*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->NetBSD man pages -> VFS_VGET (9)              
Title
Content
Arch
Section
 

VFSOPS(9)

Contents


NAME    [Toc]    [Back]

     vfsops, vfs_rootmountalloc, vfs_export_lookup, vfs_getnewfsid, VFS_MOUNT,
     VFS_START, VFS_UNMOUNT, VFS_ROOT, VFS_QUOTACTL, VFS_STATFS, VFS_STATFS,
     VFS_SYNC, VFS_VGET, VFS_FHTOVP, VFS_VPTOFH, VFS_CHECKEXP - kernel file
     system interface

SYNOPSIS    [Toc]    [Back]

     #include <sys/param.h>
     #include <sys/mount.h>
     #include <sys/vnode.h>

     int
     vfs_rootmountalloc(char *fstypename, char *devname, struct mount **mpp);

     int
     vfs_export_lookup(struct mount *mp, struct netexport *nep,
             struct export_args *argp);

     void
     vfs_getnewfsid(struct mount *mp);

     int
     VFS_MOUNT(struct mount *mp, const char *path, void *data,
             struct nameidata *ndp, struct proc *p);

     int
     VFS_START(struct mount *mp, int flags, struct proc *p);

     int
     VFS_UNMOUNT(struct mount *mp, int mntflags, struct proc *p);

     int
     VFS_ROOT(struct mount *mp, struct vnode **vpp);

     int
     VFS_QUOTACTL(struct mount *mp, int cmds, uid_t uid, caddr_t arg,
             struct proc *p);

     int
     VFS_STATFS(struct mount *mp, struct statfs *sbp, struct proc *p);

     int
     VFS_SYNC(struct mount *mp, int waitfor, struct ucred *cred,
             struct proc *p);

     int
     VFS_VGET(struct mount *mp, ino_t ino, struct vnode **vpp);

     int
     VFS_FHTOVP(struct mount *mp, struct fid *fhp, struct vnode **vpp);

     int
     VFS_VPTOFH(struct vnode *vp, struct fid *fhp);

     int
     VFS_CHECKEXP(struct mount *mp, struct mbuf *nam, int *extflagsp,
             struct ucred **credanonp);

DESCRIPTION    [Toc]    [Back]

     In a similar fashion to the vnode(9) interface, all operations that are
     done on a file system are conducted through a single interface that
     allows the system to carry out operations on a file system without knowing
 its construction or type.

     All supported file systems in the kernel have an entry in the
     vfs_list_initial table.  This table is generated by config(8) and is a
     NULL-terminated list of vfsops structures.  The vfsops structure
     describes the operations that can be done to a specific file system type.
     The following table list the elements of the vfsops vector, the corresponding
 invocation macro, and a description of the element.

     Vector element          Macro         Description
     int  (*vfs_mount)()     VFS_MOUNT     Mount a file system
     int  (*vfs_start)()     VFS_START     Make operational
     int  (*vfs_unmount)()   VFS_UMOUNT    Unmount a file system
     int  (*vfs_root)()      VFS_ROOT      Get the file system root vnode
     int  (*vfs_quotactl)()  VFS_QUOTACTL  Query/modify space quotas
     int  (*vfs_statfs)()    VFS_STATFS    Get file system statistics
     int  (*vfs_sync)()      VFS_SYNC      Flush file system buffers
     int  (*vfs_vget)()      VFS_VGET      Get vnode from file ID
     int  (*vfs_fhtovp)()    VFS_FHTOVP    NFS file handle to vnode lookup
     int  (*vfs_vptofh)()    VFS_VPTOFH    Vnode to NFS file handle lookup
     void (*vfs_init)()      -             Initialise file system
     void (*vfs_reinit)()    -             Reinitialise file system
     void (*vfs_done)()      -             Cleanup unmounted file system
     int  (*vfs_sysctl)()    -             Query/modify kernel state
     int  (*vfs_mountroot)() -             Mount the root file system
     int  (*vfs_checkexp)()  VFS_CHECKEXP  Check if fs is exported

     Some additional non-function members of the vfsops structure are the file
     system name vfs_name and a reference count vfs_refcount.  It is not
     mandatory for a file system type to support a particular operation, but
     it must assign each member function pointer to a suitable function to do
     the minimum required of it.  In most cases, such functions either do
     nothing or return an error value to the effect that it is not supported.

     At system boot, each file system with an entry in vfs_list_initial is
     established and initialised.  Each initialised file system is recorded by
     the kernel in the list vfs_list and the file system specific initialisation
 function vfs_init in its vfsops vector is invoked.  When the file
     system is not longer needed vfs_done is invoked to run file system specific
 cleanups and the file system is removed from the kernel list.

     At system boot, the root filesystem is mounted by invoking the file system
 type specific vfs_mountroot function in the vfsops vector.  All
     filesystems that can be mounted as a root file system must define this
     function.  It is responsible for initialising to list of mount structures
     for all future mounted file systems.

     Kernel state which affects a specific file system type can be queried and
     modified using the sysctl(8) interface.  The vfs_sysctl member of the
     vfsops structure is invoked by file system independent code for sysctl
     operations which are file system specific.

