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