| @@ -1,237 +1,241 @@ | | | @@ -1,237 +1,241 @@ |
1 | .\" $NetBSD: vfssubr.9,v 1.21 2014/02/22 10:05:54 hannken Exp $ | | 1 | .\" $NetBSD: vfssubr.9,v 1.22 2014/02/22 11:08:05 wiz Exp $ |
2 | .\" | | 2 | .\" |
3 | .\" Copyright (c) 2003, 2005, 2006 The NetBSD Foundation, Inc. | | 3 | .\" Copyright (c) 2003, 2005, 2006 The NetBSD Foundation, Inc. |
4 | .\" All rights reserved. | | 4 | .\" All rights reserved. |
5 | .\" | | 5 | .\" |
6 | .\" This code is derived from software contributed to The NetBSD Foundation | | 6 | .\" This code is derived from software contributed to The NetBSD Foundation |
7 | .\" by Gregory McGarry. | | 7 | .\" by Gregory McGarry. |
8 | .\" | | 8 | .\" |
9 | .\" Redistribution and use in source and binary forms, with or without | | 9 | .\" Redistribution and use in source and binary forms, with or without |
10 | .\" modification, are permitted provided that the following conditions | | 10 | .\" modification, are permitted provided that the following conditions |
11 | .\" are met: | | 11 | .\" are met: |
12 | .\" 1. Redistributions of source code must retain the above copyright | | 12 | .\" 1. Redistributions of source code must retain the above copyright |
13 | .\" notice, this list of conditions and the following disclaimer. | | 13 | .\" notice, this list of conditions and the following disclaimer. |
14 | .\" 2. Redistributions in binary form must reproduce the above copyright | | 14 | .\" 2. Redistributions in binary form must reproduce the above copyright |
15 | .\" notice, this list of conditions and the following disclaimer in the | | 15 | .\" notice, this list of conditions and the following disclaimer in the |
16 | .\" documentation and/or other materials provided with the distribution. | | 16 | .\" documentation and/or other materials provided with the distribution. |
17 | .\" | | 17 | .\" |
18 | .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | | 18 | .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
19 | .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 19 | .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
20 | .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 20 | .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
21 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 21 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
22 | .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 22 | .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
23 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 23 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
24 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 24 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
25 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 25 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
26 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 26 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
27 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 27 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
28 | .\" POSSIBILITY OF SUCH DAMAGE. | | 28 | .\" POSSIBILITY OF SUCH DAMAGE. |
29 | .\" | | 29 | .\" |
30 | .Dd February 22, 2014 | | 30 | .Dd February 22, 2014 |
31 | .Dt VFSSUBR 9 | | 31 | .Dt VFSSUBR 9 |
32 | .Os | | 32 | .Os |
33 | .Sh NAME | | 33 | .Sh NAME |
34 | .Nm vfssubr , | | 34 | .Nm vfssubr , |
35 | .Nm vfs_getnewfsid , | | 35 | .Nm vfs_getnewfsid , |
36 | .Nm vfs_getvfs , | | 36 | .Nm vfs_getvfs , |
37 | .Nm vfs_export , | | 37 | .Nm vfs_export , |
38 | .Nm vfs_showexport , | | 38 | .Nm vfs_showexport , |
39 | .Nm vfs_export_lookup , | | 39 | .Nm vfs_export_lookup , |
40 | .Nm vfs_setpublicfs , | | 40 | .Nm vfs_setpublicfs , |
41 | .Nm vfs_mountedon , | | 41 | .Nm vfs_mountedon , |
42 | .Nm vfs_mountroot , | | 42 | .Nm vfs_mountroot , |
43 | .Nm vfs_unmountall , | | 43 | .Nm vfs_unmountall , |
44 | .Nm vfs_busy , | | 44 | .Nm vfs_busy , |
45 | .Nm vfs_unbusy , | | 45 | .Nm vfs_unbusy , |
46 | .Nm vfs_mountalloc , | | 46 | .Nm vfs_mountalloc , |
47 | .Nm vfs_rootmountalloc , | | 47 | .Nm vfs_rootmountalloc , |
48 | .Nm vfs_shutdown , | | 48 | .Nm vfs_shutdown , |
49 | .Nm vfs_attach , | | 49 | .Nm vfs_attach , |
50 | .Nm vfs_detach , | | 50 | .Nm vfs_detach , |
51 | .Nm vfs_reinit , | | 51 | .Nm vfs_reinit , |
52 | .Nm vfs_getopsbyname , | | 52 | .Nm vfs_getopsbyname , |
53 | .Nm vfs_suspend , | | 53 | .Nm vfs_suspend , |
54 | .Nm vfs_resume | | 54 | .Nm vfs_resume |
55 | .Nd high-level interface to kernel file system interface | | 55 | .Nd high-level interface to kernel file system interface |
56 | .Sh SYNOPSIS | | 56 | .Sh SYNOPSIS |
57 | .In sys/param.h | | 57 | .In sys/param.h |
58 | .In sys/mount.h | | 58 | .In sys/mount.h |
59 | .In sys/vnode.h | | 59 | .In sys/vnode.h |
60 | .Ft void | | 60 | .Ft void |
61 | .Fn vfs_getnewfsid "struct mount *mp" | | 61 | .Fn vfs_getnewfsid "struct mount *mp" |
62 | .Ft struct mount * | | 62 | .Ft struct mount * |
63 | .Fn vfs_getvfs "fsid_t *fsid" | | 63 | .Fn vfs_getvfs "fsid_t *fsid" |
64 | .Ft int | | 64 | .Ft int |
65 | .Fn vfs_export_lookup "struct mount *mp" "struct netexport *nep" \ | | 65 | .Fn vfs_export_lookup "struct mount *mp" "struct netexport *nep" \ |
66 | "struct export_args *argp" | | 66 | "struct export_args *argp" |
67 | .Ft int | | 67 | .Ft int |
68 | .Fn vfs_setpublicfs "struct mount *mp" "struct netexport *nep" \ | | 68 | .Fn vfs_setpublicfs "struct mount *mp" "struct netexport *nep" \ |
69 | "struct export_args *argp" | | 69 | "struct export_args *argp" |
70 | .Ft int | | 70 | .Ft int |
71 | .Fn vfs_mountedon "struct vnode *vp" | | 71 | .Fn vfs_mountedon "struct vnode *vp" |
72 | .Ft int | | 72 | .Ft int |
73 | .Fn vfs_mountroot "void" | | 73 | .Fn vfs_mountroot "void" |
74 | .Ft void | | 74 | .Ft void |
75 | .Fn vfs_unmountall "struct lwp *l" | | 75 | .Fn vfs_unmountall "struct lwp *l" |
76 | .Ft int | | 76 | .Ft int |
77 | .Fn vfs_busy "struct mount *mp" "struct mount **nextp" | | 77 | .Fn vfs_busy "struct mount *mp" "struct mount **nextp" |
78 | .Ft void | | 78 | .Ft void |
79 | .Fn vfs_unbusy "struct mount *mp" "bool keepref" "struct mount **nextp" | | 79 | .Fn vfs_unbusy "struct mount *mp" "bool keepref" "struct mount **nextp" |
80 | .Ft struct mount * | | 80 | .Ft struct mount * |
81 | .Fn vfs_mountalloc "struct vfsops *vfs" "struct vnode *vp" | | 81 | .Fn vfs_mountalloc "struct vfsops *vfs" "struct vnode *vp" |
82 | .Ft int | | 82 | .Ft int |
83 | .Fn vfs_rootmountalloc "char *fstypename" "char *devname" \ | | 83 | .Fn vfs_rootmountalloc "char *fstypename" "char *devname" \ |
84 | "struct mount **mpp" | | 84 | "struct mount **mpp" |
85 | .Ft void | | 85 | .Ft void |
86 | .Fn vfs_shutdown "void" | | 86 | .Fn vfs_shutdown "void" |
87 | .Ft int | | 87 | .Ft int |
88 | .Fn vfs_attach "struct vfsops *vfs" | | 88 | .Fn vfs_attach "struct vfsops *vfs" |
89 | .Ft int | | 89 | .Ft int |
90 | .Fn vfs_detach "struct vfsops *vfs" | | 90 | .Fn vfs_detach "struct vfsops *vfs" |
91 | .Ft void | | 91 | .Ft void |
92 | .Fn vfs_reinit "void" | | 92 | .Fn vfs_reinit "void" |
93 | .Ft struct vfsops * | | 93 | .Ft struct vfsops * |
94 | .Fn vfs_getopsbyname "const char *name" | | 94 | .Fn vfs_getopsbyname "const char *name" |
95 | .Ft int | | 95 | .Ft int |
96 | .Fn vfs_suspend "struct mount *mp" "int nowait" | | 96 | .Fn vfs_suspend "struct mount *mp" "int nowait" |
97 | .Ft void | | 97 | .Ft void |
98 | .Fn vfs_resume "struct mount *mp" | | 98 | .Fn vfs_resume "struct mount *mp" |
99 | .Sh DESCRIPTION | | 99 | .Sh DESCRIPTION |
100 | The high-level functions described in this page are the interface to | | 100 | The high-level functions described in this page are the interface to |
101 | the kernel file system interface (VFS). | | 101 | the kernel file system interface (VFS). |
102 | .Sh FUNCTIONS | | 102 | .Sh FUNCTIONS |
103 | .Bl -tag -width compact | | 103 | .Bl -tag -width compact |
104 | .It Fn vfs_getnewfsid "mp" | | 104 | .It Fn vfs_getnewfsid "mp" |
105 | Get a new unique file system id type for the file system specified by | | 105 | Get a new unique file system id type for the file system specified by |
106 | the mount structure | | 106 | the mount structure |
107 | .Fa mp . | | 107 | .Fa mp . |
108 | The file system id type is stored in | | 108 | The file system id type is stored in |
109 | .Em mp-\*[Gt]mnt_stat.f_fsidx . | | 109 | .Em mp-\*[Gt]mnt_stat.f_fsidx . |
110 | .It Fn vfs_getvfs "fsid" | | 110 | .It Fn vfs_getvfs "fsid" |
111 | Lookup a mount point with the file system identifier | | 111 | Lookup a mount point with the file system identifier |
112 | .Fa fsid . | | 112 | .Fa fsid . |
113 | .It Fn vfs_export_lookup "mp" "nep" "argp" | | 113 | .It Fn vfs_export_lookup "mp" "nep" "argp" |
114 | Check client permission on the exportable file system specified by the | | 114 | Check client permission on the exportable file system specified by the |
115 | mount structure | | 115 | mount structure |
116 | .Fa mp . | | 116 | .Fa mp . |
117 | The argument | | 117 | The argument |
118 | .Fa nam | | 118 | .Fa nam |
119 | is the address of the networked client. | | 119 | is the address of the networked client. |
120 | This function is used by file system type specific functions to verify | | 120 | This function is used by file system type specific functions to verify |
121 | that the client can access the file system. | | 121 | that the client can access the file system. |
122 | .It Fn vfs_setpublicfs "mp" "nep" "argp" | | 122 | .It Fn vfs_setpublicfs "mp" "nep" "argp" |
123 | Set the publicly exported file system specified by the mount structure | | 123 | Set the publicly exported file system specified by the mount structure |
124 | .Fa mp . | | 124 | .Fa mp . |
125 | .It Fn vfs_mountedon "vp" | | 125 | .It Fn vfs_mountedon "vp" |
126 | Check to see if a file system is mounted on a block device specified | | 126 | Check to see if a file system is mounted on a block device specified |
127 | by the vnode | | 127 | by the vnode |
128 | .Fa vp . | | 128 | .Fa vp . |
129 | .It Fn vfs_mountroot "void" | | 129 | .It Fn vfs_mountroot "void" |
130 | Mount the root file system. | | 130 | Mount the root file system. |
131 | .It Fn vfs_unmountall "l" | | 131 | .It Fn vfs_unmountall "l" |
132 | Unmount all file systems. | | 132 | Unmount all file systems. |
133 | .It Fn vfs_busy "mp" "nextp" | | 133 | .It Fn vfs_busy "mp" "nextp" |
134 | Mark the mount point specified by | | 134 | Mark the mount point specified by |
135 | .Fa mp | | 135 | .Fa mp |
136 | as busy and get a reference to it. | | 136 | as busy and get a reference to it. |
137 | This function is used to synchronize access and to delay unmounting. | | 137 | This function is used to synchronize access and to delay unmounting. |
138 | The caller must hold a pre-existing reference to the mount. | | 138 | The caller must hold a pre-existing reference to the mount. |
139 | If | | 139 | If |
140 | .Fa nextp | | 140 | .Fa nextp |
141 | is not NULL, the caller must hold the | | 141 | is not |
| | | 142 | .Dv NULL , |
| | | 143 | the caller must hold the |
142 | .Em mountlist_lock | | 144 | .Em mountlist_lock |
143 | and | | 145 | and |
144 | .Fa nextp | | 146 | .Fa nextp |
145 | will receive the next mount from mount list on error. | | 147 | will receive the next mount from mount list on error. |
146 | The | | 148 | The |
147 | .Em mountlist_lock | | 149 | .Em mountlist_lock |
148 | is released on return. | | 150 | is released on return. |
149 | .It Fn vfs_unbusy "mp" "keepref" "nextp" | | 151 | .It Fn vfs_unbusy "mp" "keepref" "nextp" |
150 | Undo a | | 152 | Undo a |
151 | .Fn vfs_busy | | 153 | .Fn vfs_busy |
152 | on the mount point specified by | | 154 | on the mount point specified by |
153 | .Fa mp . | | 155 | .Fa mp . |
154 | If | | 156 | If |
155 | .Fa keepref | | 157 | .Fa keepref |
156 | is true, preserve the reference added by | | 158 | is true, preserve the reference added by |
157 | .Fn vfs_busy . | | 159 | .Fn vfs_busy . |
158 | If | | 160 | If |
159 | .Fa nextp | | 161 | .Fa nextp |
160 | is not NULL, the | | 162 | is not |
| | | 163 | .Dv NULL , |
| | | 164 | the |
161 | .Em mountlist_lock | | 165 | .Em mountlist_lock |
162 | will be aquired and | | 166 | will be aquired and |
163 | .Fa nextp | | 167 | .Fa nextp |
164 | will receive the next mount from mount list. | | 168 | will receive the next mount from mount list. |
165 | .It Fn vfs_mountalloc "vfsops" "vp" | | 169 | .It Fn vfs_mountalloc "vfsops" "vp" |
166 | Allocate and initialise a mount structure, setting | | 170 | Allocate and initialise a mount structure, setting |
167 | .Em mnt_vnodecovered | | 171 | .Em mnt_vnodecovered |
168 | to | | 172 | to |
169 | .Fa vp | | 173 | .Fa vp |
170 | and | | 174 | and |
171 | .Em mnt_op | | 175 | .Em mnt_op |
172 | to | | 176 | to |
173 | .Fa vfsops . | | 177 | .Fa vfsops . |
174 | On success, mark the mount structure as busy and return its address. | | 178 | On success, mark the mount structure as busy and return its address. |
175 | Otherwise, return | | 179 | Otherwise, return |
176 | .Dv NULL . | | 180 | .Dv NULL . |
177 | .It Fn vfs_rootmountalloc "fstypename" "devname" "mpp" | | 181 | .It Fn vfs_rootmountalloc "fstypename" "devname" "mpp" |
178 | Lookup a file system type specified by the name | | 182 | Lookup a file system type specified by the name |
179 | .Fa fstypename | | 183 | .Fa fstypename |
180 | and if found allocate and initialise a mount structure for it. | | 184 | and if found allocate and initialise a mount structure for it. |
181 | The allocated mount structure is returned in the address specified by | | 185 | The allocated mount structure is returned in the address specified by |
182 | .Fa mpp . | | 186 | .Fa mpp . |
183 | The device the root file system was mounted from is specified by the | | 187 | The device the root file system was mounted from is specified by the |
184 | argument | | 188 | argument |
185 | .Fa devname | | 189 | .Fa devname |
186 | and is recorded in the new mount structure. | | 190 | and is recorded in the new mount structure. |
187 | .It Fn vfs_shutdown | | 191 | .It Fn vfs_shutdown |
188 | Sync and unmount all file systems before shutting down. | | 192 | Sync and unmount all file systems before shutting down. |
189 | Invoked by | | 193 | Invoked by |
190 | .Xr cpu_reboot 9 . | | 194 | .Xr cpu_reboot 9 . |
191 | .It Fn vfs_attach "vfs" | | 195 | .It Fn vfs_attach "vfs" |
192 | Establish file system | | 196 | Establish file system |
193 | .Fa vfs | | 197 | .Fa vfs |
194 | and initialise it. | | 198 | and initialise it. |
195 | .It Fn vfs_detach "vfs" | | 199 | .It Fn vfs_detach "vfs" |
196 | Remove file system | | 200 | Remove file system |
197 | .Fa vfs | | 201 | .Fa vfs |
198 | from the kernel. | | 202 | from the kernel. |
199 | .It Fn vfs_reinit "void" | | 203 | .It Fn vfs_reinit "void" |
200 | Reinitialises all file systems within the kernel through file | | 204 | Reinitialises all file systems within the kernel through file |
201 | system-specific vfs operation (see | | 205 | system-specific vfs operation (see |
202 | .Xr vfsops 9 ) . | | 206 | .Xr vfsops 9 ) . |
203 | .It Fn vfs_getopsbyname "name" | | 207 | .It Fn vfs_getopsbyname "name" |
204 | Given a file system name specified by | | 208 | Given a file system name specified by |
205 | .Fa name , | | 209 | .Fa name , |
206 | look up the vfs operations for that file system (see | | 210 | look up the vfs operations for that file system (see |
207 | .Xr vfsops 9 ) , | | 211 | .Xr vfsops 9 ) , |
208 | or return | | 212 | or return |
209 | .Dv NULL | | 213 | .Dv NULL |
210 | if file system isn't present in the kernel. | | 214 | if file system isn't present in the kernel. |
211 | .It Fn vfs_suspend "mp" "nowait" | | 215 | .It Fn vfs_suspend "mp" "nowait" |
212 | Request a mounted file system to suspend all operations. | | 216 | Request a mounted file system to suspend all operations. |
213 | All new operations to the file system are stopped. | | 217 | All new operations to the file system are stopped. |
214 | After all operations in progress have completed, the | | 218 | After all operations in progress have completed, the |
215 | file system is synced to disk and the function returns. | | 219 | file system is synced to disk and the function returns. |
216 | If a file system suspension is currently in progress and | | 220 | If a file system suspension is currently in progress and |
217 | .Fa nowait | | 221 | .Fa nowait |
218 | is set | | 222 | is set |
219 | .Er EWOULDBLOCK | | 223 | .Er EWOULDBLOCK |
220 | is returned. | | 224 | is returned. |
221 | If the operation is successful, zero is returned, otherwise an | | 225 | If the operation is successful, zero is returned, otherwise an |
222 | appropriate error code is returned. | | 226 | appropriate error code is returned. |
223 | .It Fn vfs_resume "mp" | | 227 | .It Fn vfs_resume "mp" |
224 | Request a mounted file system to resume operations. | | 228 | Request a mounted file system to resume operations. |
225 | .El | | 229 | .El |
226 | .Sh CODE REFERENCES | | 230 | .Sh CODE REFERENCES |
227 | The vfs interface functions are implemented within the files | | 231 | The vfs interface functions are implemented within the files |
228 | .Pa sys/kern/vfs_subr.c | | 232 | .Pa sys/kern/vfs_subr.c |
229 | and | | 233 | and |
230 | .Pa sys/kern/vfs_init.c . | | 234 | .Pa sys/kern/vfs_init.c . |
231 | .Sh SEE ALSO | | 235 | .Sh SEE ALSO |
232 | .Xr intro 9 , | | 236 | .Xr intro 9 , |
233 | .Xr namei 9 , | | 237 | .Xr namei 9 , |
234 | .Xr vfs 9 , | | 238 | .Xr vfs 9 , |
235 | .Xr vfsops 9 , | | 239 | .Xr vfsops 9 , |
236 | .Xr vnode 9 , | | 240 | .Xr vnode 9 , |
237 | .Xr vnodeops 9 | | 241 | .Xr vnodeops 9 |