FUNCTIONS    [Toc]    [Back]

     vfs_rootmountalloc(fstypename, devname, mpp)
              Lookup a file system type specied by the name fstypename and if
              found allocate and initialise a mount structure for it.  The
              allocated mount structure is returned in the address specified
              by mpp.  The device the root file system was mounted from is
              specified by the argument devname and is recorded in the new
              mount structure.

     vfs_export_lookup(mp, nep, argp)
              Check client permission on the exportable file system specified
              by the mount structure mp.  The argument nam is the address of
              the networked client.  This function is used by file system type
              specific functions to verify that the client can access the file
              system.

     vfs_getnewfsid(mp)
              Get a new unique file system id type for the file system specified
 by the mount structure mp.  The file system id type is
              stored in mp->mnt_stat.f_fsid.

     VFS_MOUNT(mp, path, data, ndp, p)
              Mount a file system specified by the mount structure mp on the
              mount point described by path.  The argument data contains file
              system type specific data and is read into the kernel using
              copyin(9).  The argument ndp contains the result of a namei(9)
              call on the pathname of the mount point and p is the calling
              process.  VFS_MOUNT() initialises the mount structure for the
              mounted file system.  This structure records mount-specific
              information for the file system and records the list of vnodes
              associated with the file system.  This function is invoked both
              to mount new file systems and to change the attributes of an
              existing file system.  If the MNT_UPDATE flag is set in
              mp->mnt_flag then the filesystem should update its internal
              state from the value of mp->mnt_flag.  This can be used, for
              instance, to convert a read-only filesystem to read-write.  If
              the MNT_UPDATE flag is not specified, then this is a newly
              mounted filesystem.

     VFS_START( mp, flags, p)
              Make the file system specified by the mount structure mp operational.
  The argument p is the calling processing.  The argument
              flags is a set of flags for controlling the operation of
              VOP_START().  This function is invoked after VFS_MOUNT() and
              before the first acces to the file system.

     VFS_UNMOUNT(mp, mntflags, p)
              Unmount a file system specified by the mount structure mp.  The
              argument p is the calling process.  VFS_UNMOUNT performs any
              file system type specific operations required before the file
              system is unmounted, such are flushing buffers.  If MNT_FORCE is
              specified in the flags mntflags then open files are forcibly
              closed.  The function also deallocates space associated with
              data structure that were allocated for the file system when it
              was mounted.

     VFS_ROOT(mp, vpp)
              Get the root vnode of the file system specified by the mount
              structure mp.  The vnode is returned in the address given by
              vpp.  This function is used by the pathname translation algorithms
 when a vnode that has been covered by a mounted file system
 is encountered.  While resolving the pathname, the pathname
              translation algorithm will have to go through the directory tree
              in the file system associated with that mount point and therefore
 requires the root vnode of the file system.

     VFS_QUOTACTL(mp, cmds, uid, arg, p)
              Query/modify user space quotas for the file system specified by
              the mount structure mp.  The argument specifies the control command
 to perform.  The userid is specified in id, the calling
              process is p and arg allows command-specific data to be returned
              to the system call interface.  VFS_QUOTACTL() is the file system
              type specific implementation of the quotactl(2) system call.

     VFS_STATFS(mp, sbp, p)
              Get file system statistics for the file system specified by the
              mount structure mp.  The argument p is the calling processing.
              A statfs structure filled with the statistics is returned in
              sbp.  VFS_STATFS() is the file system type specific implementation
 of the statfs(2) and fstatfs(2) system calls.

     VFS_SYNC(mp, waitfor, cred, p)
              Flush file system I/O buffers for the file system specified by
              the mount structure mp.  The waitfor argument indicates whether
              a partial flush or complete flush should be performed.  The
              arguments p and cred specific the calling process and its credentials
 respectively.  VFS_SYNC() does not provide any return
              value since the operation can never fail.

     VFS_VGET(mp, ino, vpp)
              Get vnode for a file system type specific file id ino for the
              file system specified by the mount structure mp.  The vnode is
              returned in the address specified vpp.  The function is optional
              for file systems which have a unique id number for every file in
              the file system.  It is used internally by the UFS file system
              and also by the NFSv3 server to implement the READDIRPLUS nfs
              call.  If the file system does not support this invoked, it
              should return EOPNOTSUPP.

     VFS_FHTOVP(mp, fhp, vpp)
              Get the vnode for the NFS file specified by the file handle fhp
              in the file system specified by the mount structure mp.  The
              locked vnode is returned in vpp.

              A call to VFS_FHTOVP should generally be followed by a call to
              VFS_CHECKEXP() to check if the file is accessable to the client.

     VFS_VPTOFH(vp, fhp)
              Get a unique NFS file handle for the file specified by the vnode
              vp.  The file handle is returned in fhp.  The contents of the
              file handle are defined by the file system and are not examined
              by an eother subsystems.  It should contain enough information
              to uniquely identify a file within the file system as well as
              noticing when a file has been removed and the file system
              resources have been recycled for a new file.

     VFS_CHECKEXP(mp, nam, extflagsp, credanonp)
              Check if the file system specified by the mount structure mp is
              exported to a client with anonymous credentials credanonp.  The
              argument nam is an mbuf containing the network address of the
              client.  The return parameters for the export flags for the
              client are returned in the address specified by exflagsp.  This
              function is used by the NFS server.  It is generally invoked
              before VFS_FHTOVP() to validate that client has access to the
              file system.  The file system should call vfs_export_lookup()
              with the address of an appropriate netexport structure and the
              address of the client to verify that the client can access this
              file system.

