8#include <aquila/fcntl.h>
24int vfs_link(
const char *oldpath,
struct uio *ouio,
const char *newpath,
struct uio *nuio)
76 size_t len = strlen(target);
89 return written < 0 ? written : -EIO;
108 struct uio link_uio = *
uio;
109 link_uio.
flags |= O_NOFOLLOW;
129 struct dirent dirent;
137 return ret ? ret :
vfs_vget(dir, dirent.d_ino, ref);
154int vfs_rename(
const char *oldpath,
struct uio *ouio,
const char *newpath,
struct uio *nuio)
171 if ((ret =
entry_get(odir, oname, &ovnode)))
179 if ((ret =
entry_get(ndir, nname, &nvnode)))
183 if (ovnode == nvnode || (odir == ndir && !strcmp(oname, nname)))
193 if (S_ISDIR(ovnode->mode) &&
vfs_under(ndir, ovnode)) {
199 if (S_ISDIR(ovnode->mode) && !S_ISDIR(nvnode->mode)) {
204 if (!S_ISDIR(ovnode->mode) && S_ISDIR(nvnode->mode)) {
int vfs_close(struct vnode *vnode)
Drops a reference to a vnode.
void kfree(void *)
Frees an object that kmalloc() gave.
int vfs_rename(const char *oldpath, struct uio *ouio, const char *newpath, struct uio *nuio)
Renames a file or a directory, possibly to another directory of the same mounted filesystem.
int vfs_link(const char *oldpath, struct uio *ouio, const char *newpath, struct uio *nuio)
Makes a hard link: a new name for an existing file, in the same mounted filesystem.
ssize_t vfs_readlink(const char *path, struct uio *uio, char *buf, size_t size)
Reads what a symbolic link contains.
static int entry_get(struct vnode *dir, const char *name, struct vnode **ref)
Gets the vnode of the entry name of dir, or NULL in *ref if there is none.
int vfs_symlink(const char *target, const char *path, struct uio *uio)
Makes a symbolic link.
int vfs_lookup_dir(const char *path, struct uio *uio, struct vnode **ref, struct vnode **dir)
Finds the vnode a path names, as vfs_lookup() does, and the directory it was found in.
int vfs_lookup_parent(const char *path, struct uio *uio, struct vnode **dir, char **name)
Finds the directory of a path's last component, and the component's name, to make or remove an entry ...
struct vnode * vfs_mount_root_of(struct vnode *vnode)
Finds the root of the mounted filesystem a vnode is in.
int vfs_under(struct vnode *vnode, struct vnode *dir)
Says whether a vnode is a directory or under it, in the same filesystem: rename() can't move a direct...
int vfs_lookup(const char *path, struct uio *uio, struct vnode **ref)
Finds the vnode a path names.
int vfs_mknod(const char *path, mode_t mode, dev_t dev, struct uio *uio, struct vnode **ref)
Makes a node at a path.
ssize_t vfs_read(struct vnode *vnode, off_t off, size_t size, void *buf)
Reads from a vnode into a kernel buffer.
int vfs_finddir(struct vnode *dir, const char *name, struct dirent *dirent)
Finds the entry of a directory that has a name.
int vfs_dir_empty(struct vnode *dir)
Says whether a directory is empty, so that it can be removed.
Who does a filesystem operation: where its paths start, and its credentials and umask.
A file in memory (a vnode): what its inode says, and the kernel's own state.
int vfs_unlink(const char *path, struct uio *uio)
Removes the name of a file (not a directory) at a path.
int vfs_access(struct vnode *vnode, struct uio *uio, int mode)
Checks whether a user may access a vnode in a way: the owner's permissions apply to its owner,...
int vfs_vget(struct vnode *super, ino_t ino, struct vnode **ref)
Gets the vnode of an inode, by its number.
int vfs_vlink(struct vnode *dir, const char *fn, struct vnode *vnode, struct uio *uio)
Adds a name for an existing file (a hard link) to a directory of the same filesystem.
int vfs_vrename(struct vnode *odir, const char *ofn, struct vnode *ndir, const char *nfn, struct uio *uio)
Renames an entry, possibly to another directory of the same filesystem.
ssize_t vfs_write(struct vnode *vnode, off_t off, size_t size, void *buf)
Writes to a vnode from a kernel buffer.