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