]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
5ba3f43e | 2 | * Copyright (c) 2000-2017 Apple Inc. All rights reserved. |
5d5c5d0d | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
2d21ac55 A |
6 | * This file contains Original Code and/or Modifications of Original Code |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
8f6c56a5 | 14 | * |
2d21ac55 A |
15 | * Please obtain a copy of the License at |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
18 | * The Original Code and all software distributed under the License are | |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
23 | * Please see the License for the specific language governing rights and | |
24 | * limitations under the License. | |
8f6c56a5 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
1c79356b A |
27 | */ |
28 | /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ | |
29 | /* | |
30 | * Copyright (c) 1989, 1991, 1993 | |
31 | * The Regents of the University of California. All rights reserved. | |
32 | * | |
33 | * Redistribution and use in source and binary forms, with or without | |
34 | * modification, are permitted provided that the following conditions | |
35 | * are met: | |
36 | * 1. Redistributions of source code must retain the above copyright | |
37 | * notice, this list of conditions and the following disclaimer. | |
38 | * 2. Redistributions in binary form must reproduce the above copyright | |
39 | * notice, this list of conditions and the following disclaimer in the | |
40 | * documentation and/or other materials provided with the distribution. | |
41 | * 3. All advertising materials mentioning features or use of this software | |
42 | * must display the following acknowledgement: | |
43 | * This product includes software developed by the University of | |
44 | * California, Berkeley and its contributors. | |
45 | * 4. Neither the name of the University nor the names of its contributors | |
46 | * may be used to endorse or promote products derived from this software | |
47 | * without specific prior written permission. | |
48 | * | |
49 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
50 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
51 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
52 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
53 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
54 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
55 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
56 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
57 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
58 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
59 | * SUCH DAMAGE. | |
60 | * | |
61 | * @(#)mount.h 8.21 (Berkeley) 5/20/95 | |
62 | */ | |
2d21ac55 A |
63 | /* |
64 | * NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce | |
65 | * support for mandatory and extensible security protections. This notice | |
66 | * is included in support of clause 2.2 (b) of the Apple Public License, | |
67 | * Version 2.0. | |
68 | */ | |
69 | ||
1c79356b A |
70 | |
71 | #ifndef _SYS_MOUNT_H_ | |
72 | #define _SYS_MOUNT_H_ | |
73 | ||
9bccf70c | 74 | #include <sys/appleapiopts.h> |
91447636 A |
75 | #include <sys/cdefs.h> |
76 | #include <sys/attr.h> /* needed for vol_capabilities_attr_t */ | |
77 | ||
1c79356b | 78 | #ifndef KERNEL |
91447636 | 79 | #include <stdint.h> |
1c79356b | 80 | #include <sys/ucred.h> |
91447636 | 81 | #include <sys/queue.h> /* XXX needed for user builds */ |
593a1d5f | 82 | #include <Availability.h> |
91447636 A |
83 | #else |
84 | #include <sys/kernel_types.h> | |
b0d623f7 | 85 | #include <uuid/uuid.h> |
1c79356b | 86 | #endif |
1c79356b | 87 | |
fe8ab488 | 88 | #include <sys/_types/_fsid_t.h> /* file system id type */ |
1c79356b | 89 | |
1c79356b A |
90 | /* |
91 | * file system statistics | |
92 | */ | |
93 | ||
94 | #define MFSNAMELEN 15 /* length of fs type name, not inc. null */ | |
2d21ac55 | 95 | #define MFSTYPENAMELEN 16 /* length of fs type name including null */ |
b0d623f7 A |
96 | |
97 | #if __DARWIN_64_BIT_INO_T | |
98 | #define MNAMELEN MAXPATHLEN /* length of buffer for returned name */ | |
99 | #else /* ! __DARWIN_64_BIT_INO_T */ | |
100 | #define MNAMELEN 90 /* length of buffer for returned name */ | |
101 | #endif /* __DARWIN_64_BIT_INO_T */ | |
1c79356b | 102 | |
2d21ac55 A |
103 | #define __DARWIN_STRUCT_STATFS64 { \ |
104 | uint32_t f_bsize; /* fundamental file system block size */ \ | |
105 | int32_t f_iosize; /* optimal transfer block size */ \ | |
106 | uint64_t f_blocks; /* total data blocks in file system */ \ | |
107 | uint64_t f_bfree; /* free blocks in fs */ \ | |
108 | uint64_t f_bavail; /* free blocks avail to non-superuser */ \ | |
109 | uint64_t f_files; /* total file nodes in file system */ \ | |
110 | uint64_t f_ffree; /* free file nodes in fs */ \ | |
111 | fsid_t f_fsid; /* file system id */ \ | |
112 | uid_t f_owner; /* user that mounted the filesystem */ \ | |
113 | uint32_t f_type; /* type of filesystem */ \ | |
114 | uint32_t f_flags; /* copy of mount exported flags */ \ | |
115 | uint32_t f_fssubtype; /* fs sub-type (flavor) */ \ | |
116 | char f_fstypename[MFSTYPENAMELEN]; /* fs type name */ \ | |
117 | char f_mntonname[MAXPATHLEN]; /* directory on which mounted */ \ | |
118 | char f_mntfromname[MAXPATHLEN]; /* mounted filesystem */ \ | |
119 | uint32_t f_reserved[8]; /* For future use */ \ | |
120 | } | |
121 | ||
593a1d5f A |
122 | #if !__DARWIN_ONLY_64_BIT_INO_T |
123 | ||
2d21ac55 A |
124 | struct statfs64 __DARWIN_STRUCT_STATFS64; |
125 | ||
593a1d5f A |
126 | #endif /* !__DARWIN_ONLY_64_BIT_INO_T */ |
127 | ||
2d21ac55 A |
128 | #if __DARWIN_64_BIT_INO_T |
129 | ||
130 | struct statfs __DARWIN_STRUCT_STATFS64; | |
131 | ||
132 | #else /* !__DARWIN_64_BIT_INO_T */ | |
133 | ||
91447636 A |
134 | /* |
135 | * LP64 - WARNING - must be kept in sync with struct user_statfs in mount_internal.h. | |
136 | */ | |
1c79356b A |
137 | struct statfs { |
138 | short f_otype; /* TEMPORARY SHADOW COPY OF f_type */ | |
139 | short f_oflags; /* TEMPORARY SHADOW COPY OF f_flags */ | |
140 | long f_bsize; /* fundamental file system block size */ | |
141 | long f_iosize; /* optimal transfer block size */ | |
142 | long f_blocks; /* total data blocks in file system */ | |
143 | long f_bfree; /* free blocks in fs */ | |
144 | long f_bavail; /* free blocks avail to non-superuser */ | |
145 | long f_files; /* total file nodes in file system */ | |
146 | long f_ffree; /* free file nodes in fs */ | |
147 | fsid_t f_fsid; /* file system id */ | |
148 | uid_t f_owner; /* user that mounted the filesystem */ | |
149 | short f_reserved1; /* spare for later */ | |
150 | short f_type; /* type of filesystem */ | |
2d21ac55 | 151 | long f_flags; /* copy of mount exported flags */ |
1c79356b A |
152 | long f_reserved2[2]; /* reserved for future use */ |
153 | char f_fstypename[MFSNAMELEN]; /* fs type name */ | |
154 | char f_mntonname[MNAMELEN]; /* directory on which mounted */ | |
155 | char f_mntfromname[MNAMELEN];/* mounted filesystem */ | |
1c79356b A |
156 | char f_reserved3; /* For alignment */ |
157 | long f_reserved4[4]; /* For future use */ | |
1c79356b A |
158 | }; |
159 | ||
2d21ac55 | 160 | #endif /* __DARWIN_64_BIT_INO_T */ |
91447636 | 161 | |
0c530ab8 | 162 | #pragma pack(4) |
91447636 A |
163 | |
164 | struct vfsstatfs { | |
165 | uint32_t f_bsize; /* fundamental file system block size */ | |
166 | size_t f_iosize; /* optimal transfer block size */ | |
167 | uint64_t f_blocks; /* total data blocks in file system */ | |
168 | uint64_t f_bfree; /* free blocks in fs */ | |
169 | uint64_t f_bavail; /* free blocks avail to non-superuser */ | |
170 | uint64_t f_bused; /* free blocks avail to non-superuser */ | |
171 | uint64_t f_files; /* total file nodes in file system */ | |
172 | uint64_t f_ffree; /* free file nodes in fs */ | |
173 | fsid_t f_fsid; /* file system id */ | |
174 | uid_t f_owner; /* user that mounted the filesystem */ | |
175 | uint64_t f_flags; /* copy of mount exported flags */ | |
176 | char f_fstypename[MFSTYPENAMELEN];/* fs type name inclus */ | |
177 | char f_mntonname[MAXPATHLEN];/* directory on which mounted */ | |
178 | char f_mntfromname[MAXPATHLEN];/* mounted filesystem */ | |
179 | uint32_t f_fssubtype; /* fs sub-type (flavor) */ | |
180 | void *f_reserved[2]; /* For future use == 0 */ | |
181 | }; | |
182 | ||
0c530ab8 | 183 | #pragma pack() |
91447636 | 184 | |
2d21ac55 A |
185 | #ifdef KERNEL |
186 | /* | |
187 | * Kernel level support for the VFS_GETATTR(), VFS_SETATTR() for use in | |
188 | * implementation of filesystem KEXTs, and by the vfs_getattr() and | |
189 | * vfs_setattr() KPIs. | |
190 | */ | |
191 | ||
91447636 A |
192 | #define VFSATTR_INIT(s) ((s)->f_supported = (s)->f_active = 0LL) |
193 | #define VFSATTR_SET_SUPPORTED(s, a) ((s)->f_supported |= VFSATTR_ ## a) | |
194 | #define VFSATTR_IS_SUPPORTED(s, a) ((s)->f_supported & VFSATTR_ ## a) | |
195 | #define VFSATTR_CLEAR_ACTIVE(s, a) ((s)->f_active &= ~VFSATTR_ ## a) | |
196 | #define VFSATTR_IS_ACTIVE(s, a) ((s)->f_active & VFSATTR_ ## a) | |
197 | #define VFSATTR_ALL_SUPPORTED(s) (((s)->f_active & (s)->f_supported) == (s)->f_active) | |
198 | #define VFSATTR_WANTED(s, a) ((s)->f_active |= VFSATTR_ ## a) | |
199 | #define VFSATTR_RETURN(s, a, x) do { (s)-> a = (x); VFSATTR_SET_SUPPORTED(s, a);} while(0) | |
200 | ||
201 | #define VFSATTR_f_objcount (1LL<< 0) | |
202 | #define VFSATTR_f_filecount (1LL<< 1) | |
203 | #define VFSATTR_f_dircount (1LL<< 2) | |
204 | #define VFSATTR_f_maxobjcount (1LL<< 3) | |
205 | #define VFSATTR_f_bsize (1LL<< 4) | |
206 | #define VFSATTR_f_iosize (1LL<< 5) | |
207 | #define VFSATTR_f_blocks (1LL<< 6) | |
208 | #define VFSATTR_f_bfree (1LL<< 7) | |
209 | #define VFSATTR_f_bavail (1LL<< 8) | |
210 | #define VFSATTR_f_bused (1LL<< 9) | |
211 | #define VFSATTR_f_files (1LL<< 10) | |
212 | #define VFSATTR_f_ffree (1LL<< 11) | |
213 | #define VFSATTR_f_fsid (1LL<< 12) | |
214 | #define VFSATTR_f_owner (1LL<< 13) | |
215 | #define VFSATTR_f_capabilities (1LL<< 14) | |
216 | #define VFSATTR_f_attributes (1LL<< 15) | |
217 | #define VFSATTR_f_create_time (1LL<< 16) | |
218 | #define VFSATTR_f_modify_time (1LL<< 17) | |
219 | #define VFSATTR_f_access_time (1LL<< 18) | |
220 | #define VFSATTR_f_backup_time (1LL<< 19) | |
221 | #define VFSATTR_f_fssubtype (1LL<< 20) | |
222 | #define VFSATTR_f_vol_name (1LL<< 21) | |
223 | #define VFSATTR_f_signature (1LL<< 22) | |
224 | #define VFSATTR_f_carbon_fsid (1LL<< 23) | |
b0d623f7 | 225 | #define VFSATTR_f_uuid (1LL<< 24) |
813fb2f6 A |
226 | #define VFSATTR_f_quota (1LL<< 25) |
227 | #define VFSATTR_f_reserved (1LL<< 26) | |
228 | ||
91447636 | 229 | |
1c79356b | 230 | /* |
2d21ac55 | 231 | * Argument structure. |
1c79356b | 232 | */ |
0c530ab8 | 233 | #pragma pack(4) |
b0d623f7 A |
234 | /* |
235 | * Note: the size of the vfs_attr structure can change. | |
236 | * A kext should only reference the fields that are | |
237 | * marked as active; it should not depend on the actual | |
238 | * size of the structure or attempt to copy it. | |
239 | */ | |
91447636 A |
240 | struct vfs_attr { |
241 | uint64_t f_supported; | |
242 | uint64_t f_active; | |
243 | ||
244 | uint64_t f_objcount; /* number of filesystem objects in volume */ | |
245 | uint64_t f_filecount; /* ... files */ | |
246 | uint64_t f_dircount; /* ... directories */ | |
247 | uint64_t f_maxobjcount; /* maximum number of filesystem objects */ | |
248 | ||
249 | uint32_t f_bsize; /* block size for the below size values */ | |
250 | size_t f_iosize; /* optimal transfer block size */ | |
251 | uint64_t f_blocks; /* total data blocks in file system */ | |
252 | uint64_t f_bfree; /* free blocks in fs */ | |
253 | uint64_t f_bavail; /* free blocks avail to non-superuser */ | |
254 | uint64_t f_bused; /* blocks in use */ | |
255 | uint64_t f_files; /* total file nodes in file system */ | |
256 | uint64_t f_ffree; /* free file nodes in fs */ | |
257 | fsid_t f_fsid; /* file system id */ | |
258 | uid_t f_owner; /* user that mounted the filesystem */ | |
259 | ||
260 | vol_capabilities_attr_t f_capabilities; | |
261 | vol_attributes_attr_t f_attributes; | |
262 | ||
263 | struct timespec f_create_time; /* creation time */ | |
264 | struct timespec f_modify_time; /* last modification time */ | |
265 | struct timespec f_access_time; /* time of last access */ | |
266 | struct timespec f_backup_time; /* last backup time */ | |
267 | ||
268 | uint32_t f_fssubtype; /* filesystem subtype */ | |
269 | ||
270 | char *f_vol_name; /* volume name */ | |
271 | ||
272 | uint16_t f_signature; /* used for ATTR_VOL_SIGNATURE, Carbon's FSVolumeInfo.signature */ | |
273 | uint16_t f_carbon_fsid; /* same as Carbon's FSVolumeInfo.filesystemID */ | |
b0d623f7 | 274 | uuid_t f_uuid; /* file system UUID (version 3 or 5), available in 10.6 and later */ |
813fb2f6 A |
275 | uint64_t f_quota; /* total quota data blocks in file system */ |
276 | uint64_t f_reserved; /* total reserved data blocks in file system */ | |
1c79356b | 277 | }; |
91447636 | 278 | |
0c530ab8 | 279 | #pragma pack() |
1c79356b | 280 | |
2d21ac55 A |
281 | #endif /* KERNEL */ |
282 | ||
1c79356b A |
283 | /* |
284 | * User specifiable flags. | |
285 | * | |
286 | * Unmount uses MNT_FORCE flag. | |
287 | */ | |
288 | #define MNT_RDONLY 0x00000001 /* read only filesystem */ | |
289 | #define MNT_SYNCHRONOUS 0x00000002 /* file system written synchronously */ | |
290 | #define MNT_NOEXEC 0x00000004 /* can't exec from filesystem */ | |
291 | #define MNT_NOSUID 0x00000008 /* don't honor setuid bits on fs */ | |
292 | #define MNT_NODEV 0x00000010 /* don't interpret special files */ | |
293 | #define MNT_UNION 0x00000020 /* union with underlying filesystem */ | |
294 | #define MNT_ASYNC 0x00000040 /* file system written asynchronously */ | |
d1ecb069 | 295 | #define MNT_CPROTECT 0x00000080 /* file system supports content protection */ |
1c79356b A |
296 | |
297 | /* | |
298 | * NFS export related mount flags. | |
299 | */ | |
1c79356b | 300 | #define MNT_EXPORTED 0x00000100 /* file system is exported */ |
1c79356b | 301 | |
2d21ac55 A |
302 | /* |
303 | * MAC labeled / "quarantined" flag | |
304 | */ | |
305 | #define MNT_QUARANTINE 0x00000400 /* file system is quarantined */ | |
306 | ||
1c79356b A |
307 | /* |
308 | * Flags set by internal operations. | |
309 | */ | |
310 | #define MNT_LOCAL 0x00001000 /* filesystem is stored locally */ | |
311 | #define MNT_QUOTA 0x00002000 /* quotas are enabled on filesystem */ | |
312 | #define MNT_ROOTFS 0x00004000 /* identifies the root filesystem */ | |
2d21ac55 A |
313 | #define MNT_DOVOLFS 0x00008000 /* FS supports volfs (deprecated flag in Mac OS X 10.5) */ |
314 | ||
315 | ||
316 | #define MNT_DONTBROWSE 0x00100000 /* file system is not appropriate path to user data */ | |
317 | #define MNT_IGNORE_OWNERSHIP 0x00200000 /* VFS will ignore ownership information on filesystem objects */ | |
318 | #define MNT_AUTOMOUNTED 0x00400000 /* filesystem was mounted by automounter */ | |
319 | #define MNT_JOURNALED 0x00800000 /* filesystem is journaled */ | |
320 | #define MNT_NOUSERXATTR 0x01000000 /* Don't allow user extended attributes */ | |
321 | #define MNT_DEFWRITE 0x02000000 /* filesystem should defer writes */ | |
322 | #define MNT_MULTILABEL 0x04000000 /* MAC support for individual labels */ | |
5ba3f43e A |
323 | #define MNT_NOATIME 0x10000000 /* disable update of file access time */ |
324 | #define MNT_SNAPSHOT 0x40000000 /* The mount is a snapshot */ | |
6d2010ae A |
325 | #ifdef BSD_KERNEL_PRIVATE |
326 | /* #define MNT_IMGSRC_BY_INDEX 0x20000000 see sys/imgsrc.h */ | |
327 | #endif /* BSD_KERNEL_PRIVATE */ | |
2d21ac55 A |
328 | |
329 | /* backwards compatibility only */ | |
330 | #define MNT_UNKNOWNPERMISSIONS MNT_IGNORE_OWNERSHIP | |
331 | ||
1c79356b A |
332 | |
333 | /* | |
334 | * XXX I think that this could now become (~(MNT_CMDFLAGS)) | |
335 | * but the 'mount' program may need changing to handle this. | |
336 | */ | |
337 | #define MNT_VISFLAGMASK (MNT_RDONLY | MNT_SYNCHRONOUS | MNT_NOEXEC | \ | |
338 | MNT_NOSUID | MNT_NODEV | MNT_UNION | \ | |
2d21ac55 A |
339 | MNT_ASYNC | MNT_EXPORTED | MNT_QUARANTINE | \ |
340 | MNT_LOCAL | MNT_QUOTA | \ | |
1c79356b | 341 | MNT_ROOTFS | MNT_DOVOLFS | MNT_DONTBROWSE | \ |
2d21ac55 | 342 | MNT_IGNORE_OWNERSHIP | MNT_AUTOMOUNTED | MNT_JOURNALED | \ |
6d2010ae | 343 | MNT_NOUSERXATTR | MNT_DEFWRITE | MNT_MULTILABEL | \ |
5ba3f43e | 344 | MNT_NOATIME | MNT_SNAPSHOT | MNT_CPROTECT) |
1c79356b A |
345 | /* |
346 | * External filesystem command modifier flags. | |
347 | * Unmount can use the MNT_FORCE flag. | |
348 | * XXX These are not STATES and really should be somewhere else. | |
349 | * External filesystem control flags. | |
350 | */ | |
351 | #define MNT_UPDATE 0x00010000 /* not a real mount, just an update */ | |
316670eb | 352 | #define MNT_NOBLOCK 0x00020000 /* don't block unmount if not responding */ |
1c79356b A |
353 | #define MNT_RELOAD 0x00040000 /* reload filesystem data */ |
354 | #define MNT_FORCE 0x00080000 /* force unmount or readonly change */ | |
316670eb | 355 | #define MNT_CMDFLAGS (MNT_UPDATE|MNT_NOBLOCK|MNT_RELOAD|MNT_FORCE) |
91447636 A |
356 | |
357 | ||
1c79356b | 358 | |
1c79356b A |
359 | /* |
360 | * Sysctl CTL_VFS definitions. | |
361 | * | |
362 | * Second level identifier specifies which filesystem. Second level | |
363 | * identifier VFS_GENERIC returns information about all filesystems. | |
364 | */ | |
365 | #define VFS_GENERIC 0 /* generic filesystem information */ | |
366 | #define VFS_NUMMNTOPS 1 /* int: total num of vfs mount/unmount operations */ | |
367 | /* | |
368 | * Third level identifiers for VFS_GENERIC are given below; third | |
369 | * level identifiers for specific filesystems are given in their | |
370 | * mount specific header files. | |
371 | */ | |
372 | #define VFS_MAXTYPENUM 1 /* int: highest defined filesystem type */ | |
373 | #define VFS_CONF 2 /* struct: vfsconf for filesystem given | |
374 | as next argument */ | |
55e303ae | 375 | |
1c79356b A |
376 | /* |
377 | * Flags for various system call interfaces. | |
378 | * | |
379 | * waitfor flags to vfs_sync() and getfsstat() | |
380 | */ | |
b0d623f7 | 381 | #define MNT_WAIT 1 /* synchronized I/O file integrity completion */ |
1c79356b | 382 | #define MNT_NOWAIT 2 /* start all I/O, but do not wait for it */ |
b0d623f7 | 383 | #define MNT_DWAIT 4 /* synchronized I/O data integrity completion */ |
1c79356b | 384 | |
1c79356b | 385 | |
91447636 A |
386 | #ifndef KERNEL |
387 | struct mount; | |
388 | typedef struct mount * mount_t; | |
389 | struct vnode; | |
390 | typedef struct vnode * vnode_t; | |
391 | #endif | |
1c79356b | 392 | |
b0d623f7 | 393 | /* Reserved fields preserve binary compatibility */ |
1c79356b | 394 | struct vfsconf { |
b0d623f7 | 395 | uint32_t vfc_reserved1; /* opaque */ |
1c79356b A |
396 | char vfc_name[MFSNAMELEN]; /* filesystem type name */ |
397 | int vfc_typenum; /* historic filesystem type number */ | |
398 | int vfc_refcount; /* number mounted of this type */ | |
399 | int vfc_flags; /* permanent flags */ | |
b0d623f7 A |
400 | uint32_t vfc_reserved2; /* opaque */ |
401 | uint32_t vfc_reserved3; /* opaque */ | |
1c79356b A |
402 | }; |
403 | ||
55e303ae A |
404 | struct vfsidctl { |
405 | int vc_vers; /* should be VFSIDCTL_VERS1 (below) */ | |
406 | fsid_t vc_fsid; /* fsid to operate on. */ | |
407 | void *vc_ptr; /* pointer to data structure. */ | |
408 | size_t vc_len; /* sizeof said structure. */ | |
409 | u_int32_t vc_spare[12]; /* spare (must be zero). */ | |
410 | }; | |
411 | ||
91447636 | 412 | |
55e303ae A |
413 | /* vfsidctl API version. */ |
414 | #define VFS_CTL_VERS1 0x01 | |
415 | ||
91447636 | 416 | #ifdef KERNEL |
91447636 A |
417 | struct user_vfsidctl { |
418 | int vc_vers; /* should be VFSIDCTL_VERS1 (below) */ | |
419 | fsid_t vc_fsid; /* fsid to operate on. */ | |
0c530ab8 | 420 | user_addr_t vc_ptr __attribute((aligned(8))); /* pointer to data structure. */ |
91447636 A |
421 | user_size_t vc_len; /* sizeof said structure. */ |
422 | u_int32_t vc_spare[12]; /* spare (must be zero). */ | |
423 | }; | |
424 | ||
b0d623f7 A |
425 | struct user32_vfsidctl { |
426 | int vc_vers; /* should be VFSIDCTL_VERS1 (below) */ | |
427 | fsid_t vc_fsid; /* fsid to operate on. */ | |
428 | user32_addr_t vc_ptr; /* pointer to data structure. */ | |
429 | user32_size_t vc_len; /* sizeof said structure. */ | |
430 | u_int32_t vc_spare[12]; /* spare (must be zero). */ | |
431 | }; | |
432 | ||
433 | union union_vfsidctl { /* the fields vc_vers and vc_fsid are compatible */ | |
434 | struct user32_vfsidctl vc32; | |
435 | struct user_vfsidctl vc64; | |
436 | }; | |
437 | ||
91447636 A |
438 | #endif /* KERNEL */ |
439 | ||
55e303ae A |
440 | /* |
441 | * New style VFS sysctls, do not reuse/conflict with the namespace for | |
442 | * private sysctls. | |
443 | */ | |
444 | #define VFS_CTL_STATFS 0x00010001 /* statfs */ | |
445 | #define VFS_CTL_UMOUNT 0x00010002 /* unmount */ | |
446 | #define VFS_CTL_QUERY 0x00010003 /* anything wrong? (vfsquery) */ | |
447 | #define VFS_CTL_NEWADDR 0x00010004 /* reconnect to new address */ | |
448 | #define VFS_CTL_TIMEO 0x00010005 /* set timeout for vfs notification */ | |
e5568f75 | 449 | #define VFS_CTL_NOLOCKS 0x00010006 /* disable file locking */ |
6d2010ae | 450 | #define VFS_CTL_SADDR 0x00010007 /* get server address */ |
316670eb | 451 | #define VFS_CTL_DISC 0x00010008 /* server disconnected */ |
39236c6e | 452 | #define VFS_CTL_SERVERINFO 0x00010009 /* information about fs server */ |
fe8ab488 | 453 | #define VFS_CTL_NSTATUS 0x0001000A /* netfs mount status */ |
55e303ae A |
454 | |
455 | struct vfsquery { | |
456 | u_int32_t vq_flags; | |
457 | u_int32_t vq_spare[31]; | |
458 | }; | |
459 | ||
39236c6e A |
460 | struct vfs_server { |
461 | int32_t vs_minutes; /* minutes until server goes down. */ | |
462 | u_int8_t vs_server_name[MAXHOSTNAMELEN*3]; /* UTF8 server name to display (null terminated) */ | |
463 | }; | |
464 | ||
fe8ab488 A |
465 | /* |
466 | * NetFS mount status - returned by VFS_CTL_NSTATUS | |
467 | */ | |
468 | struct netfs_status { | |
469 | u_int32_t ns_status; // Current status of mount (vfsquery flags) | |
470 | char ns_mountopts[512]; // Significant mount options | |
471 | uint32_t ns_waittime; // Time waiting for reply (sec) | |
472 | uint32_t ns_threadcount; // Number of threads blocked on network calls | |
473 | uint64_t ns_threadids[0]; // Thread IDs of those blocked threads | |
474 | }; | |
475 | ||
55e303ae A |
476 | /* vfsquery flags */ |
477 | #define VQ_NOTRESP 0x0001 /* server down */ | |
478 | #define VQ_NEEDAUTH 0x0002 /* server bad auth */ | |
479 | #define VQ_LOWDISK 0x0004 /* we're low on space */ | |
480 | #define VQ_MOUNT 0x0008 /* new filesystem arrived */ | |
481 | #define VQ_UNMOUNT 0x0010 /* filesystem has left */ | |
482 | #define VQ_DEAD 0x0020 /* filesystem is dead, needs force unmount */ | |
91447636 | 483 | #define VQ_ASSIST 0x0040 /* filesystem needs assistance from external program */ |
e5568f75 | 484 | #define VQ_NOTRESPLOCK 0x0080 /* server lockd down */ |
91447636 | 485 | #define VQ_UPDATE 0x0100 /* filesystem information has changed */ |
b0d623f7 | 486 | #define VQ_VERYLOWDISK 0x0200 /* file system has *very* little disk space left */ |
39236c6e A |
487 | #define VQ_SYNCEVENT 0x0400 /* a sync just happened (not set by kernel starting Mac OS X 10.9) */ |
488 | #define VQ_SERVEREVENT 0x0800 /* server issued notification/warning */ | |
490019cf | 489 | #define VQ_QUOTA 0x1000 /* a user quota has been hit */ |
813fb2f6 A |
490 | #define VQ_NEARLOWDISK 0x2000 /* Above lowdisk and below desired disk space */ |
491 | #define VQ_DESIRED_DISK 0x4000 /* the desired disk space */ | |
55e303ae A |
492 | #define VQ_FLAG8000 0x8000 /* placeholder */ |
493 | ||
55e303ae | 494 | |
9bccf70c | 495 | #ifdef KERNEL |
1c79356b | 496 | |
91447636 A |
497 | /* Structure for setting device IO parameters per mount point */ |
498 | struct vfsioattr { | |
499 | u_int32_t io_maxreadcnt; /* Max. byte count for read */ | |
500 | u_int32_t io_maxwritecnt; /* Max. byte count for write */ | |
501 | u_int32_t io_segreadcnt; /* Max. segment count for read */ | |
502 | u_int32_t io_segwritecnt; /* Max. segment count for write */ | |
503 | u_int32_t io_maxsegreadsize; /* Max. segment read size */ | |
504 | u_int32_t io_maxsegwritesize; /* Max. segment write size */ | |
505 | u_int32_t io_devblocksize; /* the underlying device block size */ | |
2d21ac55 | 506 | u_int32_t io_flags; /* flags for underlying device */ |
39037602 A |
507 | union { |
508 | int64_t io_max_swappin_available; | |
509 | // On 32 bit architectures, we don't have any spare | |
510 | void *io_reserved[2]; | |
511 | }; | |
91447636 A |
512 | }; |
513 | ||
39037602 A |
514 | #define VFS_IOATTR_FLAGS_FUA 0x00000001 /* Write-through cache supported */ |
515 | #define VFS_IOATTR_FLAGS_UNMAP 0x00000002 /* Unmap (trim) supported */ | |
516 | #define VFS_IOATTR_FLAGS_SWAPPIN_SUPPORTED 0x00000010 /* Pinning swap file supported */ | |
1c79356b A |
517 | |
518 | /* | |
91447636 | 519 | * Filesystem Registration information |
1c79356b | 520 | */ |
39236c6e A |
521 | #define VFS_TBLTHREADSAFE 0x0001 /* Only threadsafe filesystems are supported */ |
522 | #define VFS_TBLFSNODELOCK 0x0002 /* Only threadsafe filesystems are supported */ | |
2d21ac55 A |
523 | #define VFS_TBLNOTYPENUM 0x0008 |
524 | #define VFS_TBLLOCALVOL 0x0010 | |
525 | #define VFS_TBL64BITREADY 0x0020 | |
526 | #define VFS_TBLNATIVEXATTR 0x0040 | |
527 | #define VFS_TBLDIRLINKS 0x0080 | |
528 | #define VFS_TBLUNMOUNT_PREFLIGHT 0x0100 /* does a preflight check before unmounting */ | |
529 | #define VFS_TBLGENERICMNTARGS 0x0200 /* force generic mount args for local fs */ | |
530 | #define VFS_TBLREADDIR_EXTENDED 0x0400 /* fs supports VNODE_READDIR_EXTENDED */ | |
531 | #define VFS_TBLNOMACLABEL 0x1000 | |
b0d623f7 A |
532 | #define VFS_TBLVNOP_PAGEINV2 0x2000 |
533 | #define VFS_TBLVNOP_PAGEOUTV2 0x4000 | |
39236c6e | 534 | #define VFS_TBLVNOP_NOUPDATEID_RENAME 0x8000 /* vfs should not call vnode_update_ident on rename */ |
fe8ab488 | 535 | #define VFS_TBLVNOP_SECLUDE_RENAME 0x10000 |
39037602 | 536 | #define VFS_TBLCANMOUNTROOT 0x20000 |
b0d623f7 | 537 | |
91447636 A |
538 | |
539 | struct vfs_fsentry { | |
540 | struct vfsops * vfe_vfsops; /* vfs operations */ | |
541 | int vfe_vopcnt; /* # of vnodeopv_desc being registered (reg, spec, fifo ...) */ | |
542 | struct vnodeopv_desc ** vfe_opvdescs; /* null terminated; */ | |
543 | int vfe_fstypenum; /* historic filesystem type number */ | |
544 | char vfe_fsname[MFSNAMELEN]; /* filesystem type name */ | |
545 | uint32_t vfe_flags; /* defines the FS capabilities */ | |
546 | void * vfe_reserv[2]; /* reserved for future use; set this to zero*/ | |
547 | }; | |
548 | ||
549 | ||
1c79356b A |
550 | |
551 | struct vfsops { | |
b0d623f7 A |
552 | /*! |
553 | @function vfs_mount | |
554 | @abstract Perform filesystem-specific operations required for mounting. | |
555 | @discussion Typical operations include setting the mount-specific data with vfs_setfsprivate(). | |
556 | Note that if a mount call fails, the filesystem must clean up any state it has constructed, because | |
557 | vfs-level mount code will not clean it up. | |
558 | @param mp Mount structure for the newly mounted filesystem. | |
559 | @param devvp Device that the filesystem is mounted from. | |
560 | @param data Filesystem-specific data passed down from userspace. | |
561 | @param context Context to authenticate for mount. | |
562 | @return 0 for success, else an error code. Once success is returned, the filesystem should be ready to go active; | |
563 | VFS will not ask again. | |
564 | */ | |
91447636 | 565 | int (*vfs_mount)(struct mount *mp, vnode_t devvp, user_addr_t data, vfs_context_t context); |
b0d623f7 A |
566 | |
567 | /*! | |
568 | @function vfs_start | |
569 | @abstract Mark a mount as ready to be used. | |
570 | @discussion After receiving this calldown, a filesystem will be hooked into the mount list and should expect | |
571 | calls down from the VFS layer. | |
572 | @param mp Mount structure being activated. | |
573 | @param flags Unused. | |
574 | @param context Context to authenticate for mount. | |
575 | @return Return value is ignored. | |
576 | */ | |
91447636 | 577 | int (*vfs_start)(struct mount *mp, int flags, vfs_context_t context); |
b0d623f7 A |
578 | |
579 | /*! | |
580 | @function vfs_unmount | |
581 | @abstract Perform filesystem-specific cleanup as part of unmount. | |
582 | @discussion If the unmount downcall succeeds, VFS considers itself authorized to destroy all | |
583 | state related to the mount. | |
584 | @param mp Mount structure to unmount. | |
585 | @param mntflags MNT_FORCE indicates that we wish to unmount even if there are active vnodes. | |
586 | @param context Context to authenticate for unmount. | |
587 | @return 0 for success, else an error code. | |
588 | */ | |
91447636 | 589 | int (*vfs_unmount)(struct mount *mp, int mntflags, vfs_context_t context); |
b0d623f7 A |
590 | |
591 | /*! | |
592 | @function vfs_root | |
593 | @abstract Get the root vnode of a filesystem. | |
594 | @discussion Upon success, should return with an iocount held on the root vnode which the caller will | |
595 | drop with vnode_put(). | |
596 | @param mp Mount for which to get the root. | |
597 | @param vpp Destination for root vnode. | |
598 | @param context Context to authenticate for getting the root. | |
599 | @return 0 for success, else an error code. | |
600 | */ | |
91447636 | 601 | int (*vfs_root)(struct mount *mp, struct vnode **vpp, vfs_context_t context); |
b0d623f7 A |
602 | |
603 | /*! | |
604 | @function vfs_quotactl | |
605 | @abstract Manipulate quotas for a volume. | |
606 | @param mp Mount for which to manipulate quotas. | |
607 | @param cmds Detailed in "quotactl" manual page. | |
608 | @param uid Detailed in "quotactl" manual page. | |
609 | @param arg Detailed in "quotactl" manual page. | |
610 | @param context Context to authenticate for changing quotas. | |
611 | @return 0 for success, else an error code. | |
612 | */ | |
91447636 | 613 | int (*vfs_quotactl)(struct mount *mp, int cmds, uid_t uid, caddr_t arg, vfs_context_t context); |
b0d623f7 A |
614 | |
615 | /*! | |
616 | @function vfs_getattr | |
617 | @abstract Get filesystem attributes. | |
618 | @discussion See VFSATTR_RETURN, VFSATTR_ACTIVE, VFSATTR_SET_SUPPORTED, VFSATTR_WANTED macros. | |
619 | @param mp Mount for which to get parameters. | |
620 | @param vfa Container for specifying which attributes are desired and which attributes the filesystem | |
621 | supports, as well as for returning results. | |
622 | @param ctx Context to authenticate for getting filesystem attributes. | |
623 | @return 0 for success, else an error code. | |
624 | */ | |
91447636 A |
625 | int (*vfs_getattr)(struct mount *mp, struct vfs_attr *, vfs_context_t context); |
626 | /* int (*vfs_statfs)(struct mount *mp, struct vfsstatfs *sbp, vfs_context_t context);*/ | |
b0d623f7 A |
627 | |
628 | /*! | |
629 | @function vfs_sync | |
630 | @abstract Flush all filesystem data to backing store. | |
631 | @discussion vfs_sync will be called as part of the sync() system call and during unmount. | |
632 | @param mp Mountpoint to sync. | |
633 | @param waitfor MNT_WAIT: flush synchronously, waiting for all data to be written before returning. MNT_NOWAIT: start I/O but do not wait for it. | |
634 | @param ctx Context to authenticate for the sync. | |
635 | @return 0 for success, else an error code. | |
636 | */ | |
91447636 | 637 | int (*vfs_sync)(struct mount *mp, int waitfor, vfs_context_t context); |
b0d623f7 A |
638 | |
639 | /*! | |
640 | @function vfs_vget | |
641 | @abstract Get a vnode by file id (inode number). | |
642 | @discussion This routine is chiefly used to build paths to vnodes. Result should be turned with an iocount that the | |
643 | caller will drop with vnode_put(). | |
644 | @param mp Mount against which to look up inode number. | |
645 | @param ino File ID for desired file, as found through a readdir. | |
646 | @param vpp Destination for vnode. | |
647 | @return 0 for success, else an error code. | |
648 | */ | |
91447636 | 649 | int (*vfs_vget)(struct mount *mp, ino64_t ino, struct vnode **vpp, vfs_context_t context); |
b0d623f7 A |
650 | |
651 | /*! | |
652 | @function vfs_fhtovp | |
653 | @abstract Get the vnode corresponding to a file handle. | |
654 | @discussion Filesystems can return handles to files which are independent of their (transient) vnode identities. | |
655 | vfs_thtovp converts that persistent handle back to a vnode. The vnode should be returned with an iocount which | |
656 | the caller will drop with vnode_put(). | |
657 | @param mp Mount against which to look up file handle. | |
658 | @param fhlen Size of file handle structure, as returned by vfs_vptofh. | |
659 | @param fhp Pointer to handle. | |
660 | @param vpp Destination for vnode. | |
661 | @param ctx Context against which to authenticate the file-handle conversion. | |
662 | @return 0 for success, else an error code. | |
663 | */ | |
91447636 A |
664 | int (*vfs_fhtovp)(struct mount *mp, int fhlen, unsigned char *fhp, struct vnode **vpp, |
665 | vfs_context_t context); | |
b0d623f7 A |
666 | |
667 | /*! | |
668 | @function vfs_vptofh | |
669 | @abstract Get a persistent handle corresponding to a vnode. | |
670 | @param mp Mount against which to convert the vnode to a handle. | |
671 | @param fhlen Size of buffer provided for handle; set to size of actual handle returned. | |
672 | @param fhp Pointer to buffer in which to place handle data. | |
673 | @param ctx Context against which to authenticate the file-handle request. | |
674 | @return 0 for success, else an error code. | |
675 | */ | |
91447636 | 676 | int (*vfs_vptofh)(struct vnode *vp, int *fhlen, unsigned char *fhp, vfs_context_t context); |
b0d623f7 A |
677 | |
678 | /*! | |
679 | @function vfs_init | |
680 | @abstract Prepare a filesystem for having instances mounted. | |
681 | @discussion This routine is called once, before any particular instance of a filesystem | |
682 | is mounted; it allows the filesystem to initialize whatever global data structures | |
683 | are shared across all mounts. If this returns successfully, a filesystem should be ready to have | |
684 | instances mounted. | |
685 | @param vfsconf Configuration information. Currently, the only useful data are the filesystem name, | |
686 | typenum, and flags. The flags field will be either 0 or MNT_LOCAL. Many filesystems ignore this | |
687 | parameter. | |
688 | @return 0 for success, else an error code. | |
689 | */ | |
91447636 | 690 | int (*vfs_init)(struct vfsconf *); |
b0d623f7 A |
691 | |
692 | /*! | |
693 | @function vfs_sysctl | |
694 | @abstract Broad interface for querying and controlling filesystem. | |
695 | @discussion VFS defines VFS_CTL_QUERY as a generic status request which is answered | |
696 | with the VQ_* macros in a "struct vfsquery." | |
697 | A filesystem may also define implementation-specific commands. See "man 3 sysctl" | |
698 | for the meaning of sysctl parameters. | |
699 | @param context Context against which to authenticate command. | |
700 | @return 0 for success, else an error code. | |
701 | */ | |
91447636 | 702 | int (*vfs_sysctl)(int *, u_int, user_addr_t, size_t *, user_addr_t, size_t, vfs_context_t context); |
b0d623f7 A |
703 | |
704 | /*! | |
705 | @function vfs_setattr | |
706 | @abstract Set filesystem attributes. | |
707 | @discussion The other side of the vfs_getattr coin. Currently only called to set volume name. | |
708 | @param mp Mount on which to set attributes. | |
709 | @param vfa VFS attribute structure containing requested attributes to set and their values. Currently | |
710 | will only be called with f_vol_name set. | |
711 | @param context Context against which to authenticate attribute change. | |
712 | @return 0 for success, else an error code. | |
713 | */ | |
91447636 | 714 | int (*vfs_setattr)(struct mount *mp, struct vfs_attr *, vfs_context_t context); |
39037602 A |
715 | |
716 | /*! | |
717 | @function vfs_ioctl | |
718 | @abstract File system control operations. | |
719 | @discussion Unlike vfs_sysctl, this is specific to a particular volume. | |
720 | @param mp The mount to execute the command on. | |
721 | @param command Identifier for action to take. The command used here | |
722 | should be in the same namespace as VNOP ioctl commands. | |
723 | @param data Pointer to data; this can be an integer constant (of 32 bits | |
724 | only) or an address to be read from or written to, depending on "command." | |
725 | If it is an address, it is valid and resides in the kernel; callers of | |
726 | VFS_IOCTL() are responsible for copying to and from userland. | |
727 | @param flags Reserved for future use, set to zero | |
728 | @param ctx Context against which to authenticate ioctl request. | |
729 | @return 0 for success, else an error code. | |
730 | */ | |
731 | int (*vfs_ioctl)(struct mount *mp, u_long command, caddr_t data, | |
732 | int flags, vfs_context_t context); | |
733 | ||
734 | /*! | |
735 | @function vfs_vget_snapdir | |
736 | @abstract Get the vnode for the snapshot directory of a filesystem. | |
737 | @discussion Upon success, should return with an iocount held on the root vnode which the caller will | |
738 | drop with vnode_put(). | |
739 | @param mp Mount for which to get the root. | |
740 | @param vpp Destination for snapshot directory vnode. | |
741 | @param context Context to authenticate for getting the snapshot directory. | |
742 | @return 0 for success, else an error code. | |
743 | */ | |
744 | int (*vfs_vget_snapdir)(struct mount *mp, struct vnode **vpp, vfs_context_t context); | |
745 | void *vfs_reserved5; | |
746 | void *vfs_reserved4; | |
747 | void *vfs_reserved3; | |
748 | void *vfs_reserved2; | |
749 | void *vfs_reserved1; | |
1c79356b A |
750 | }; |
751 | ||
39037602 A |
752 | #ifdef KERNEL |
753 | ||
754 | /* | |
755 | * Commands for vfs_ioctl. While they are encoded the same way as for ioctl(2), | |
756 | * there is no generic interface for them from userspace like ioctl(2). | |
757 | */ | |
758 | struct fs_snapshot_mount_args { | |
759 | mount_t sm_mp; | |
760 | struct componentname *sm_cnp; | |
761 | }; | |
762 | ||
763 | #define VFSIOC_MOUNT_SNAPSHOT _IOW('V', 1, struct fs_snapshot_mount_args) | |
39037602 A |
764 | |
765 | struct fs_snapshot_revert_args { | |
766 | struct componentname *sr_cnp; | |
767 | }; | |
768 | #define VFSIOC_REVERT_SNAPSHOT _IOW('V', 2, struct fs_snapshot_revert_args) | |
39037602 | 769 | |
813fb2f6 A |
770 | struct fs_snapshot_root_args { |
771 | struct componentname *sr_cnp; | |
772 | }; | |
773 | #define VFSIOC_ROOT_SNAPSHOT _IOW('V', 3, struct fs_snapshot_root_args) | |
813fb2f6 | 774 | |
39037602 | 775 | #endif /* KERNEL */ |
1c79356b A |
776 | |
777 | /* | |
91447636 | 778 | * flags passed into vfs_iterate |
1c79356b | 779 | */ |
6d2010ae A |
780 | #ifdef PRIVATE |
781 | #define VFS_ITERATE_TAIL_FIRST (1 << 0) | |
fe8ab488 | 782 | #define VFS_ITERATE_CB_DROPREF (1 << 1) // Callback will drop the iterref |
6d2010ae | 783 | #endif /* PRIVATE */ |
1c79356b A |
784 | |
785 | /* | |
91447636 | 786 | * return values from callback |
1c79356b | 787 | */ |
91447636 A |
788 | #define VFS_RETURNED 0 /* done with vnode, reference can be dropped */ |
789 | #define VFS_RETURNED_DONE 1 /* done with vnode, reference can be dropped, terminate iteration */ | |
790 | #define VFS_CLAIMED 2 /* don't drop reference */ | |
791 | #define VFS_CLAIMED_DONE 3 /* don't drop reference, terminate iteration */ | |
1c79356b | 792 | |
91447636 A |
793 | |
794 | __BEGIN_DECLS | |
b0d623f7 | 795 | #ifdef BSD_KERNEL_PRIVATE |
91447636 A |
796 | extern int VFS_MOUNT(mount_t, vnode_t, user_addr_t, vfs_context_t); |
797 | extern int VFS_START(mount_t, int, vfs_context_t); | |
798 | extern int VFS_UNMOUNT(mount_t, int, vfs_context_t); | |
799 | extern int VFS_ROOT(mount_t, vnode_t *, vfs_context_t); | |
800 | extern int VFS_QUOTACTL(mount_t, int, uid_t, caddr_t, vfs_context_t); | |
2d21ac55 A |
801 | extern int VFS_GETATTR(mount_t, struct vfs_attr *, vfs_context_t); |
802 | extern int VFS_SETATTR(mount_t, struct vfs_attr *, vfs_context_t); | |
91447636 A |
803 | extern int VFS_SYNC(mount_t, int, vfs_context_t); |
804 | extern int VFS_VGET(mount_t, ino64_t, vnode_t *, vfs_context_t); | |
805 | extern int VFS_FHTOVP(mount_t, int, unsigned char *, vnode_t *, vfs_context_t); | |
806 | extern int VFS_VPTOFH(vnode_t, int *, unsigned char *, vfs_context_t); | |
39037602 A |
807 | extern int VFS_IOCTL(mount_t mp, u_long command, caddr_t data, |
808 | int flags, vfs_context_t context); | |
809 | extern int VFS_VGET_SNAPDIR(mount_t, vnode_t *, vfs_context_t); | |
b0d623f7 A |
810 | #endif /* BSD_KERNEL_PRIVATE */ |
811 | /* | |
812 | * prototypes for exported VFS operations | |
813 | */ | |
91447636 | 814 | |
b0d623f7 A |
815 | /*! |
816 | @function vfs_fsadd | |
817 | @abstract Register a filesystem with VFS. | |
818 | @discussion Typically called by a filesystem Kernel Extension when it is loaded. | |
819 | @param vfe Filesystem information: table of vfs operations, list of vnode operation tables, | |
820 | filesystem type number (can be omitted with VFS_TBLNOTYPENUM flag), name, flags. | |
821 | @param handle Opaque handle which will be passed to vfs_fsremove. | |
822 | @return 0 for success, else an error code. | |
823 | */ | |
39037602 | 824 | int vfs_fsadd(struct vfs_fsentry *vfe, vfstable_t *handle); |
b0d623f7 A |
825 | |
826 | /*! | |
827 | @function vfs_fsremove | |
828 | @abstract Unregister a filesystem with VFS. | |
829 | @discussion Typically called by a filesystem Kernel Extension when it is unloaded. | |
830 | @param handle Handle which was returned by vfs_fsadd. | |
831 | @return 0 for success, else an error code. | |
832 | */ | |
39037602 | 833 | int vfs_fsremove(vfstable_t handle); |
b0d623f7 A |
834 | |
835 | /*! | |
836 | @function vfs_iterate | |
837 | @abstract Iterate over all mountpoints with a callback. Used, for example, by sync(). | |
838 | @param flags Unused. | |
39037602 | 839 | @param callout Function which takes a mount and arbitrary passed-in "arg," and returns one of VFS_RETURNED_DONE or VFS_CLAIMED_DONE: end |
b0d623f7 A |
840 | iteration and return success. VFS_RETURNED or VFS_CLAIMED: continue iterating. Anything else: continue iterating. |
841 | @param arg Arbitrary data to pass to callback. | |
842 | @return 0 for success, else an error code. | |
843 | */ | |
39037602 | 844 | int vfs_iterate(int flags, int (*callout)(struct mount *, void *), void *arg); |
91447636 | 845 | |
b0d623f7 A |
846 | /*! |
847 | @function vfs_init_io_attributes | |
848 | @abstract Set I/O attributes on a mountpoint based on device properties. | |
849 | @param devvp Block device vnode from which a filesystem is being mounted. | |
850 | @param mp Mountpoint whose I/O parameters to initialize. | |
851 | @return 0 for success, else an error code. | |
852 | */ | |
39037602 | 853 | int vfs_init_io_attributes(vnode_t devvp, mount_t mp); |
b0d623f7 A |
854 | |
855 | /*! | |
856 | @function vfs_flags | |
857 | @abstract Retrieve mount flags. | |
858 | @discussion Results will be in the bitwise "OR" of MNT_VISFLAGMASK and MNT_CMDFLAGS. | |
859 | @param mp Mount whose flags to grab. | |
860 | @return Flags. | |
861 | */ | |
39037602 | 862 | uint64_t vfs_flags(mount_t mp); |
b0d623f7 A |
863 | |
864 | /*! | |
865 | @function vfs_setflags | |
866 | @abstract Set flags on a mount. | |
867 | @discussion Sets mount flags to the bitwise "OR" of their current value and the specified bits. Often | |
868 | used by a filesystem as part of the mount process. | |
869 | @param mp Mount whose flags to set. | |
870 | @param flags Flags to activate. Must be in the bitwise "OR" of MNT_VISFLAGMASK and MNT_CMDFLAGS. | |
b0d623f7 | 871 | */ |
39037602 | 872 | void vfs_setflags(mount_t mp, uint64_t flags); |
b0d623f7 A |
873 | |
874 | /*! | |
875 | @function vfs_clearflags | |
876 | @abstract Clear flags on a mount. | |
877 | @discussion Sets mount flags to the bitwise "AND" of their current value and the complement of the specified bits. | |
878 | @param mp Mount whose flags to set. | |
879 | @param flags Flags to deactivate. Must be in the bitwise "OR" of MNT_VISFLAGMASK and MNT_CMDFLAGS. | |
b0d623f7 | 880 | */ |
39037602 | 881 | void vfs_clearflags(mount_t mp, uint64_t flags); |
91447636 | 882 | |
b0d623f7 A |
883 | /*! |
884 | @function vfs_issynchronous | |
885 | @abstract Determine if writes to a filesystem occur synchronously. | |
886 | @param mp Mount to test. | |
887 | @return Nonzero if writes occur synchronously, else 0. | |
888 | */ | |
39037602 | 889 | int vfs_issynchronous(mount_t mp); |
b0d623f7 A |
890 | |
891 | /*! | |
892 | @function vfs_iswriteupgrade | |
893 | @abstract Determine if a filesystem is mounted read-only but a request has been made to upgrade | |
894 | to read-write. | |
895 | @param mp Mount to test. | |
896 | @return Nonzero if a request has been made to update from read-only to read-write, else 0. | |
897 | */ | |
39037602 | 898 | int vfs_iswriteupgrade(mount_t mp); |
b0d623f7 A |
899 | |
900 | /*! | |
901 | @function vfs_isupdate | |
902 | @abstract Determine if a mount update is in progress. | |
903 | @param mp Mount to test. | |
904 | @return Nonzero if a mount update is in progress, 0 otherwise. | |
905 | */ | |
39037602 | 906 | int vfs_isupdate(mount_t mp); |
b0d623f7 A |
907 | |
908 | /*! | |
909 | @function vfs_isreload | |
910 | @abstract Determine if a reload of filesystem data is in progress. This can only be the case | |
911 | for a read-only filesystem; all data is brought in from secondary storage. | |
912 | @param mp Mount to test. | |
913 | @return Nonzero if a request has been made to reload data, else 0. | |
914 | */ | |
39037602 | 915 | int vfs_isreload(mount_t mp); |
b0d623f7 A |
916 | |
917 | /*! | |
918 | @function vfs_isforce | |
919 | @abstract Determine if a forced unmount is in progress. | |
920 | @discussion A forced unmount invalidates open files. | |
921 | @param mp Mount to test. | |
922 | @return Nonzero if a request has been made to forcibly unmount, else 0. | |
923 | */ | |
39037602 | 924 | int vfs_isforce(mount_t mp); |
b0d623f7 A |
925 | |
926 | /*! | |
927 | @function vfs_isunmount | |
928 | @abstract Determine if an unmount is in progress. | |
929 | @discussion This is an unsynchronized snapshot of the mount state. It should only be called | |
930 | if the mount is known to be valid, e.g. there are known to be live files on that volume. | |
931 | @param mp Mount to test. | |
932 | @return Nonzero if an unmount is in progress, else zero. | |
933 | */ | |
934 | int vfs_isunmount(mount_t mp); | |
935 | ||
936 | /*! | |
937 | @function vfs_isrdonly | |
938 | @abstract Determine if a filesystem is mounted read-only. | |
939 | @param mp Mount to test. | |
940 | @return Nonzero if filesystem is mounted read-only, else 0. | |
941 | */ | |
39037602 | 942 | int vfs_isrdonly(mount_t mp); |
b0d623f7 A |
943 | |
944 | /*! | |
945 | @function vfs_isrdwr | |
946 | @abstract Determine if a filesystem is mounted with writes enabled. | |
947 | @param mp Mount to test. | |
948 | @return Nonzero if filesystem is mounted read-write, else 0. | |
949 | */ | |
39037602 | 950 | int vfs_isrdwr(mount_t mp); |
b0d623f7 A |
951 | |
952 | /*! | |
953 | @function vfs_authopaque | |
954 | @abstract Determine if a filesystem's authorization decisions occur remotely. | |
955 | @param mp Mount to test. | |
956 | @return Nonzero if filesystem authorization is controlled remotely, else 0. | |
957 | */ | |
39037602 | 958 | int vfs_authopaque(mount_t mp); |
b0d623f7 A |
959 | |
960 | /*! | |
961 | @function vfs_authopaqueaccess | |
962 | @abstract Check if a filesystem is marked as having reliable remote VNOP_ACCESS support. | |
963 | @param mp Mount to test. | |
964 | @return Nonzero if VNOP_ACCESS is supported remotely, else 0. | |
965 | */ | |
39037602 | 966 | int vfs_authopaqueaccess(mount_t mp); |
b0d623f7 A |
967 | |
968 | /*! | |
969 | @function vfs_setauthopaque | |
970 | @abstract Mark a filesystem as having authorization decisions controlled remotely. | |
971 | @param mp Mount to mark. | |
b0d623f7 | 972 | */ |
39037602 | 973 | void vfs_setauthopaque(mount_t mp); |
b0d623f7 A |
974 | |
975 | /*! | |
976 | @function vfs_setauthopaqueaccess | |
977 | @abstract Mark a filesystem as having remote VNOP_ACCESS support. | |
978 | @param mp Mount to mark. | |
b0d623f7 | 979 | */ |
39037602 | 980 | void vfs_setauthopaqueaccess(mount_t mp); |
b0d623f7 A |
981 | |
982 | /*! | |
983 | @function vfs_clearauthopaque | |
984 | @abstract Mark a filesystem as not having remote authorization decisions. | |
985 | @param mp Mount to mark. | |
b0d623f7 | 986 | */ |
39037602 | 987 | void vfs_clearauthopaque(mount_t mp); |
b0d623f7 A |
988 | |
989 | /*! | |
990 | @function vfs_clearauthopaque | |
991 | @abstract Mark a filesystem as not having remote VNOP_ACCESS support. | |
992 | @param mp Mount to mark. | |
b0d623f7 | 993 | */ |
39037602 | 994 | void vfs_clearauthopaqueaccess(mount_t mp); |
b0d623f7 A |
995 | |
996 | /*! | |
997 | @function vfs_setextendedsecurity | |
998 | @abstract Mark a filesystem as supporting security controls beyond POSIX permissions. | |
999 | @discussion Specific controls include ACLs, file owner UUIDs, and group UUIDs. | |
1000 | @param mp Mount to test. | |
b0d623f7 | 1001 | */ |
39037602 | 1002 | void vfs_setextendedsecurity(mount_t mp); |
b0d623f7 A |
1003 | |
1004 | /*! | |
1005 | @function vfs_clearextendedsecurity | |
1006 | @abstract Mark a filesystem as NOT supporting security controls beyond POSIX permissions. | |
1007 | @discussion Specific controls include ACLs, file owner UUIDs, and group UUIDs. | |
1008 | @param mp Mount to test. | |
b0d623f7 | 1009 | */ |
39037602 | 1010 | void vfs_clearextendedsecurity(mount_t mp); |
b0d623f7 | 1011 | |
813fb2f6 A |
1012 | /*! |
1013 | @function vfs_setnoswap | |
1014 | @abstract Mark a filesystem as unable to use swap files. | |
1015 | @param mp Mount to mark. | |
1016 | */ | |
1017 | void vfs_setnoswap(mount_t mp); | |
1018 | ||
1019 | /*! | |
1020 | @function vfs_clearnoswap | |
1021 | @abstract Mark a filesystem as capable of using swap files. | |
1022 | @param mp Mount to mark. | |
1023 | */ | |
1024 | void vfs_clearnoswap(mount_t mp); | |
1025 | ||
b0d623f7 A |
1026 | /*! |
1027 | @function vfs_setlocklocal | |
1028 | @abstract Mark a filesystem as using VFS-level advisory locking support. | |
1029 | @discussion Advisory locking operations will not call down to the filesystem if this flag is set. | |
1030 | @param mp Mount to mark. | |
b0d623f7 | 1031 | */ |
39037602 | 1032 | void vfs_setlocklocal(mount_t mp); |
b0d623f7 A |
1033 | |
1034 | /*! | |
1035 | @function vfs_authcache_ttl | |
1036 | @abstract Determine the time-to-live of cached authorized credentials for files in this filesystem. | |
1037 | @discussion If a filesystem is set to allow caching credentials, the VFS layer can authorize | |
1038 | previously-authorized actions from the same vfs_context_t without calling down to the filesystem (though | |
1039 | it will not deny based on the cache). | |
1040 | @param mp Mount for which to check cache lifetime. | |
1041 | @return Cache lifetime in seconds. CACHED_RIGHT_INFINITE_TTL indicates that credentials never expire. | |
1042 | */ | |
39037602 | 1043 | int vfs_authcache_ttl(mount_t mp); |
b0d623f7 A |
1044 | |
1045 | /*! | |
1046 | @function vfs_setauthcache_ttl | |
1047 | @abstract Enable credential caching and set time-to-live of cached authorized credentials for files in this filesystem. | |
1048 | @discussion If a filesystem is set to allow caching credentials, the VFS layer can authorize | |
1049 | previously-authorized actions from the same vfs_context_t without calling down to the filesystem (though | |
1050 | it will not deny based on the cache). | |
1051 | @param mp Mount for which to set cache lifetime. | |
b0d623f7 | 1052 | */ |
39037602 | 1053 | void vfs_setauthcache_ttl(mount_t mp, int ttl); |
b0d623f7 A |
1054 | |
1055 | /*! | |
1056 | @function vfs_clearauthcache_ttl | |
1057 | @abstract Remove time-to-live controls for cached credentials on a filesytem. Filesystems with remote authorization | |
1058 | decisions (opaque) will still have KAUTH_VNODE_SEARCH rights cached for a default of CACHED_LOOKUP_RIGHT_TTL seconds. | |
1059 | @param mp Mount for which to clear cache lifetime. | |
b0d623f7 | 1060 | */ |
39037602 | 1061 | void vfs_clearauthcache_ttl(mount_t mp); |
91447636 | 1062 | |
2d21ac55 A |
1063 | /* |
1064 | * return value from vfs_cachedrights_ttl if | |
1065 | * neither MNTK_AUTH_OPAQUE | MNTK_AUTH_CACHE_TTL | |
1066 | * is set in mnt_kern_flag.. it indicates | |
1067 | * that no TTL is being applied to the vnode rights cache | |
1068 | */ | |
1069 | #define CACHED_RIGHT_INFINITE_TTL ~0 | |
91447636 | 1070 | |
b0d623f7 A |
1071 | /*! |
1072 | @function vfs_maxsymlen | |
1073 | @abstract Get the maximum length of a symbolic link on a filesystem. | |
1074 | @param mp Mount from which to get symlink length cap. | |
1075 | @return Max symlink length. | |
1076 | */ | |
39037602 | 1077 | uint32_t vfs_maxsymlen(mount_t mp); |
b0d623f7 A |
1078 | |
1079 | /*! | |
1080 | @function vfs_setmaxsymlen | |
1081 | @abstract Set the maximum length of a symbolic link on a filesystem. | |
1082 | @param mp Mount on which to set symlink length cap. | |
1083 | @param symlen Length to set. | |
b0d623f7 | 1084 | */ |
39037602 | 1085 | void vfs_setmaxsymlen(mount_t mp, uint32_t symlen); |
b0d623f7 A |
1086 | |
1087 | /*! | |
1088 | @function vfs_fsprivate | |
1089 | @abstract Get filesystem-private mount data. | |
1090 | @discussion A filesystem generally has an internal mount structure which it attaches to the VFS-level mount structure | |
1091 | as part of the mounting process. | |
1092 | @param mp Mount for which to get private data. | |
1093 | @return Private data. | |
1094 | */ | |
39037602 | 1095 | void * vfs_fsprivate(mount_t mp); |
b0d623f7 A |
1096 | |
1097 | /*! | |
1098 | @function vfs_setfsprivate | |
1099 | @abstract Set filesystem-private mount data. | |
1100 | @discussion A filesystem generally has an internal mount structure which it attaches to the VFS-level mount structure | |
1101 | as part of the mounting process. | |
1102 | @param mp Mount for which to set private data. | |
b0d623f7 | 1103 | */ |
39037602 | 1104 | void vfs_setfsprivate(mount_t mp, void *mntdata); |
91447636 | 1105 | |
b0d623f7 A |
1106 | /*! |
1107 | @function vfs_statfs | |
1108 | @abstract Get information about filesystem status. | |
1109 | @discussion Each filesystem has a struct vfsstatfs associated with it which is updated as events occur; this function | |
1110 | returns a pointer to it. Note that the data in the structure will continue to change over time and also that it may | |
5ba3f43e | 1111 | be quite stale if vfs_update_vfsstat has not been called recently. |
b0d623f7 A |
1112 | @param mp Mount for which to get vfsstatfs pointer. |
1113 | @return Pointer to vfsstatfs. | |
1114 | */ | |
39037602 | 1115 | struct vfsstatfs * vfs_statfs(mount_t mp); |
2d21ac55 A |
1116 | #define VFS_USER_EVENT 0 |
1117 | #define VFS_KERNEL_EVENT 1 | |
b0d623f7 A |
1118 | |
1119 | /*! | |
1120 | @function vfs_update_vfsstat | |
1121 | @abstract Update cached filesystem status information in the VFS mount structure. | |
1122 | @discussion Each filesystem has a struct vfsstatfs associated with it which is updated as events occur; this function | |
1123 | updates it so that the structure pointer returned by vfs_statfs() returns a pointer to fairly recent data. | |
1124 | @param mp Mount for which to update cached status information. | |
1125 | @param ctx Context to authenticate against for call down to filesystem. | |
1126 | @param eventtype VFS_USER_EVENT: need for update is driven by user-level request; perform additional authentication. | |
1127 | VFS_KERNEL_EVENT: need for update is driven by in-kernel events. Skip extra authentication. | |
1128 | @return 0 for success, or an error code for authentication failure or problem with call to filesystem to | |
1129 | request information. | |
1130 | */ | |
39037602 | 1131 | int vfs_update_vfsstat(mount_t mp, vfs_context_t ctx, int eventtype); |
91447636 | 1132 | |
b0d623f7 A |
1133 | /*! |
1134 | @function vfs_typenum | |
1135 | @abstract Get (archaic) filesystem type number. | |
1136 | @discussion Filesystem type numbers are an old construct; most filesystems just get a number assigned based on | |
1137 | the order in which they are registered with the system. | |
1138 | @param mp Mount for which to get type number. | |
1139 | @return Type number. | |
1140 | */ | |
39037602 | 1141 | int vfs_typenum(mount_t mp); |
b0d623f7 A |
1142 | |
1143 | /*! | |
1144 | @function vfs_name | |
1145 | @abstract Copy filesystem name into a buffer. | |
1146 | @discussion Get filesystem name; this refers to the filesystem type of which a mount is an instantiation, | |
1147 | rather than a name specific to the mountpoint. | |
1148 | @param mp Mount for which to get name. | |
1149 | @param buffer Destination for name; length should be at least MFSNAMELEN. | |
b0d623f7 | 1150 | */ |
39037602 | 1151 | void vfs_name(mount_t mp, char *buffer); |
b0d623f7 A |
1152 | |
1153 | /*! | |
1154 | @function vfs_devblocksize | |
1155 | @abstract Get the block size of the device underlying a mount. | |
1156 | @param mp Mount for which to get block size. | |
1157 | @return Block size. | |
1158 | */ | |
39037602 | 1159 | int vfs_devblocksize(mount_t mp); |
b0d623f7 A |
1160 | |
1161 | /*! | |
1162 | @function vfs_ioattr | |
1163 | @abstract Get I/O attributes associated with a mounpoint. | |
1164 | @param mp Mount for which to get attributes. If NULL, system defaults are filled into ioattrp. | |
1165 | @param ioattrp Destination for results. | |
b0d623f7 | 1166 | */ |
39037602 | 1167 | void vfs_ioattr(mount_t mp, struct vfsioattr *ioattrp); |
b0d623f7 A |
1168 | |
1169 | /*! | |
1170 | @function vfs_setioattr | |
1171 | @abstract Set I/O attributes associated with a mounpoint. | |
1172 | @param mp Mount for which to set attributes. | |
1173 | @param ioattrp Structure containing I/O parameters; all fields must be filled in. | |
b0d623f7 | 1174 | */ |
39037602 | 1175 | void vfs_setioattr(mount_t mp, struct vfsioattr *ioattrp); |
b0d623f7 A |
1176 | |
1177 | /*! | |
1178 | @function vfs_64bitready | |
1179 | @abstract Check if the filesystem associated with a mountpoint is marked ready for interaction with 64-bit user processes. | |
1180 | @param mp Mount to test. | |
1181 | @return Nonzero if filesystem is ready for 64-bit; 0 otherwise. | |
1182 | */ | |
39037602 | 1183 | int vfs_64bitready(mount_t mp); |
91447636 A |
1184 | |
1185 | ||
2d21ac55 | 1186 | #define LK_NOWAIT 1 |
b0d623f7 A |
1187 | /*! |
1188 | @function vfs_busy | |
1189 | @abstract "Busy" a mountpoint. | |
1190 | @discussion vfs_busy() will "busy" a mountpoint, preventing unmounts from taking off, by taking its reader-writer lock | |
1191 | in a shared manner. If a mount is dead, | |
1192 | it will fail; if an unmount is in progress, depending on flags, it will either fail immediately or block | |
1193 | until the unmount completes (then failing if the unmount has succeeded, or potentially succeeding if unmounting failed). | |
1194 | A successful vfs_busy() must be followed by a vfs_unbusy() to release the lock on the mount. | |
1195 | @param mp Mount to busy. | |
1196 | @param flags LK_NOWAIT: fail with ENOENT if an unmount is in progress. | |
1197 | @return 0 for success, with a lock held; an error code otherwise, with no lock held. | |
1198 | */ | |
39037602 | 1199 | int vfs_busy(mount_t mp, int flags); |
b0d623f7 A |
1200 | |
1201 | /*! | |
1202 | @function vfs_unbusy | |
1203 | @abstract "Unbusy" a mountpoint by releasing its read-write lock. | |
1204 | @discussion A successful vfs_busy() must be followed by a vfs_unbusy() to release the lock on the mount. | |
1205 | @param mp Mount to unbusy. | |
b0d623f7 | 1206 | */ |
39037602 | 1207 | void vfs_unbusy(mount_t mp); |
91447636 | 1208 | |
b0d623f7 A |
1209 | /*! |
1210 | @function vfs_getnewfsid | |
1211 | @abstract Generate a unique filesystem ID for a mount and store it in the mount structure. | |
1212 | @discussion Filesystem IDs are returned as part of "struct statfs." This function is typically | |
1213 | called as part of file-system specific mount code (i.e. through VFS_MOUNT). | |
1214 | @param mp Mount to set an ID for. | |
b0d623f7 | 1215 | */ |
39037602 | 1216 | void vfs_getnewfsid(struct mount *mp); |
b0d623f7 A |
1217 | |
1218 | /*! | |
1219 | @function vfs_getvfs | |
1220 | @abstract Given a filesystem ID, look up a mount structure. | |
1221 | @param fsid Filesystem ID to look up. | |
1222 | @return Mountpoint if found, else NULL. Note unmounting mountpoints can be returned. | |
1223 | */ | |
39037602 | 1224 | mount_t vfs_getvfs(fsid_t *fsid); |
b0d623f7 A |
1225 | |
1226 | /*! | |
1227 | @function vfs_mountedon | |
1228 | @abstract Check whether a given block device has a filesystem mounted on it. | |
1229 | @discussion Note that this is NOT a check for a covered vnode (the directory upon which | |
1230 | a filesystem is mounted)--it is a test for whether a block device is being used as the source | |
1231 | of a filesystem. Note that a block device marked as being mounted on cannot be opened. | |
1232 | @param vp The vnode to test. | |
1233 | @return EBUSY if vnode is indeed the source of a filesystem; 0 if it is not. | |
1234 | */ | |
39037602 | 1235 | int vfs_mountedon(struct vnode *vp); |
b0d623f7 A |
1236 | |
1237 | /*! | |
1238 | @function vfs_unmountbyfsid | |
1239 | @abstract Find a filesystem by ID and unmount it. | |
1240 | @param fsid ID of filesystem to unmount, as found through (for example) statfs. | |
1241 | @param flags MNT_FORCE: forcibly invalidate files open on the mount (though in-flight I/O operations | |
1242 | will be allowed to complete). | |
1243 | @param ctx Context against which to authenticate unmount operation. | |
1244 | @return 0 for succcess, nonero for failure. | |
1245 | */ | |
39037602 | 1246 | int vfs_unmountbyfsid(fsid_t *fsid, int flags, vfs_context_t ctx); |
91447636 | 1247 | |
b0d623f7 A |
1248 | /*! |
1249 | @function vfs_event_signal | |
1250 | @abstract Post a kqueue-style event on a filesystem (EVFILT_FS). | |
1251 | @param fsid Unused. | |
1252 | @param event Events to post. | |
1253 | @param data Unused. | |
b0d623f7 | 1254 | */ |
39037602 A |
1255 | void vfs_event_signal(fsid_t *fsid, u_int32_t event, intptr_t data); |
1256 | ||
b0d623f7 A |
1257 | /*! |
1258 | @function vfs_event_init | |
1259 | @abstract This function should not be called by kexts. | |
1260 | */ | |
1261 | void vfs_event_init(void); /* XXX We should not export this */ | |
39037602 | 1262 | |
5ba3f43e A |
1263 | /*! |
1264 | @function vfs_set_root_unmount_cleanly | |
1265 | @abstract This function should be called by the root file system | |
1266 | when it is being mounted if the file system state is consistent. | |
1267 | */ | |
1268 | void vfs_set_root_unmounted_cleanly(void); | |
1269 | ||
b0d623f7 | 1270 | #ifdef KERNEL_PRIVATE |
6d2010ae | 1271 | int vfs_getbyid(fsid_t *fsid, ino64_t ino, vnode_t *vpp, vfs_context_t ctx); |
b0d623f7 A |
1272 | int vfs_getattr(mount_t mp, struct vfs_attr *vfa, vfs_context_t ctx); |
1273 | int vfs_setattr(mount_t mp, struct vfs_attr *vfa, vfs_context_t ctx); | |
1274 | int vfs_extendedsecurity(mount_t); | |
1275 | mount_t vfs_getvfs_by_mntonname(char *); | |
b0d623f7 | 1276 | vnode_t vfs_vnodecovered(mount_t mp); /* Returns vnode with an iocount that must be released with vnode_put() */ |
6d2010ae | 1277 | vnode_t vfs_devvp(mount_t mp); /* Please see block comment with implementation */ |
39236c6e | 1278 | int vfs_nativexattrs (mount_t mp); /* whether or not the FS supports EAs natively */ |
6d2010ae | 1279 | void * vfs_mntlabel(mount_t mp); /* Safe to cast to "struct label*"; returns "void*" to limit dependence of mount.h on security headers. */ |
6d2010ae A |
1280 | void vfs_setcompoundopen(mount_t mp); |
1281 | uint64_t vfs_throttle_mask(mount_t mp); | |
39037602 | 1282 | int vfs_isswapmount(mount_t mp); |
6d2010ae A |
1283 | |
1284 | struct vnode_trigger_info; | |
1285 | ||
1286 | /*! | |
1287 | @function vfs_addtrigger | |
1288 | @abstract Create an "external" trigger vnode: look up a vnode and mark it as | |
1289 | a trigger. Can only safely be called in the context of a callback set by | |
1290 | vfs_settriggercallback(). May only be used on a file which is not already | |
1291 | marked as a trigger. | |
1292 | @param relpath Path relative to root of mountpoint at which to mark trigger. | |
1293 | @param vtip Information about trigger; analogous to "vnode_trigger_param" | |
1294 | argument to vnode_create. | |
1295 | @param ctx Authorization context. | |
1296 | */ | |
1297 | int vfs_addtrigger(mount_t mp, const char *relpath, struct vnode_trigger_info *vtip, vfs_context_t ctx); | |
1298 | ||
1299 | ||
1300 | /*! | |
1301 | @enum vfs_trigger_callback_op_t | |
1302 | @abstract Operation to perform after an attempted unmount (successful or otherwise). | |
1303 | @constant VTC_REPLACE Unmount failed: attempt to replace triggers. Only valid | |
1304 | VFS operation to perform in this context is vfs_addtrigger(). | |
1305 | @constant VTC_RELEASE Unmount succeeded: release external triggering context. | |
1306 | */ | |
1307 | typedef enum { | |
1308 | VTC_REPLACE, | |
1309 | VTC_RELEASE | |
1310 | } vfs_trigger_callback_op_t; | |
1311 | ||
1312 | /*! | |
1313 | @typedef vfs_trigger_callback_t | |
1314 | @abstract Callback to be passed to vfs_settriggercallback() and invoked from | |
1315 | unmount context. | |
1316 | @param mp Mountpoint on which unmount is occurring. | |
1317 | @param op Operation (see vfs_trigger_callback_op_t) | |
1318 | @param data Context passed to vfs_settriggercallback() | |
1319 | @param ctx Authorization context in which unmount is occurring. | |
1320 | */ | |
1321 | typedef void vfs_trigger_callback_t(mount_t mp, vfs_trigger_callback_op_t op, void *data, vfs_context_t ctx); | |
1322 | ||
1323 | /*! | |
1324 | @function vfs_settriggercallback | |
1325 | @abstract Install a callback to be called after unmount attempts on a volume, | |
1326 | to restore triggers for failed unmounts and release state for successful ones. | |
1327 | @discussion Installs a callback which will be called in two situations: a | |
1328 | failed unmount where vnodes may have been reclaimed and a successful unmount. | |
1329 | Gives an external trigger-marking entity an opportunity to replace triggers | |
1330 | which may have been reclaimed. The callback can only be installed (not | |
1331 | cleared), and only one callback can be installed. The callback will be called | |
1332 | with a read-write lock held on the mount point; in the VTC_REPLACE case, the | |
1333 | <em>only</em> valid VFS operation to perform in the context of the callback is | |
1334 | vfs_addtrigger() on the mountpoint in question. This rwlock is held in order | |
1335 | to attempt to provide some modicum of coverage from lookups which might find | |
1336 | missing trigger vnodes and receive spurious ENOENTs. Note that this | |
1337 | protection is incomplete--current working directories, or traversals up into a | |
1338 | volume via ".." may still find missing triggers. As of this writing, no | |
1339 | serialization mechanism exists to do better than this. | |
1340 | When the "op" is VTC_RELEASE, the mountpoint is going away, and the only valid | |
1341 | VFS operation is to free the private data pointer if needed. The callback | |
1342 | will be called immediately, with VTC_REPLACE, from vfs_settriggercallback(), | |
1343 | if installation is successful. | |
1344 | @param fsid FSID for filesystem in question. | |
1345 | @param vtc Callback pointer. | |
1346 | @param data Context pointer to be passed to callback. | |
1347 | @param flags Currently unused. | |
1348 | @param ctx Authorization context. | |
1349 | @return 0 for success. EBUSY if a trigger has already been installed. | |
1350 | */ | |
1351 | int vfs_settriggercallback(fsid_t *fsid, vfs_trigger_callback_t vtc, void *data, uint32_t flags, vfs_context_t ctx); | |
1352 | ||
39037602 A |
1353 | /* tags a volume as not supporting extended readdir for NFS exports */ |
1354 | void mount_set_noreaddirext (mount_t); | |
1355 | ||
b0d623f7 | 1356 | #endif /* KERNEL_PRIVATE */ |
91447636 A |
1357 | __END_DECLS |
1358 | ||
1359 | #endif /* KERNEL */ | |
1c79356b | 1360 | |
91447636 A |
1361 | #ifndef KERNEL |
1362 | ||
1363 | /* | |
1364 | * Generic file handle | |
1365 | */ | |
2d21ac55 A |
1366 | #define NFS_MAX_FH_SIZE NFSV4_MAX_FH_SIZE |
1367 | #define NFSV4_MAX_FH_SIZE 128 | |
1368 | #define NFSV3_MAX_FH_SIZE 64 | |
91447636 A |
1369 | #define NFSV2_MAX_FH_SIZE 32 |
1370 | struct fhandle { | |
1371 | int fh_len; /* length of file handle */ | |
1372 | unsigned char fh_data[NFS_MAX_FH_SIZE]; /* file handle value */ | |
1373 | }; | |
1374 | typedef struct fhandle fhandle_t; | |
1c79356b | 1375 | |
1c79356b A |
1376 | |
1377 | __BEGIN_DECLS | |
91447636 | 1378 | int fhopen(const struct fhandle *, int); |
2d21ac55 | 1379 | int fstatfs(int, struct statfs *) __DARWIN_INODE64(fstatfs); |
593a1d5f A |
1380 | #if !__DARWIN_ONLY_64_BIT_INO_T |
1381 | int fstatfs64(int, struct statfs64 *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5,__MAC_10_6,__IPHONE_NA,__IPHONE_NA); | |
1382 | #endif /* !__DARWIN_ONLY_64_BIT_INO_T */ | |
91447636 | 1383 | int getfh(const char *, fhandle_t *); |
2d21ac55 | 1384 | int getfsstat(struct statfs *, int, int) __DARWIN_INODE64(getfsstat); |
593a1d5f A |
1385 | #if !__DARWIN_ONLY_64_BIT_INO_T |
1386 | int getfsstat64(struct statfs64 *, int, int) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5,__MAC_10_6,__IPHONE_NA,__IPHONE_NA); | |
1387 | #endif /* !__DARWIN_ONLY_64_BIT_INO_T */ | |
2d21ac55 | 1388 | int getmntinfo(struct statfs **, int) __DARWIN_INODE64(getmntinfo); |
5ba3f43e A |
1389 | int getmntinfo_r_np(struct statfs **, int) __DARWIN_INODE64(getmntinfo_r_np) |
1390 | __OSX_AVAILABLE(10.13) __IOS_AVAILABLE(11.0) | |
1391 | __TVOS_AVAILABLE(11.0) __WATCHOS_AVAILABLE(4.0); | |
593a1d5f A |
1392 | #if !__DARWIN_ONLY_64_BIT_INO_T |
1393 | int getmntinfo64(struct statfs64 **, int) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5,__MAC_10_6,__IPHONE_NA,__IPHONE_NA); | |
1394 | #endif /* !__DARWIN_ONLY_64_BIT_INO_T */ | |
91447636 | 1395 | int mount(const char *, const char *, int, void *); |
5ba3f43e | 1396 | int fmount(const char *, int, int, void *) __OSX_AVAILABLE(10.13) __IOS_AVAILABLE(11.0) __TVOS_AVAILABLE(11.0) __WATCHOS_AVAILABLE(4.0); |
2d21ac55 | 1397 | int statfs(const char *, struct statfs *) __DARWIN_INODE64(statfs); |
593a1d5f A |
1398 | #if !__DARWIN_ONLY_64_BIT_INO_T |
1399 | int statfs64(const char *, struct statfs64 *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5,__MAC_10_6,__IPHONE_NA,__IPHONE_NA); | |
1400 | #endif /* !__DARWIN_ONLY_64_BIT_INO_T */ | |
91447636 A |
1401 | int unmount(const char *, int); |
1402 | int getvfsbyname(const char *, struct vfsconf *); | |
1c79356b A |
1403 | __END_DECLS |
1404 | ||
1405 | #endif /* KERNEL */ | |
1406 | #endif /* !_SYS_MOUNT_H_ */ |