xref: /freebsd/share/man/man9/vfsconf.9 (revision 2e3f49888ec8851bafb22011533217487764fdb0)
1.\"
2.\" Copyright (C) 2001 Chad David <davidc@acns.ab.ca>. All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice(s), this list of conditions and the following disclaimer as
9.\"    the first lines of this file unmodified other than the possible
10.\"    addition of one or more copyright notices.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice(s), this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
16.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18.\" DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
19.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
25.\" DAMAGE.
26.\"
27.Dd June 16, 2013
28.Dt VFSCONF 9
29.Os
30.Sh NAME
31.Nm vfsconf
32.Nd "vfs configuration information"
33.Sh SYNOPSIS
34.In sys/param.h
35.In sys/mount.h
36.Ft int
37.Fn vfs_register "struct vfsconf *vfc"
38.Ft int
39.Fn vfs_unregister "struct vfsconf *vfc"
40.Ft int
41.Fn vfs_modevent "module_t mod" "int type" "void *data"
42.Sh DESCRIPTION
43Each file system type known to the kernel has a
44.Vt vfsconf
45structure that contains the
46information required to create a new mount of that file systems type.
47.Bd -literal
48struct vfsconf {
49	struct	vfsops *vfc_vfsops;	/* file system operations vector */
50	char	vfc_name[MFSNAMELEN];	/* file system type name */
51	int	vfc_typenum;		/* historic file system type number */
52	int	vfc_refcount;		/* number mounted of this type */
53	int	vfc_flags;		/* permanent flags */
54	struct	vfsconf *vfc_next;	/* next in list */
55};
56.Ed
57.Pp
58When a new file system is mounted,
59.Xr mount 2
60does a lookup of the
61.Vt vfsconf
62structure by its name, and if it is not already registered,
63attempts to load a kernel module for it.
64The file system operations for the new mount point are taken from
65.Va vfc_vfsops ,
66and
67.Va mnt_vfc
68in the
69.Vt mount
70structure is made to point directly at the
71.Vt vfsconf
72structure for the
73file system type.
74The file system type number is taken from
75.Va vfc_typenum
76which was assigned in
77.Fn vfs_register ,
78and the mount flags are taken from a mask of
79.Va vfc_flags .
80Each time a file system of a given type is mounted,
81.Va vfc_refcount
82is incremented.
83.Pp
84.Fn vfs_register
85takes a new
86.Vt vfsconf
87structure and adds it to the list of existing file systems.
88If the type has not already been registered, it is initialized by calling the
89.Fn vfs_init
90function in the file system operations vector.
91.Fn vfs_register
92also updates the oid's of any sysctl nodes for this file system type
93to be the same as the newly assigned type number.
94.Pp
95.Fn vfs_unregister
96unlinks
97.Fa vfc
98from the list of registered file system types if there are currently no mounted instances.
99If the
100.Fn vfs_uninit
101function in the file systems initialization vector is defined, it is called.
102.Pp
103.Fn vfs_modevent
104is registered by
105.Fn VFS_SET
106to handle the loading and unloading of file system kernel modules.
107In the case of
108.Dv MOD_LOAD ,
109.Fn vfs_register
110is called.
111In the case of
112.Dv MOD_UNLOAD ,
113.Fn vfs_unregister
114is called.
115.Sh RETURN VALUES
116.Fn vfs_register
117returns 0 if successful; otherwise,
118.Er EEXIST
119is returned indicating that the file system type has already been registered.
120.Pp
121.Fn vfs_unregister
122returns 0 if successful.
123If no
124.Vt vfsconf
125entry can be found matching the name in
126.Fa vfc ,
127.Er EINVAL
128is returned.
129If the reference count of mounted instances of the file system type is not zero,
130.Er EBUSY
131is returned.
132If
133.Fn vfs_uninit
134is called, any errors it returns will be returned by
135.Fn vfs_unregister .
136.Pp
137.Fn vfs_modevent
138returns the result of the call to
139.Fn vfs_register
140or
141.Fn vfs_unregister ,
142whatever the case.
143.Sh SEE ALSO
144.Xr mount 2 ,
145.Xr vfs_rootmountalloc 9 ,
146.Xr VFS_SET 9
147.Sh AUTHORS
148This manual page was written by
149.An Chad David Aq Mt davidc@acns.ab.ca .
150