CODE REFERENCES    [Toc]    [Back]

     This section describes places within the NetBSD source tree where actual
     code implementing or utilising the vfs operations can be found.  All
     pathnames are relative to /usr/src.

     The vfs operations are implemented within the files sys/kern/vfs_subr.c
     and sys/kern/vfs_init.c.

SEE ALSO    [Toc]    [Back]

      
      
     intro(9), namei(9), vfs(9), vnode(9)

HISTORY    [Toc]    [Back]

     The vfs operations vector, its functions and the corresponding macros
     appeared in 4.3BSD.

BSD                             October 6, 2001                            BSD
[ Back ]
 Similar pages
Name OS Title
vfs OpenBSD kernel interface to file systems
vfs NetBSD kernel interface to file systems
VFS FreeBSD kernel interface to file systems
sizer Tru64 Displays information about the system or kernel, or creates a system configuration file
create_sysfile HP-UX create a kernel system file
mk_kernel HP-UX load a kernel configuration from a system file
syncer FreeBSD file system synchronizer kernel process
kreg Tru64 Maintains the system file that registers kernel layered products
libugidfw FreeBSD library interface to the file system firewall MAC policy
vxfs_max_ra_kbytes HP-UX maximum amount of read-ahead data, in KB, that kernel may have outstanding for a single VxFS file system
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service