]> git.saurik.com Git - apple/xnu.git/blame - bsd/sys/mount.h
xnu-1228.7.58.tar.gz
[apple/xnu.git] / bsd / sys / mount.h
CommitLineData
1c79356b 1/*
2d21ac55 2 * Copyright (c) 2000-2007 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
A
81#include <sys/queue.h> /* XXX needed for user builds */
82#else
83#include <sys/kernel_types.h>
1c79356b 84#endif
1c79356b
A
85
86typedef struct fsid { int32_t val[2]; } fsid_t; /* file system id type */
87
1c79356b
A
88/*
89 * file system statistics
90 */
91
92#define MFSNAMELEN 15 /* length of fs type name, not inc. null */
2d21ac55 93#define MFSTYPENAMELEN 16 /* length of fs type name including null */
1c79356b
A
94#define MNAMELEN 90 /* length of buffer for returned name */
95
2d21ac55
A
96#define __DARWIN_STRUCT_STATFS64 { \
97 uint32_t f_bsize; /* fundamental file system block size */ \
98 int32_t f_iosize; /* optimal transfer block size */ \
99 uint64_t f_blocks; /* total data blocks in file system */ \
100 uint64_t f_bfree; /* free blocks in fs */ \
101 uint64_t f_bavail; /* free blocks avail to non-superuser */ \
102 uint64_t f_files; /* total file nodes in file system */ \
103 uint64_t f_ffree; /* free file nodes in fs */ \
104 fsid_t f_fsid; /* file system id */ \
105 uid_t f_owner; /* user that mounted the filesystem */ \
106 uint32_t f_type; /* type of filesystem */ \
107 uint32_t f_flags; /* copy of mount exported flags */ \
108 uint32_t f_fssubtype; /* fs sub-type (flavor) */ \
109 char f_fstypename[MFSTYPENAMELEN]; /* fs type name */ \
110 char f_mntonname[MAXPATHLEN]; /* directory on which mounted */ \
111 char f_mntfromname[MAXPATHLEN]; /* mounted filesystem */ \
112 uint32_t f_reserved[8]; /* For future use */ \
113}
114
115struct statfs64 __DARWIN_STRUCT_STATFS64;
116
117#if __DARWIN_64_BIT_INO_T
118
119struct statfs __DARWIN_STRUCT_STATFS64;
120
121#else /* !__DARWIN_64_BIT_INO_T */
122
91447636
A
123/*
124 * LP64 - WARNING - must be kept in sync with struct user_statfs in mount_internal.h.
125 */
1c79356b
A
126struct statfs {
127 short f_otype; /* TEMPORARY SHADOW COPY OF f_type */
128 short f_oflags; /* TEMPORARY SHADOW COPY OF f_flags */
129 long f_bsize; /* fundamental file system block size */
130 long f_iosize; /* optimal transfer block size */
131 long f_blocks; /* total data blocks in file system */
132 long f_bfree; /* free blocks in fs */
133 long f_bavail; /* free blocks avail to non-superuser */
134 long f_files; /* total file nodes in file system */
135 long f_ffree; /* free file nodes in fs */
136 fsid_t f_fsid; /* file system id */
137 uid_t f_owner; /* user that mounted the filesystem */
138 short f_reserved1; /* spare for later */
139 short f_type; /* type of filesystem */
2d21ac55 140 long f_flags; /* copy of mount exported flags */
1c79356b
A
141 long f_reserved2[2]; /* reserved for future use */
142 char f_fstypename[MFSNAMELEN]; /* fs type name */
143 char f_mntonname[MNAMELEN]; /* directory on which mounted */
144 char f_mntfromname[MNAMELEN];/* mounted filesystem */
145#if COMPAT_GETFSSTAT
146 char f_reserved3[0]; /* For alignment */
147 long f_reserved4[0]; /* For future use */
148#else
149 char f_reserved3; /* For alignment */
150 long f_reserved4[4]; /* For future use */
151#endif
152};
153
2d21ac55 154#endif /* __DARWIN_64_BIT_INO_T */
91447636 155
0c530ab8 156#pragma pack(4)
91447636
A
157
158struct vfsstatfs {
159 uint32_t f_bsize; /* fundamental file system block size */
160 size_t f_iosize; /* optimal transfer block size */
161 uint64_t f_blocks; /* total data blocks in file system */
162 uint64_t f_bfree; /* free blocks in fs */
163 uint64_t f_bavail; /* free blocks avail to non-superuser */
164 uint64_t f_bused; /* free blocks avail to non-superuser */
165 uint64_t f_files; /* total file nodes in file system */
166 uint64_t f_ffree; /* free file nodes in fs */
167 fsid_t f_fsid; /* file system id */
168 uid_t f_owner; /* user that mounted the filesystem */
169 uint64_t f_flags; /* copy of mount exported flags */
170 char f_fstypename[MFSTYPENAMELEN];/* fs type name inclus */
171 char f_mntonname[MAXPATHLEN];/* directory on which mounted */
172 char f_mntfromname[MAXPATHLEN];/* mounted filesystem */
173 uint32_t f_fssubtype; /* fs sub-type (flavor) */
174 void *f_reserved[2]; /* For future use == 0 */
175};
176
0c530ab8 177#pragma pack()
91447636 178
2d21ac55
A
179#ifdef KERNEL
180/*
181 * Kernel level support for the VFS_GETATTR(), VFS_SETATTR() for use in
182 * implementation of filesystem KEXTs, and by the vfs_getattr() and
183 * vfs_setattr() KPIs.
184 */
185
91447636
A
186#define VFSATTR_INIT(s) ((s)->f_supported = (s)->f_active = 0LL)
187#define VFSATTR_SET_SUPPORTED(s, a) ((s)->f_supported |= VFSATTR_ ## a)
188#define VFSATTR_IS_SUPPORTED(s, a) ((s)->f_supported & VFSATTR_ ## a)
189#define VFSATTR_CLEAR_ACTIVE(s, a) ((s)->f_active &= ~VFSATTR_ ## a)
190#define VFSATTR_IS_ACTIVE(s, a) ((s)->f_active & VFSATTR_ ## a)
191#define VFSATTR_ALL_SUPPORTED(s) (((s)->f_active & (s)->f_supported) == (s)->f_active)
192#define VFSATTR_WANTED(s, a) ((s)->f_active |= VFSATTR_ ## a)
193#define VFSATTR_RETURN(s, a, x) do { (s)-> a = (x); VFSATTR_SET_SUPPORTED(s, a);} while(0)
194
195#define VFSATTR_f_objcount (1LL<< 0)
196#define VFSATTR_f_filecount (1LL<< 1)
197#define VFSATTR_f_dircount (1LL<< 2)
198#define VFSATTR_f_maxobjcount (1LL<< 3)
199#define VFSATTR_f_bsize (1LL<< 4)
200#define VFSATTR_f_iosize (1LL<< 5)
201#define VFSATTR_f_blocks (1LL<< 6)
202#define VFSATTR_f_bfree (1LL<< 7)
203#define VFSATTR_f_bavail (1LL<< 8)
204#define VFSATTR_f_bused (1LL<< 9)
205#define VFSATTR_f_files (1LL<< 10)
206#define VFSATTR_f_ffree (1LL<< 11)
207#define VFSATTR_f_fsid (1LL<< 12)
208#define VFSATTR_f_owner (1LL<< 13)
209#define VFSATTR_f_capabilities (1LL<< 14)
210#define VFSATTR_f_attributes (1LL<< 15)
211#define VFSATTR_f_create_time (1LL<< 16)
212#define VFSATTR_f_modify_time (1LL<< 17)
213#define VFSATTR_f_access_time (1LL<< 18)
214#define VFSATTR_f_backup_time (1LL<< 19)
215#define VFSATTR_f_fssubtype (1LL<< 20)
216#define VFSATTR_f_vol_name (1LL<< 21)
217#define VFSATTR_f_signature (1LL<< 22)
218#define VFSATTR_f_carbon_fsid (1LL<< 23)
219
1c79356b 220/*
2d21ac55 221 * Argument structure.
1c79356b 222 */
0c530ab8 223#pragma pack(4)
91447636
A
224
225struct vfs_attr {
226 uint64_t f_supported;
227 uint64_t f_active;
228
229 uint64_t f_objcount; /* number of filesystem objects in volume */
230 uint64_t f_filecount; /* ... files */
231 uint64_t f_dircount; /* ... directories */
232 uint64_t f_maxobjcount; /* maximum number of filesystem objects */
233
234 uint32_t f_bsize; /* block size for the below size values */
235 size_t f_iosize; /* optimal transfer block size */
236 uint64_t f_blocks; /* total data blocks in file system */
237 uint64_t f_bfree; /* free blocks in fs */
238 uint64_t f_bavail; /* free blocks avail to non-superuser */
239 uint64_t f_bused; /* blocks in use */
240 uint64_t f_files; /* total file nodes in file system */
241 uint64_t f_ffree; /* free file nodes in fs */
242 fsid_t f_fsid; /* file system id */
243 uid_t f_owner; /* user that mounted the filesystem */
244
245 vol_capabilities_attr_t f_capabilities;
246 vol_attributes_attr_t f_attributes;
247
248 struct timespec f_create_time; /* creation time */
249 struct timespec f_modify_time; /* last modification time */
250 struct timespec f_access_time; /* time of last access */
251 struct timespec f_backup_time; /* last backup time */
252
253 uint32_t f_fssubtype; /* filesystem subtype */
254
255 char *f_vol_name; /* volume name */
256
257 uint16_t f_signature; /* used for ATTR_VOL_SIGNATURE, Carbon's FSVolumeInfo.signature */
258 uint16_t f_carbon_fsid; /* same as Carbon's FSVolumeInfo.filesystemID */
1c79356b 259};
91447636 260
0c530ab8 261#pragma pack()
1c79356b 262
2d21ac55
A
263#endif /* KERNEL */
264
1c79356b
A
265/*
266 * User specifiable flags.
267 *
268 * Unmount uses MNT_FORCE flag.
269 */
270#define MNT_RDONLY 0x00000001 /* read only filesystem */
271#define MNT_SYNCHRONOUS 0x00000002 /* file system written synchronously */
272#define MNT_NOEXEC 0x00000004 /* can't exec from filesystem */
273#define MNT_NOSUID 0x00000008 /* don't honor setuid bits on fs */
274#define MNT_NODEV 0x00000010 /* don't interpret special files */
275#define MNT_UNION 0x00000020 /* union with underlying filesystem */
276#define MNT_ASYNC 0x00000040 /* file system written asynchronously */
1c79356b
A
277
278/*
279 * NFS export related mount flags.
280 */
1c79356b 281#define MNT_EXPORTED 0x00000100 /* file system is exported */
1c79356b 282
2d21ac55
A
283/*
284 * MAC labeled / "quarantined" flag
285 */
286#define MNT_QUARANTINE 0x00000400 /* file system is quarantined */
287
1c79356b
A
288/*
289 * Flags set by internal operations.
290 */
291#define MNT_LOCAL 0x00001000 /* filesystem is stored locally */
292#define MNT_QUOTA 0x00002000 /* quotas are enabled on filesystem */
293#define MNT_ROOTFS 0x00004000 /* identifies the root filesystem */
2d21ac55
A
294#define MNT_DOVOLFS 0x00008000 /* FS supports volfs (deprecated flag in Mac OS X 10.5) */
295
296
297#define MNT_DONTBROWSE 0x00100000 /* file system is not appropriate path to user data */
298#define MNT_IGNORE_OWNERSHIP 0x00200000 /* VFS will ignore ownership information on filesystem objects */
299#define MNT_AUTOMOUNTED 0x00400000 /* filesystem was mounted by automounter */
300#define MNT_JOURNALED 0x00800000 /* filesystem is journaled */
301#define MNT_NOUSERXATTR 0x01000000 /* Don't allow user extended attributes */
302#define MNT_DEFWRITE 0x02000000 /* filesystem should defer writes */
303#define MNT_MULTILABEL 0x04000000 /* MAC support for individual labels */
304#define MNT_NOATIME 0x10000000 /* disable update of file access time */
305
306/* backwards compatibility only */
307#define MNT_UNKNOWNPERMISSIONS MNT_IGNORE_OWNERSHIP
308
1c79356b
A
309
310/*
311 * XXX I think that this could now become (~(MNT_CMDFLAGS))
312 * but the 'mount' program may need changing to handle this.
313 */
314#define MNT_VISFLAGMASK (MNT_RDONLY | MNT_SYNCHRONOUS | MNT_NOEXEC | \
315 MNT_NOSUID | MNT_NODEV | MNT_UNION | \
2d21ac55
A
316 MNT_ASYNC | MNT_EXPORTED | MNT_QUARANTINE | \
317 MNT_LOCAL | MNT_QUOTA | \
1c79356b 318 MNT_ROOTFS | MNT_DOVOLFS | MNT_DONTBROWSE | \
2d21ac55
A
319 MNT_IGNORE_OWNERSHIP | MNT_AUTOMOUNTED | MNT_JOURNALED | \
320 MNT_NOUSERXATTR | MNT_DEFWRITE | MNT_MULTILABEL | MNT_NOATIME)
1c79356b
A
321/*
322 * External filesystem command modifier flags.
323 * Unmount can use the MNT_FORCE flag.
324 * XXX These are not STATES and really should be somewhere else.
325 * External filesystem control flags.
326 */
327#define MNT_UPDATE 0x00010000 /* not a real mount, just an update */
1c79356b
A
328#define MNT_RELOAD 0x00040000 /* reload filesystem data */
329#define MNT_FORCE 0x00080000 /* force unmount or readonly change */
91447636
A
330#define MNT_CMDFLAGS (MNT_UPDATE|MNT_RELOAD|MNT_FORCE)
331
332
1c79356b 333
1c79356b
A
334/*
335 * Sysctl CTL_VFS definitions.
336 *
337 * Second level identifier specifies which filesystem. Second level
338 * identifier VFS_GENERIC returns information about all filesystems.
339 */
340#define VFS_GENERIC 0 /* generic filesystem information */
341#define VFS_NUMMNTOPS 1 /* int: total num of vfs mount/unmount operations */
342/*
343 * Third level identifiers for VFS_GENERIC are given below; third
344 * level identifiers for specific filesystems are given in their
345 * mount specific header files.
346 */
347#define VFS_MAXTYPENUM 1 /* int: highest defined filesystem type */
348#define VFS_CONF 2 /* struct: vfsconf for filesystem given
349 as next argument */
91447636 350#define VFS_SET_PACKAGE_EXTS 3 /* set package extension list */
55e303ae 351
1c79356b
A
352/*
353 * Flags for various system call interfaces.
354 *
355 * waitfor flags to vfs_sync() and getfsstat()
356 */
357#define MNT_WAIT 1 /* synchronously wait for I/O to complete */
358#define MNT_NOWAIT 2 /* start all I/O, but do not wait for it */
359
1c79356b 360
91447636
A
361#ifndef KERNEL
362struct mount;
363typedef struct mount * mount_t;
364struct vnode;
365typedef struct vnode * vnode_t;
366#endif
1c79356b 367
1c79356b
A
368struct vfsconf {
369 struct vfsops *vfc_vfsops; /* filesystem operations vector */
370 char vfc_name[MFSNAMELEN]; /* filesystem type name */
371 int vfc_typenum; /* historic filesystem type number */
372 int vfc_refcount; /* number mounted of this type */
373 int vfc_flags; /* permanent flags */
91447636 374 int (*vfc_mountroot)(mount_t, vnode_t); /* if != NULL, routine to mount root */
1c79356b
A
375 struct vfsconf *vfc_next; /* next in list */
376};
377
55e303ae
A
378struct vfsidctl {
379 int vc_vers; /* should be VFSIDCTL_VERS1 (below) */
380 fsid_t vc_fsid; /* fsid to operate on. */
381 void *vc_ptr; /* pointer to data structure. */
382 size_t vc_len; /* sizeof said structure. */
383 u_int32_t vc_spare[12]; /* spare (must be zero). */
384};
385
91447636 386
55e303ae
A
387/* vfsidctl API version. */
388#define VFS_CTL_VERS1 0x01
389
91447636 390#ifdef KERNEL
91447636
A
391
392/* LP64 version of vfsconf. all pointers
393 * grow when we're dealing with a 64-bit process.
394 * WARNING - keep in sync with vfsconf
395 */
91447636
A
396struct user_vfsconf {
397 user_addr_t vfc_vfsops; /* filesystem operations vector */
398 char vfc_name[MFSNAMELEN]; /* filesystem type name */
399 int vfc_typenum; /* historic filesystem type number */
400 int vfc_refcount; /* number mounted of this type */
401 int vfc_flags; /* permanent flags */
0c530ab8 402 user_addr_t vfc_mountroot __attribute((aligned(8))); /* if != NULL, routine to mount root */
91447636
A
403 user_addr_t vfc_next; /* next in list */
404};
405
406struct user_vfsidctl {
407 int vc_vers; /* should be VFSIDCTL_VERS1 (below) */
408 fsid_t vc_fsid; /* fsid to operate on. */
0c530ab8 409 user_addr_t vc_ptr __attribute((aligned(8))); /* pointer to data structure. */
91447636
A
410 user_size_t vc_len; /* sizeof said structure. */
411 u_int32_t vc_spare[12]; /* spare (must be zero). */
412};
413
91447636
A
414#endif /* KERNEL */
415
55e303ae
A
416/*
417 * New style VFS sysctls, do not reuse/conflict with the namespace for
418 * private sysctls.
419 */
420#define VFS_CTL_STATFS 0x00010001 /* statfs */
421#define VFS_CTL_UMOUNT 0x00010002 /* unmount */
422#define VFS_CTL_QUERY 0x00010003 /* anything wrong? (vfsquery) */
423#define VFS_CTL_NEWADDR 0x00010004 /* reconnect to new address */
424#define VFS_CTL_TIMEO 0x00010005 /* set timeout for vfs notification */
e5568f75 425#define VFS_CTL_NOLOCKS 0x00010006 /* disable file locking */
55e303ae
A
426
427struct vfsquery {
428 u_int32_t vq_flags;
429 u_int32_t vq_spare[31];
430};
431
432/* vfsquery flags */
433#define VQ_NOTRESP 0x0001 /* server down */
434#define VQ_NEEDAUTH 0x0002 /* server bad auth */
435#define VQ_LOWDISK 0x0004 /* we're low on space */
436#define VQ_MOUNT 0x0008 /* new filesystem arrived */
437#define VQ_UNMOUNT 0x0010 /* filesystem has left */
438#define VQ_DEAD 0x0020 /* filesystem is dead, needs force unmount */
91447636 439#define VQ_ASSIST 0x0040 /* filesystem needs assistance from external program */
e5568f75 440#define VQ_NOTRESPLOCK 0x0080 /* server lockd down */
91447636 441#define VQ_UPDATE 0x0100 /* filesystem information has changed */
55e303ae
A
442#define VQ_FLAG0200 0x0200 /* placeholder */
443#define VQ_FLAG0400 0x0400 /* placeholder */
444#define VQ_FLAG0800 0x0800 /* placeholder */
445#define VQ_FLAG1000 0x1000 /* placeholder */
446#define VQ_FLAG2000 0x2000 /* placeholder */
447#define VQ_FLAG4000 0x4000 /* placeholder */
448#define VQ_FLAG8000 0x8000 /* placeholder */
449
55e303ae 450
9bccf70c 451#ifdef KERNEL
1c79356b 452
91447636
A
453/* Structure for setting device IO parameters per mount point */
454struct vfsioattr {
455 u_int32_t io_maxreadcnt; /* Max. byte count for read */
456 u_int32_t io_maxwritecnt; /* Max. byte count for write */
457 u_int32_t io_segreadcnt; /* Max. segment count for read */
458 u_int32_t io_segwritecnt; /* Max. segment count for write */
459 u_int32_t io_maxsegreadsize; /* Max. segment read size */
460 u_int32_t io_maxsegwritesize; /* Max. segment write size */
461 u_int32_t io_devblocksize; /* the underlying device block size */
2d21ac55
A
462 u_int32_t io_flags; /* flags for underlying device */
463 void * io_reserved[2]; /* extended attribute information */
91447636
A
464};
465
2d21ac55 466#define VFS_IOATTR_FLAGS_FUA 0x01 /* Write-through cache supported */
1c79356b
A
467
468/*
91447636 469 * Filesystem Registration information
1c79356b 470 */
2d21ac55
A
471#define VFS_TBLTHREADSAFE 0x0001
472#define VFS_TBLFSNODELOCK 0x0002
473#define VFS_TBLNOTYPENUM 0x0008
474#define VFS_TBLLOCALVOL 0x0010
475#define VFS_TBL64BITREADY 0x0020
476#define VFS_TBLNATIVEXATTR 0x0040
477#define VFS_TBLDIRLINKS 0x0080
478#define VFS_TBLUNMOUNT_PREFLIGHT 0x0100 /* does a preflight check before unmounting */
479#define VFS_TBLGENERICMNTARGS 0x0200 /* force generic mount args for local fs */
480#define VFS_TBLREADDIR_EXTENDED 0x0400 /* fs supports VNODE_READDIR_EXTENDED */
481#define VFS_TBLNOMACLABEL 0x1000
91447636
A
482
483struct vfs_fsentry {
484 struct vfsops * vfe_vfsops; /* vfs operations */
485 int vfe_vopcnt; /* # of vnodeopv_desc being registered (reg, spec, fifo ...) */
486 struct vnodeopv_desc ** vfe_opvdescs; /* null terminated; */
487 int vfe_fstypenum; /* historic filesystem type number */
488 char vfe_fsname[MFSNAMELEN]; /* filesystem type name */
489 uint32_t vfe_flags; /* defines the FS capabilities */
490 void * vfe_reserv[2]; /* reserved for future use; set this to zero*/
491 };
492
493
1c79356b
A
494
495struct vfsops {
91447636
A
496 int (*vfs_mount)(struct mount *mp, vnode_t devvp, user_addr_t data, vfs_context_t context);
497 int (*vfs_start)(struct mount *mp, int flags, vfs_context_t context);
498 int (*vfs_unmount)(struct mount *mp, int mntflags, vfs_context_t context);
499 int (*vfs_root)(struct mount *mp, struct vnode **vpp, vfs_context_t context);
500 int (*vfs_quotactl)(struct mount *mp, int cmds, uid_t uid, caddr_t arg, vfs_context_t context);
501 int (*vfs_getattr)(struct mount *mp, struct vfs_attr *, vfs_context_t context);
502/* int (*vfs_statfs)(struct mount *mp, struct vfsstatfs *sbp, vfs_context_t context);*/
503 int (*vfs_sync)(struct mount *mp, int waitfor, vfs_context_t context);
504 int (*vfs_vget)(struct mount *mp, ino64_t ino, struct vnode **vpp, vfs_context_t context);
505 int (*vfs_fhtovp)(struct mount *mp, int fhlen, unsigned char *fhp, struct vnode **vpp,
506 vfs_context_t context);
507 int (*vfs_vptofh)(struct vnode *vp, int *fhlen, unsigned char *fhp, vfs_context_t context);
508 int (*vfs_init)(struct vfsconf *);
509 int (*vfs_sysctl)(int *, u_int, user_addr_t, size_t *, user_addr_t, size_t, vfs_context_t context);
510 int (*vfs_setattr)(struct mount *mp, struct vfs_attr *, vfs_context_t context);
511 void *vfs_reserved[7];
1c79356b
A
512};
513
1c79356b
A
514
515/*
91447636 516 * flags passed into vfs_iterate
1c79356b 517 */
1c79356b
A
518
519/*
91447636 520 * return values from callback
1c79356b 521 */
91447636
A
522#define VFS_RETURNED 0 /* done with vnode, reference can be dropped */
523#define VFS_RETURNED_DONE 1 /* done with vnode, reference can be dropped, terminate iteration */
524#define VFS_CLAIMED 2 /* don't drop reference */
525#define VFS_CLAIMED_DONE 3 /* don't drop reference, terminate iteration */
1c79356b 526
91447636
A
527
528__BEGIN_DECLS
1c79356b 529/*
91447636 530 * prototypes for exported VFS operations
1c79356b 531 */
91447636
A
532extern int VFS_MOUNT(mount_t, vnode_t, user_addr_t, vfs_context_t);
533extern int VFS_START(mount_t, int, vfs_context_t);
534extern int VFS_UNMOUNT(mount_t, int, vfs_context_t);
535extern int VFS_ROOT(mount_t, vnode_t *, vfs_context_t);
536extern int VFS_QUOTACTL(mount_t, int, uid_t, caddr_t, vfs_context_t);
2d21ac55
A
537extern int VFS_GETATTR(mount_t, struct vfs_attr *, vfs_context_t);
538extern int VFS_SETATTR(mount_t, struct vfs_attr *, vfs_context_t);
91447636
A
539extern int VFS_SYNC(mount_t, int, vfs_context_t);
540extern int VFS_VGET(mount_t, ino64_t, vnode_t *, vfs_context_t);
541extern int VFS_FHTOVP(mount_t, int, unsigned char *, vnode_t *, vfs_context_t);
542extern int VFS_VPTOFH(vnode_t, int *, unsigned char *, vfs_context_t);
543
544/* The file system registrartion KPI */
545int vfs_fsadd(struct vfs_fsentry *, vfstable_t *);
546int vfs_fsremove(vfstable_t);
547int vfs_iterate(int, int (*)(struct mount *, void *), void *);
548
549uint64_t vfs_flags(mount_t);
550void vfs_setflags(mount_t, uint64_t);
551void vfs_clearflags(mount_t, uint64_t);
552
553int vfs_issynchronous(mount_t);
554int vfs_iswriteupgrade(mount_t);
555int vfs_isupdate(mount_t);
556int vfs_isreload(mount_t);
557int vfs_isforce(mount_t);
558int vfs_isrdonly(mount_t);
559int vfs_isrdwr(mount_t);
560int vfs_authopaque(mount_t);
561int vfs_authopaqueaccess(mount_t);
562void vfs_setauthopaque(mount_t);
563void vfs_setauthopaqueaccess(mount_t);
564void vfs_clearauthopaque(mount_t);
565void vfs_clearauthopaqueaccess(mount_t);
566int vfs_extendedsecurity(mount_t);
567void vfs_setextendedsecurity(mount_t);
568void vfs_clearextendedsecurity(mount_t);
569void vfs_setlocklocal(mount_t);
2d21ac55
A
570int vfs_authcache_ttl(mount_t);
571void vfs_setauthcache_ttl(mount_t, int);
572void vfs_clearauthcache_ttl(mount_t);
573void vfs_markdependency(mount_t);
91447636 574
2d21ac55
A
575/*
576 * return value from vfs_cachedrights_ttl if
577 * neither MNTK_AUTH_OPAQUE | MNTK_AUTH_CACHE_TTL
578 * is set in mnt_kern_flag.. it indicates
579 * that no TTL is being applied to the vnode rights cache
580 */
581#define CACHED_RIGHT_INFINITE_TTL ~0
91447636
A
582
583
584uint32_t vfs_maxsymlen(mount_t);
585void vfs_setmaxsymlen(mount_t, uint32_t);
586void * vfs_fsprivate(mount_t);
587void vfs_setfsprivate(mount_t, void *mntdata);
588
589struct vfsstatfs * vfs_statfs(mount_t);
2d21ac55
A
590#define VFS_USER_EVENT 0
591#define VFS_KERNEL_EVENT 1
592int vfs_update_vfsstat(mount_t, vfs_context_t, int eventtype);
91447636
A
593int vfs_getattr(mount_t mp, struct vfs_attr *vfa, vfs_context_t ctx);
594int vfs_setattr(mount_t mp, struct vfs_attr *vfa, vfs_context_t ctx);
595
596int vfs_typenum(mount_t);
597void vfs_name(mount_t, char *);
598int vfs_devblocksize(mount_t);
599void vfs_ioattr(mount_t, struct vfsioattr *);
600void vfs_setioattr(mount_t, struct vfsioattr *);
601int vfs_64bitready(mount_t);
602
603
2d21ac55 604#define LK_NOWAIT 1
91447636
A
605int vfs_busy(mount_t, int);
606void vfs_unbusy(mount_t);
607
608void vfs_getnewfsid(struct mount *);
609mount_t vfs_getvfs(fsid_t *);
2d21ac55 610mount_t vfs_getvfs_by_mntonname(char *);
91447636 611int vfs_mountedon(struct vnode *);
2d21ac55 612int vfs_unmountbyfsid(fsid_t *, int, vfs_context_t);
91447636 613
55e303ae
A
614void vfs_event_signal(fsid_t *, u_int32_t, intptr_t);
615void vfs_event_init(void);
91447636
A
616__END_DECLS
617
618#endif /* KERNEL */
1c79356b 619
91447636
A
620#ifndef KERNEL
621
622/*
623 * Generic file handle
624 */
2d21ac55
A
625#define NFS_MAX_FH_SIZE NFSV4_MAX_FH_SIZE
626#define NFSV4_MAX_FH_SIZE 128
627#define NFSV3_MAX_FH_SIZE 64
91447636
A
628#define NFSV2_MAX_FH_SIZE 32
629struct fhandle {
630 int fh_len; /* length of file handle */
631 unsigned char fh_data[NFS_MAX_FH_SIZE]; /* file handle value */
632};
633typedef struct fhandle fhandle_t;
1c79356b 634
1c79356b
A
635
636__BEGIN_DECLS
91447636 637int fhopen(const struct fhandle *, int);
2d21ac55
A
638int fstatfs(int, struct statfs *) __DARWIN_INODE64(fstatfs);
639int fstatfs64(int, struct statfs64 *);
91447636 640int getfh(const char *, fhandle_t *);
2d21ac55
A
641int getfsstat(struct statfs *, int, int) __DARWIN_INODE64(getfsstat);
642int getfsstat64(struct statfs64 *, int, int);
643int getmntinfo(struct statfs **, int) __DARWIN_INODE64(getmntinfo);
644int getmntinfo64(struct statfs64 **, int);
91447636 645int mount(const char *, const char *, int, void *);
2d21ac55
A
646int statfs(const char *, struct statfs *) __DARWIN_INODE64(statfs);
647int statfs64(const char *, struct statfs64 *);
91447636
A
648int unmount(const char *, int);
649int getvfsbyname(const char *, struct vfsconf *);
1c79356b
A
650__END_DECLS
651
652#endif /* KERNEL */
653#endif /* !_SYS_MOUNT_H_ */