Next: 8.2 struct vfsops
Up: 8. Appendix: Vnode Interface
Previous: 8. Appendix: Vnode Interface
8.1 struct vfs
An instance of the vfs structure exists in a running kernel for each
mounted file system. All of these instances are chained together in a
singly-linked list. The head of the list is a global variable called root_vp, which contains the vfs for the root device. The field vfs_next links one vfs structure to the following one in the list.
Figure:
SunOS 5.x VFS Interface
Figure:
SunOS 5.x VFS Interface
typedef struct vfs {
struct vfs *vfs_next; /* next VFS in VFS list */
struct vfsops *vfs_op; /* operations on VFS */
struct vnode *vfs_vnodecovered; /* vnode mounted on */
u_long vfs_flag; /* flags */
u_long vfs_bsize; /* native block size */
int vfs_fstype; /* file system type index */
fsid_t vfs_fsid; /* file system id */
caddr_t vfs_data; /* private data */
dev_t vfs_dev; /* device of mounted VFS */
u_long vfs_bcount; /* I/O count (accounting) */
u_short vfs_nsubmounts; /* immediate sub-mount count */
struct vfs *vfs_list; /* sync list pointer */
struct vfs *vfs_hash; /* hash list pointer */
kmutex_t vfs_reflock; /* mount/unmount/sync lock */
} vfs_t;
|
5.3in
typedef struct vfs {
struct vfs *vfs_next; /* next VFS in VFS list */
struct vfsops *vfs_op; /* operations on VFS */
struct vnode *vfs_vnodecovered; /* vnode mounted on */
u_long vfs_flag; /* flags */
u_long vfs_bsize; /* native block size */
int vfs_fstype; /* file system type index */
fsid_t vfs_fsid; /* file system id */
caddr_t vfs_data; /* private data */
dev_t vfs_dev; /* device of mounted VFS */
u_long vfs_bcount; /* I/O count (accounting) */
u_short vfs_nsubmounts; /* immediate sub-mount count */
struct vfs *vfs_list; /* sync list pointer */
struct vfs *vfs_hash; /* hash list pointer */
kmutex_t vfs_reflock; /* mount/unmount/sync lock */
} vfs_t;
|
The fields relevant to this proposal are as follows:
- vfs_next is a pointer to the next vfs in the linked list.
- vfs_op is a pointer to a function-pointer table. That is,
this vfs_op can hold pointers to UFS functions, NFS, PCFS, HSFS, etc.
For example, if the vnode interface calls the function to mount the file
system, it will call whatever subfield of struct vfsops (See Section
sec-appendix-vnode-vfsops) is designated for the mount function. That
is how the transition from the vnode level to a file system-specific level is
made.
- vfs_vnodecovered is the vnode on which this file system is
mounted (the mount point).
- vfs_flag contains bit flags for characteristics such as
whether this file system is mounted read-only, if the setuid/setgid bits
should be turned off when exec-ing a new process, if sub-mounts are allowed,
etc.
- vfs_data is a pointer to opaque data specific to this vfs and
the type of file system this one is. For an NFS vfs, this would be a pointer
to struct mntinfo (located in <nfs/nfs_clnt.h>) -- a large
NFS-specific structure containing such information as the NFS mount options,
NFS read and write sizes, host name, attribute cache limits, whether the
remote server is down or not, and more.
- vfs_reflock is a mutual exclusion variable used by locking
functions that need to change values of certain fields in the vfs structure.
Next: 8.2 struct vfsops
Up: 8. Appendix: Vnode Interface
Previous: 8. Appendix: Vnode Interface
Erez Zadok
1999-12-07