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