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