AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
vops.c File Reference

The vnode operations that work on a directory and a name, or on a vnode's inode: each checks its arguments, then calls the filesystem's operation (vops). More...

#include <core/system.h>
#include <fs/vfs.h>

Go to the source code of this file.

Functions

int vfs_vmknod (struct vnode *dir, const char *name, mode_t mode, dev_t dev, struct uio *uio, struct vnode **ref)
 Makes a node in a directory.
int vfs_vcreat (struct vnode *dir, const char *name, struct uio *uio, struct vnode **ref)
 Makes a regular file in a directory, with no permissions set.
int vfs_vmkdir (struct vnode *dir, const char *name, struct uio *uio, struct vnode **ref)
 Makes a directory in a directory, with no permissions set.
int vfs_vunlink (struct vnode *dir, const char *fn, struct uio *uio)
 Removes a name from a directory.
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.
int vfs_setattr (struct vnode *vnode)
 Has the filesystem store a vnode's attributes (mode, owner, times) after they were changed in memory.
int vfs_vget (struct vnode *super, ino_t ino, struct vnode **ref)
 Gets the vnode of an inode, by its number.
int vfs_map (struct vm_space *vm_space, struct vm_entry *vm_entry)
 Maps a file into an address space, for mmap(): a device's own mapping, or the filesystem's.

Detailed Description

The vnode operations that work on a directory and a name, or on a vnode's inode: each checks its arguments, then calls the filesystem's operation (vops).

Definition in file vops.c.

Function Documentation

◆ vfs_map()

int vfs_map ( struct vm_space * vm_space,
struct vm_entry * vm_entry )

Maps a file into an address space, for mmap(): a device's own mapping, or the filesystem's.

Parameters
vm_spacethe address space
vm_entrythe mapping, whose object is the file
Returns
0, -EINVAL if the mapping isn't of a file, -ENOSYS, or the filesystem's error

Definition at line 205 of file vops.c.

References vnode::fs, ISDEV, kdev_map(), vops::map, vm_object::p, vm_object::type, vfs_map(), vm_entry::vm_object, VMOBJ_FILE, VNODE_DEV, and fs::vops.

Referenced by sys_mmap(), and vfs_map().

◆ vfs_setattr()

int vfs_setattr ( struct vnode * vnode)

Has the filesystem store a vnode's attributes (mode, owner, times) after they were changed in memory.

Parameters
vnodethe vnode
Returns
0, -ENOSYS if the filesystem can't, or its error

Definition at line 156 of file vops.c.

References vnode::fs, vops::setattr, vfs_setattr(), and fs::vops.

Referenced by store(), and vfs_setattr().

◆ vfs_vcreat()

int vfs_vcreat ( struct vnode * dir,
const char * name,
struct uio * uio,
struct vnode ** ref )

Makes a regular file in a directory, with no permissions set.

Parameters
dirthe directory
namethe new file's name
uiowho is asking
refif not NULL, set to the new vnode (the caller closes it)
Returns
0, or a negative errno

Definition at line 52 of file vops.c.

References vfs_vcreat(), and vfs_vmknod().

Referenced by vfs_vcreat().

◆ vfs_vget()

int vfs_vget ( struct vnode * super,
ino_t ino,
struct vnode ** ref )

Gets the vnode of an inode, by its number.

On success it has a reference for the caller.

Parameters
superany vnode of the filesystem (it names the filesystem)
inothe inode number
refif not NULL, set to the vnode (the caller closes it)
Returns
0, -ENOSYS if the filesystem can't, or its error

Definition at line 176 of file vops.c.

References vnode::fs, vnode::ino, NULL, vnode::ref, vfs_vget(), vops::vget, and fs::vops.

Referenced by entry_get(), lookup_name(), vfs_lookup_parent(), vfs_parent(), vfs_remove(), and vfs_vget().

◆ vfs_vlink()

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.

Parameters
dirthe directory
fnthe new name
vnodethe file
uiowho is asking
Returns
0, -EXDEV across filesystems, -ENOTDIR, -ENOSYS, or the filesystem's error

Definition at line 103 of file vops.c.

References vnode::fs, vnode::mode, vfs_vlink(), vops::vlink, and fs::vops.

Referenced by vfs_link(), and vfs_vlink().

◆ vfs_vmkdir()

int vfs_vmkdir ( struct vnode * dir,
const char * name,
struct uio * uio,
struct vnode ** ref )

Makes a directory in a directory, with no permissions set.

Parameters
dirthe directory
namethe new directory's name
uiowho is asking
refif not NULL, set to the new vnode (the caller closes it)
Returns
0, or a negative errno

Definition at line 66 of file vops.c.

References vfs_vmkdir(), and vfs_vmknod().

Referenced by vfs_vmkdir().

◆ vfs_vmknod()

int vfs_vmknod ( struct vnode * dir,
const char * name,
mode_t mode,
dev_t dev,
struct uio * uio,
struct vnode ** ref )

Makes a node in a directory.

On success the new vnode has a reference for the caller.

Parameters
dirthe directory
namethe new node's name
modeits type (S_IF*) and permissions
devits device number, for a device node
uiowho is asking
refif not NULL, set to the new vnode (the caller closes it)
Returns
0, -ENOTDIR, -ENOSYS if the filesystem can't, or its error

Definition at line 22 of file vops.c.

References vnode::fs, vnode::mode, vfs_vmknod(), vops::vmknod, and fs::vops.

Referenced by pts_new(), vfs_mknod(), vfs_vcreat(), vfs_vmkdir(), and vfs_vmknod().

◆ vfs_vrename()

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.

Parameters
odirthe directory it's in
ofnits name
ndirthe directory it goes to
nfnits new name
uiowho is asking
Returns
0, -EXDEV across filesystems, -ENOTDIR, -ENOSYS, or the filesystem's error

Definition at line 132 of file vops.c.

References vnode::fs, vnode::mode, vfs_vrename(), fs::vops, and vops::vrename.

Referenced by vfs_rename(), and vfs_vrename().

◆ vfs_vunlink()

int vfs_vunlink ( struct vnode * dir,
const char * fn,
struct uio * uio )

Removes a name from a directory.

Parameters
dirthe directory
fnthe name
uiowho is asking
Returns
0, -ENOSYS if the filesystem can't, or its error

Definition at line 79 of file vops.c.

References vnode::fs, vfs_vunlink(), fs::vops, and vops::vunlink.

Referenced by pty_free(), vfs_remove(), and vfs_vunlink().