2007-08-01 01:39:56 +04:00
|
|
|
.\" $NetBSD: vfsops.9,v 1.32 2007/07/31 21:39:56 pooka Exp $
|
2001-10-22 07:33:19 +04:00
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 2001 The NetBSD Foundation, Inc.
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
.\" by Gregory McGarry.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\" 3. All advertising materials mentioning features or use of this software
|
|
|
|
.\" must display the following acknowledgement:
|
|
|
|
.\" This product includes software developed by the NetBSD
|
|
|
|
.\" Foundation, Inc. and its contributors.
|
|
|
|
.\" 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
.\" contributors may be used to endorse or promote products derived
|
|
|
|
.\" from this software without specific prior written permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
2001-10-22 12:21:32 +04:00
|
|
|
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
2001-10-22 07:33:19 +04:00
|
|
|
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
.\" POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
.\"
|
2007-08-01 01:39:56 +04:00
|
|
|
.Dd July 31, 2007
|
2001-10-22 07:33:19 +04:00
|
|
|
.Dt VFSOPS 9
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm vfsops ,
|
|
|
|
.Nm VFS_MOUNT ,
|
|
|
|
.Nm VFS_START ,
|
|
|
|
.Nm VFS_UNMOUNT ,
|
|
|
|
.Nm VFS_ROOT ,
|
|
|
|
.Nm VFS_QUOTACTL ,
|
2005-07-20 15:35:48 +04:00
|
|
|
.Nm VFS_STATVFS ,
|
2001-10-22 07:33:19 +04:00
|
|
|
.Nm VFS_SYNC ,
|
|
|
|
.Nm VFS_VGET ,
|
|
|
|
.Nm VFS_FHTOVP ,
|
|
|
|
.Nm VFS_VPTOFH ,
|
2007-01-21 18:42:36 +03:00
|
|
|
.Nm VFS_SNAPSHOT ,
|
|
|
|
.Nm VFS_SUSPENDCTL
|
2001-10-22 07:33:19 +04:00
|
|
|
.Nd kernel file system interface
|
|
|
|
.Sh SYNOPSIS
|
2003-04-16 17:34:34 +04:00
|
|
|
.In sys/param.h
|
|
|
|
.In sys/mount.h
|
|
|
|
.In sys/vnode.h
|
2001-10-22 07:33:19 +04:00
|
|
|
.Ft int
|
2007-08-01 01:39:56 +04:00
|
|
|
.Fo VFS_MOUNT
|
|
|
|
.Fa "struct mount *mp" "const char *path" "void *data" "size_t *dlen"
|
|
|
|
.Fa "struct lwp *l"
|
|
|
|
.Fc
|
2001-10-22 07:33:19 +04:00
|
|
|
.Ft int
|
2005-12-20 22:53:14 +03:00
|
|
|
.Fn VFS_START "struct mount *mp" "int flags" "struct lwp *l"
|
2001-10-22 07:33:19 +04:00
|
|
|
.Ft int
|
2005-12-20 22:53:14 +03:00
|
|
|
.Fn VFS_UNMOUNT "struct mount *mp" "int mntflags" "struct lwp *l"
|
2001-10-22 07:33:19 +04:00
|
|
|
.Ft int
|
|
|
|
.Fn VFS_ROOT "struct mount *mp" "struct vnode **vpp"
|
|
|
|
.Ft int
|
|
|
|
.Fn VFS_QUOTACTL "struct mount *mp" "int cmds" "uid_t uid" \
|
2007-03-07 03:41:16 +03:00
|
|
|
"void *arg" "struct lwp *l"
|
2001-10-22 07:33:19 +04:00
|
|
|
.Ft int
|
2005-12-20 22:53:14 +03:00
|
|
|
.Fn VFS_STATVFS "struct mount *mp" "struct statvfs *sbp" "struct lwp *l"
|
2001-10-22 07:33:19 +04:00
|
|
|
.Ft int
|
2006-10-04 15:35:47 +04:00
|
|
|
.Fn VFS_SYNC "struct mount *mp" "int waitfor" "kauth_cred_t cred" \
|
2005-12-20 22:53:14 +03:00
|
|
|
"struct lwp *l"
|
2001-10-22 07:33:19 +04:00
|
|
|
.Ft int
|
|
|
|
.Fn VFS_VGET "struct mount *mp" "ino_t ino" "struct vnode **vpp"
|
|
|
|
.Ft int
|
|
|
|
.Fn VFS_FHTOVP "struct mount *mp" "struct fid *fhp" "struct vnode **vpp"
|
|
|
|
.Ft int
|
2007-04-16 18:47:19 +04:00
|
|
|
.Fn VFS_VPTOFH "struct vnode *vp" "struct fid *fhp" "size_t *fh_size"
|
2001-10-22 07:33:19 +04:00
|
|
|
.Ft int
|
2004-05-25 18:54:55 +04:00
|
|
|
.Fn VFS_SNAPSHOT "struct mount *mp" "struct vnode *vp" "struct timespec *ts"
|
2007-01-21 18:42:36 +03:00
|
|
|
.Ft int
|
|
|
|
.Fn VFS_SUSPENDCTL "struct mount *mp" "int cmd"
|
2001-10-22 07:33:19 +04:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
In a similar fashion to the
|
|
|
|
.Xr 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.
|
|
|
|
.Pp
|
|
|
|
All supported file systems in the kernel have an entry in the
|
|
|
|
.Va vfs_list_initial
|
2002-10-14 17:43:14 +04:00
|
|
|
table.
|
|
|
|
This table is generated by
|
2005-06-20 17:25:23 +04:00
|
|
|
.Xr config 1
|
2002-08-15 07:23:55 +04:00
|
|
|
and is a
|
|
|
|
.Dv NULL Ns No -terminated
|
|
|
|
list of
|
2001-10-22 07:33:19 +04:00
|
|
|
.Em vfsops
|
2002-10-14 17:43:14 +04:00
|
|
|
structures.
|
|
|
|
The vfsops structure describes the operations that can be done to a
|
|
|
|
specific file system type.
|
2006-04-25 05:45:17 +04:00
|
|
|
The following table lists the elements of the vfsops vector, the
|
2002-10-14 17:43:14 +04:00
|
|
|
corresponding invocation macro, and a description of the element.
|
2001-10-22 07:33:19 +04:00
|
|
|
.Pp
|
|
|
|
.nf
|
|
|
|
.ta \w'int (*vfs_mountroot)()'u+2n +\w'VFS_QUOTACTL'u+2n +\w'Get the file system root vnode'u
|
|
|
|
\fIVector element\fP \fIMacro\fP \fIDescription\fP
|
|
|
|
.ta \w'int (*vfs_mountroot)()'u+2n +\w'VFS_QUOTACTL'u+2n +\w'Get the file system root vnode'u+6nC
|
|
|
|
.sp 5p
|
|
|
|
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
|
2005-07-20 15:35:48 +04:00
|
|
|
int (*vfs_statvfs)() VFS_STATVFS Get file system statistics
|
2001-10-22 07:33:19 +04:00
|
|
|
int (*vfs_sync)() VFS_SYNC Flush file system buffers
|
2002-08-14 22:50:48 +04:00
|
|
|
int (*vfs_vget)() VFS_VGET Get vnode from file id
|
2001-10-22 07:33:19 +04:00
|
|
|
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_mountroot)() - Mount the root file system
|
2004-05-25 18:54:55 +04:00
|
|
|
int (*vfs_snapshot)() VFS_SNAPSHOT Take a snapshot
|
2007-01-21 18:42:36 +03:00
|
|
|
int (*vfs_suspendctl)() VFS_SUSPENDCTL Suspend or resume
|
2001-10-22 07:33:19 +04:00
|
|
|
.fi
|
|
|
|
.Pp
|
|
|
|
Some additional non-function members of the vfsops structure are the
|
|
|
|
file system name
|
|
|
|
.Ns Em vfs_name
|
|
|
|
and a reference count
|
|
|
|
.Ns Em 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
|
2002-10-14 17:43:14 +04:00
|
|
|
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.
|
Apply the NFS exports list rototill patch:
- Remove all NFS related stuff from file system specific code.
- Drop the vfs_checkexp hook and generalize it in the new nfs_check_export
function, thus removing redundancy from all file systems.
- Move all NFS export-related stuff from kern/vfs_subr.c to the new
file sys/nfs/nfs_export.c. The former was becoming large and its code
is always compiled, regardless of the build options. Using the latter,
the code is only compiled in when NFSSERVER is enabled. While doing this,
also make some functions in nfs_subs.c conditional to NFSSERVER.
- Add a new command in nfssvc(2), called NFSSVC_SETEXPORTSLIST, that takes a
path and a set of export entries. At the moment it can only clear the
exports list or append entries, one by one, but it is done in a way that
allows setting the whole set of entries atomically in the future (see the
comment in mountd_set_exports_list or in doc/TODO).
- Change mountd(8) to use the nfssvc(2) system call instead of mount(2) so
that it becomes file system agnostic. In fact, all this whole thing was
done to remove a 'XXX' block from this utility!
- Change the mount*, newfs and fsck* userland utilities to not deal with NFS
exports initialization; done internally by the kernel when initializing
the NFS support for each file system.
- Implement an interface for VFS (called VFS hooks) so that several kernel
subsystems can run arbitrary code upon receipt of specific VFS events.
At the moment, this only provides support for unmount and is used to
destroy NFS exports lists from the file systems being unmounted, though it
has room for extension.
Thanks go to yamt@, chs@, thorpej@, wrstuden@ and others for their comments
and advice in the development of this patch.
2005-09-23 16:10:31 +04:00
|
|
|
.Em vfs_reinit ,
|
|
|
|
.Em vfs_mountroot ,
|
2005-09-24 00:30:48 +04:00
|
|
|
.Em vfs_fhtovp ,
|
2002-08-14 22:50:48 +04:00
|
|
|
and
|
Apply the NFS exports list rototill patch:
- Remove all NFS related stuff from file system specific code.
- Drop the vfs_checkexp hook and generalize it in the new nfs_check_export
function, thus removing redundancy from all file systems.
- Move all NFS export-related stuff from kern/vfs_subr.c to the new
file sys/nfs/nfs_export.c. The former was becoming large and its code
is always compiled, regardless of the build options. Using the latter,
the code is only compiled in when NFSSERVER is enabled. While doing this,
also make some functions in nfs_subs.c conditional to NFSSERVER.
- Add a new command in nfssvc(2), called NFSSVC_SETEXPORTSLIST, that takes a
path and a set of export entries. At the moment it can only clear the
exports list or append entries, one by one, but it is done in a way that
allows setting the whole set of entries atomically in the future (see the
comment in mountd_set_exports_list or in doc/TODO).
- Change mountd(8) to use the nfssvc(2) system call instead of mount(2) so
that it becomes file system agnostic. In fact, all this whole thing was
done to remove a 'XXX' block from this utility!
- Change the mount*, newfs and fsck* userland utilities to not deal with NFS
exports initialization; done internally by the kernel when initializing
the NFS support for each file system.
- Implement an interface for VFS (called VFS hooks) so that several kernel
subsystems can run arbitrary code upon receipt of specific VFS events.
At the moment, this only provides support for unmount and is used to
destroy NFS exports lists from the file systems being unmounted, though it
has room for extension.
Thanks go to yamt@, chs@, thorpej@, wrstuden@ and others for their comments
and advice in the development of this patch.
2005-09-23 16:10:31 +04:00
|
|
|
.Em vfs_vptofh
|
2002-08-14 22:50:48 +04:00
|
|
|
may
|
2002-08-15 07:23:55 +04:00
|
|
|
be
|
|
|
|
.Dv NULL .
|
2001-10-22 07:33:19 +04:00
|
|
|
.Pp
|
|
|
|
At system boot, each file system with an entry in
|
|
|
|
.Va vfs_list_initial
|
2002-10-14 17:43:14 +04:00
|
|
|
is established and initialised.
|
|
|
|
Each initialised file system is recorded by the kernel in the list
|
2001-10-22 07:33:19 +04:00
|
|
|
.Va vfs_list
|
|
|
|
and the file system specific initialisation function
|
|
|
|
.Em vfs_init
|
2002-10-14 17:43:14 +04:00
|
|
|
in its vfsops vector is invoked.
|
2005-07-16 18:45:18 +04:00
|
|
|
When the file system is no longer needed
|
2001-10-22 07:33:19 +04:00
|
|
|
.Em vfs_done
|
|
|
|
is invoked to run file system specific cleanups and the file system is
|
|
|
|
removed from the kernel list.
|
|
|
|
.Pp
|
|
|
|
At system boot, the root filesystem is mounted by invoking the file
|
|
|
|
system type specific
|
|
|
|
.Em vfs_mountroot
|
2002-10-14 17:43:14 +04:00
|
|
|
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.
|
2001-10-22 07:33:19 +04:00
|
|
|
.Pp
|
|
|
|
Kernel state which affects a specific file system type can be
|
|
|
|
queried and modified using the
|
|
|
|
.Xr sysctl 8
|
2002-10-14 17:43:14 +04:00
|
|
|
interface.
|
2001-10-22 07:33:19 +04:00
|
|
|
.Sh FUNCTIONS
|
|
|
|
.Bl -tag -width compact
|
2007-08-01 01:39:56 +04:00
|
|
|
.It Fn VFS_MOUNT "mp" "path" "data" "dlen" "l"
|
2001-10-22 07:33:19 +04:00
|
|
|
Mount a file system specified by the mount structure
|
|
|
|
.Fa mp
|
|
|
|
on the mount point described by
|
|
|
|
.Fa path .
|
|
|
|
The argument
|
|
|
|
.Fa data
|
2007-08-01 01:39:56 +04:00
|
|
|
contains file system type specific data, while the argument
|
|
|
|
.Fa dlen
|
|
|
|
points to a location specifying the length of the data.
|
2001-10-22 07:33:19 +04:00
|
|
|
The argument
|
2007-06-20 20:35:52 +04:00
|
|
|
.Fa l
|
|
|
|
is the calling lwp.
|
2007-08-01 01:39:56 +04:00
|
|
|
.Pp
|
2001-10-22 07:33:19 +04:00
|
|
|
.Fn VFS_MOUNT
|
2002-10-14 17:43:14 +04:00
|
|
|
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.
|
2007-08-01 01:39:56 +04:00
|
|
|
If the flag MNT_UPDATE is set in
|
|
|
|
.Em mp-\*[Gt]mnt_flag ,
|
|
|
|
the filesystem should update its state.
|
2001-10-22 07:33:19 +04:00
|
|
|
This can be used, for instance, to convert a read-only filesystem to
|
2002-10-14 17:43:14 +04:00
|
|
|
read-write.
|
2007-08-01 01:39:56 +04:00
|
|
|
The current attributes for a mounted file system can be fetched by
|
|
|
|
specifying
|
|
|
|
.Dv MNT_GETARGS .
|
|
|
|
If neither
|
|
|
|
.Dv MNT_UPDATE
|
|
|
|
or
|
|
|
|
.Dv MNT_GETARGS
|
|
|
|
are specified, a new file system will attempted to be mounted.
|
2005-12-20 22:53:14 +03:00
|
|
|
.It Fn VFS_START "mp" "flags" "l"
|
2001-10-22 07:33:19 +04:00
|
|
|
Make the file system specified by the mount structure
|
|
|
|
.Fa mp
|
2002-10-14 17:43:14 +04:00
|
|
|
operational.
|
|
|
|
The argument
|
2007-06-20 20:35:52 +04:00
|
|
|
.Fa l
|
|
|
|
is the calling lwp.
|
2002-10-14 17:43:14 +04:00
|
|
|
The argument
|
2001-10-22 07:33:19 +04:00
|
|
|
.Fa flags
|
|
|
|
is a set of flags for controlling the operation of
|
2005-11-09 23:17:55 +03:00
|
|
|
.Fn VFS_START .
|
2001-10-22 07:33:19 +04:00
|
|
|
This function is invoked after
|
|
|
|
.Fn VFS_MOUNT
|
2003-01-03 07:18:57 +03:00
|
|
|
and before the first access to the file system.
|
2005-12-20 22:53:14 +03:00
|
|
|
.It Fn VFS_UNMOUNT "mp" "mntflags" "l"
|
2001-10-22 07:33:19 +04:00
|
|
|
Unmount a file system specified by the mount structure
|
|
|
|
.Fa mp .
|
|
|
|
The argument
|
2007-06-20 20:35:52 +04:00
|
|
|
.Fa l
|
|
|
|
is the calling lwp.
|
2003-09-06 23:02:42 +04:00
|
|
|
.Fn VFS_UNMOUNT
|
2001-10-22 07:33:19 +04:00
|
|
|
performs any file system type specific operations required before the
|
2002-10-14 17:43:14 +04:00
|
|
|
file system is unmounted, such are flushing buffers.
|
|
|
|
If MNT_FORCE is specified in the flags
|
2001-10-22 07:33:19 +04:00
|
|
|
.Fa mntflags
|
2002-10-14 17:43:14 +04:00
|
|
|
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.
|
2001-10-22 07:33:19 +04:00
|
|
|
.It Fn VFS_ROOT "mp" "vpp"
|
|
|
|
Get the root vnode of the file system specified by the mount
|
|
|
|
structure
|
|
|
|
.Fa mp .
|
|
|
|
The vnode is returned in the address given by
|
2001-10-22 12:21:32 +04:00
|
|
|
.Fa vpp .
|
2001-10-22 07:33:19 +04:00
|
|
|
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.
|
2005-12-20 22:53:14 +03:00
|
|
|
.It Fn VFS_QUOTACTL "mp" "cmds" "uid" "arg" "l"
|
2001-10-22 07:33:19 +04:00
|
|
|
Query/modify user space quotas for the file system specified by the
|
|
|
|
mount structure
|
|
|
|
.Fa mp .
|
2002-10-14 17:43:14 +04:00
|
|
|
The argument specifies the control command to perform.
|
|
|
|
The userid is specified in
|
2001-10-22 07:33:19 +04:00
|
|
|
.Fa id ,
|
2007-06-20 20:35:52 +04:00
|
|
|
the calling lwp is
|
|
|
|
.Fa l
|
2001-10-22 07:33:19 +04:00
|
|
|
and
|
|
|
|
.Fa arg
|
|
|
|
allows command-specific data to be returned to the system call
|
|
|
|
interface.
|
|
|
|
.Fn VFS_QUOTACTL
|
|
|
|
is the file system type specific implementation of the
|
|
|
|
.Xr quotactl 2
|
|
|
|
system call.
|
2005-12-20 22:53:14 +03:00
|
|
|
.It Fn VFS_STATVFS "mp" "sbp" "l"
|
2001-10-22 07:33:19 +04:00
|
|
|
Get file system statistics for the file system specified by the mount
|
|
|
|
structure
|
|
|
|
.Fa mp .
|
|
|
|
The argument
|
2007-06-20 20:35:52 +04:00
|
|
|
.Fa l
|
|
|
|
is the calling lwp.
|
2005-07-20 15:35:48 +04:00
|
|
|
A statvfs structure filled with the statistics is returned in
|
2001-10-22 07:33:19 +04:00
|
|
|
.Fa sbp .
|
2005-07-20 15:35:48 +04:00
|
|
|
.Fn VFS_STATVFS
|
2001-10-22 07:33:19 +04:00
|
|
|
is the file system type specific implementation of the
|
2005-07-20 15:35:48 +04:00
|
|
|
.Xr statvfs 2
|
2001-10-22 07:33:19 +04:00
|
|
|
and
|
2005-07-20 15:35:48 +04:00
|
|
|
.Xr fstatvfs 2
|
2001-10-22 07:33:19 +04:00
|
|
|
system calls.
|
2005-12-20 22:53:14 +03:00
|
|
|
.It Fn VFS_SYNC "mp" "waitfor" "cred" "l"
|
2001-10-22 07:33:19 +04:00
|
|
|
Flush file system I/O buffers for the file system specified by the mount
|
|
|
|
structure
|
|
|
|
.Fa mp .
|
|
|
|
The
|
|
|
|
.Fa waitfor
|
|
|
|
argument indicates whether a partial flush or complete flush should be
|
2002-10-14 17:43:14 +04:00
|
|
|
performed.
|
|
|
|
The arguments
|
2006-10-04 15:35:47 +04:00
|
|
|
.Fa l
|
2001-10-22 07:33:19 +04:00
|
|
|
and
|
|
|
|
.Fa cred
|
2006-10-04 15:35:47 +04:00
|
|
|
specific the calling lwp and its credentials, respectively.
|
2001-10-22 07:33:19 +04:00
|
|
|
.Fn VFS_SYNC
|
|
|
|
does not provide any return value since the operation can never fail.
|
|
|
|
.It Fn VFS_VGET "mp" "ino" "vpp"
|
|
|
|
Get vnode for a file system type specific file id
|
|
|
|
.Fa ino
|
|
|
|
for the file system specified by the mount structure
|
|
|
|
.Fa mp .
|
|
|
|
The vnode is returned in the address specified
|
|
|
|
.Fa vpp .
|
|
|
|
The function is optional for file systems which have a unique id
|
2002-10-14 17:43:14 +04:00
|
|
|
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 function, it should return
|
2002-08-15 07:23:55 +04:00
|
|
|
.Er EOPNOTSUPP .
|
2001-10-22 07:33:19 +04:00
|
|
|
.It Fn VFS_FHTOVP "mp" "fhp" "vpp"
|
2007-04-16 18:47:19 +04:00
|
|
|
Get the vnode for the file handle
|
2001-10-22 07:33:19 +04:00
|
|
|
.Fa fhp
|
|
|
|
in the file system specified by the mount structure
|
|
|
|
.Fa mp .
|
|
|
|
The locked vnode is returned in
|
|
|
|
.Fa vpp .
|
|
|
|
.Pp
|
2007-04-16 18:47:19 +04:00
|
|
|
When exporting, the call to
|
2003-09-06 23:02:42 +04:00
|
|
|
.Fn VFS_FHTOVP
|
2007-04-16 18:47:19 +04:00
|
|
|
should follow a call to
|
|
|
|
.Fn netexport_check ,
|
|
|
|
which checks if the file is accessable to the client.
|
Apply the NFS exports list rototill patch:
- Remove all NFS related stuff from file system specific code.
- Drop the vfs_checkexp hook and generalize it in the new nfs_check_export
function, thus removing redundancy from all file systems.
- Move all NFS export-related stuff from kern/vfs_subr.c to the new
file sys/nfs/nfs_export.c. The former was becoming large and its code
is always compiled, regardless of the build options. Using the latter,
the code is only compiled in when NFSSERVER is enabled. While doing this,
also make some functions in nfs_subs.c conditional to NFSSERVER.
- Add a new command in nfssvc(2), called NFSSVC_SETEXPORTSLIST, that takes a
path and a set of export entries. At the moment it can only clear the
exports list or append entries, one by one, but it is done in a way that
allows setting the whole set of entries atomically in the future (see the
comment in mountd_set_exports_list or in doc/TODO).
- Change mountd(8) to use the nfssvc(2) system call instead of mount(2) so
that it becomes file system agnostic. In fact, all this whole thing was
done to remove a 'XXX' block from this utility!
- Change the mount*, newfs and fsck* userland utilities to not deal with NFS
exports initialization; done internally by the kernel when initializing
the NFS support for each file system.
- Implement an interface for VFS (called VFS hooks) so that several kernel
subsystems can run arbitrary code upon receipt of specific VFS events.
At the moment, this only provides support for unmount and is used to
destroy NFS exports lists from the file systems being unmounted, though it
has room for extension.
Thanks go to yamt@, chs@, thorpej@, wrstuden@ and others for their comments
and advice in the development of this patch.
2005-09-23 16:10:31 +04:00
|
|
|
.Pp
|
2007-04-16 18:47:19 +04:00
|
|
|
If file handles are not supported by the file system, this function
|
|
|
|
must return
|
|
|
|
.Er EOPNOTSUPP .
|
|
|
|
.It Fn VFS_VPTOFH "vp" "fhp" "fh_size"
|
|
|
|
Get a file handle for the vnode specified by
|
2001-10-22 07:33:19 +04:00
|
|
|
.Fa vp .
|
|
|
|
The file handle is returned in
|
|
|
|
.Fa fhp .
|
|
|
|
The contents of the file handle are defined by the file system and are
|
2002-10-14 17:43:14 +04:00
|
|
|
not examined by any other 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.
|
Apply the NFS exports list rototill patch:
- Remove all NFS related stuff from file system specific code.
- Drop the vfs_checkexp hook and generalize it in the new nfs_check_export
function, thus removing redundancy from all file systems.
- Move all NFS export-related stuff from kern/vfs_subr.c to the new
file sys/nfs/nfs_export.c. The former was becoming large and its code
is always compiled, regardless of the build options. Using the latter,
the code is only compiled in when NFSSERVER is enabled. While doing this,
also make some functions in nfs_subs.c conditional to NFSSERVER.
- Add a new command in nfssvc(2), called NFSSVC_SETEXPORTSLIST, that takes a
path and a set of export entries. At the moment it can only clear the
exports list or append entries, one by one, but it is done in a way that
allows setting the whole set of entries atomically in the future (see the
comment in mountd_set_exports_list or in doc/TODO).
- Change mountd(8) to use the nfssvc(2) system call instead of mount(2) so
that it becomes file system agnostic. In fact, all this whole thing was
done to remove a 'XXX' block from this utility!
- Change the mount*, newfs and fsck* userland utilities to not deal with NFS
exports initialization; done internally by the kernel when initializing
the NFS support for each file system.
- Implement an interface for VFS (called VFS hooks) so that several kernel
subsystems can run arbitrary code upon receipt of specific VFS events.
At the moment, this only provides support for unmount and is used to
destroy NFS exports lists from the file systems being unmounted, though it
has room for extension.
Thanks go to yamt@, chs@, thorpej@, wrstuden@ and others for their comments
and advice in the development of this patch.
2005-09-23 16:10:31 +04:00
|
|
|
.Pp
|
2007-04-16 18:47:19 +04:00
|
|
|
The parameter
|
|
|
|
.Fa fh_size
|
|
|
|
points to the container size for the file handle.
|
|
|
|
This parameter should be updated to the size of the finished file handle.
|
|
|
|
Note that it is legal to call this function with
|
|
|
|
.Fa fhp
|
|
|
|
set to
|
|
|
|
.Dv NULL
|
|
|
|
in case
|
|
|
|
.Fa fh_size
|
|
|
|
is zero.
|
|
|
|
In case
|
|
|
|
.Fa fh_size
|
|
|
|
indicates a storage space too small, the storage space required for
|
|
|
|
the file handle corresponding to
|
|
|
|
.Fa vp
|
|
|
|
should be filled in and
|
|
|
|
.Er E2BIG
|
|
|
|
should be returned.
|
|
|
|
.Pp
|
|
|
|
If file handles are not supported by the file system, this function
|
|
|
|
must return
|
|
|
|
.Er EOPNOTSUPP .
|
2004-05-25 18:54:55 +04:00
|
|
|
.It Fn VFS_SNAPSHOT "mp" "vp" "ts"
|
|
|
|
Take a snapshot of the file system specified by the mount structure
|
|
|
|
.Fa mp
|
|
|
|
and make it accessible through the locked vnode
|
|
|
|
.Fa vp .
|
|
|
|
If
|
|
|
|
.Fa ts
|
|
|
|
is not
|
|
|
|
.Dv NULL
|
|
|
|
it will receive the time this snapshot was taken.
|
|
|
|
If the file system does not support this function, it should return
|
|
|
|
.Er EOPNOTSUPP .
|
2007-01-21 18:42:36 +03:00
|
|
|
.It Fn VFS_SUSPENDCTL "mp" "cmd"
|
|
|
|
Suspend or resume all operations on this file system.
|
|
|
|
.Fa cmd
|
|
|
|
is either
|
|
|
|
.Dv SUSPEND_SUSPEND
|
|
|
|
to suspend or
|
|
|
|
.Dv SUSPEND_RESUME
|
|
|
|
to resume operations.
|
|
|
|
If the file system does not support this function, it should return
|
|
|
|
.Er EOPNOTSUPP .
|
2001-10-22 07:33:19 +04:00
|
|
|
.El
|
|
|
|
.Sh CODE REFERENCES
|
|
|
|
This section describes places within the
|
|
|
|
.Nx
|
2003-02-05 01:38:15 +03:00
|
|
|
source tree where actual code implementing or using the vfs
|
2002-10-14 17:43:14 +04:00
|
|
|
operations can be found.
|
|
|
|
All pathnames are relative to
|
2001-10-22 12:21:32 +04:00
|
|
|
.Pa /usr/src .
|
2001-10-22 07:33:19 +04:00
|
|
|
.Pp
|
|
|
|
The vfs operations are implemented within the files
|
|
|
|
.Pa sys/kern/vfs_subr.c
|
|
|
|
and
|
|
|
|
.Pa sys/kern/vfs_init.c .
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr intro 9 ,
|
|
|
|
.Xr namei 9 ,
|
|
|
|
.Xr vfs 9 ,
|
2003-04-06 11:09:47 +04:00
|
|
|
.Xr vfssubr 9 ,
|
2002-08-15 07:23:55 +04:00
|
|
|
.Xr vnode 9 ,
|
2002-08-14 22:50:48 +04:00
|
|
|
.Xr vnodeops 9
|
2001-10-22 07:33:19 +04:00
|
|
|
.Sh HISTORY
|
|
|
|
The vfs operations vector, its functions and the corresponding macros
|
|
|
|
appeared in
|
2001-10-22 12:21:32 +04:00
|
|
|
.Bx 4.3 .
|