1*43a90889SApple OSS Distributions /* 2*43a90889SApple OSS Distributions * Copyright (c) 2000-2020 Apple Computer, 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) 1982, 1986, 1990, 1993, 1994 31*43a90889SApple OSS Distributions * The Regents of the University of California. All rights reserved. 32*43a90889SApple OSS Distributions * (c) UNIX System Laboratories, Inc. 33*43a90889SApple OSS Distributions * All or some portions of this file are derived from material licensed 34*43a90889SApple OSS Distributions * to the University of California by American Telephone and Telegraph 35*43a90889SApple OSS Distributions * Co. or Unix System Laboratories, Inc. and are reproduced herein with 36*43a90889SApple OSS Distributions * the permission of UNIX System Laboratories, Inc. 37*43a90889SApple OSS Distributions * 38*43a90889SApple OSS Distributions * Redistribution and use in source and binary forms, with or without 39*43a90889SApple OSS Distributions * modification, are permitted provided that the following conditions 40*43a90889SApple OSS Distributions * are met: 41*43a90889SApple OSS Distributions * 1. Redistributions of source code must retain the above copyright 42*43a90889SApple OSS Distributions * notice, this list of conditions and the following disclaimer. 43*43a90889SApple OSS Distributions * 2. Redistributions in binary form must reproduce the above copyright 44*43a90889SApple OSS Distributions * notice, this list of conditions and the following disclaimer in the 45*43a90889SApple OSS Distributions * documentation and/or other materials provided with the distribution. 46*43a90889SApple OSS Distributions * 3. All advertising materials mentioning features or use of this software 47*43a90889SApple OSS Distributions * must display the following acknowledgement: 48*43a90889SApple OSS Distributions * This product includes software developed by the University of 49*43a90889SApple OSS Distributions * California, Berkeley and its contributors. 50*43a90889SApple OSS Distributions * 4. Neither the name of the University nor the names of its contributors 51*43a90889SApple OSS Distributions * may be used to endorse or promote products derived from this software 52*43a90889SApple OSS Distributions * without specific prior written permission. 53*43a90889SApple OSS Distributions * 54*43a90889SApple OSS Distributions * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 55*43a90889SApple OSS Distributions * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 56*43a90889SApple OSS Distributions * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 57*43a90889SApple OSS Distributions * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 58*43a90889SApple OSS Distributions * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 59*43a90889SApple OSS Distributions * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 60*43a90889SApple OSS Distributions * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 61*43a90889SApple OSS Distributions * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 62*43a90889SApple OSS Distributions * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 63*43a90889SApple OSS Distributions * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 64*43a90889SApple OSS Distributions * SUCH DAMAGE. 65*43a90889SApple OSS Distributions * 66*43a90889SApple OSS Distributions * @(#)fsctl.h 8.6 (Berkeley) 3/28/94 67*43a90889SApple OSS Distributions */ 68*43a90889SApple OSS Distributions 69*43a90889SApple OSS Distributions #ifndef _SYS_FSCTL_H_ 70*43a90889SApple OSS Distributions #define _SYS_FSCTL_H_ 71*43a90889SApple OSS Distributions 72*43a90889SApple OSS Distributions #include <sys/ioccom.h> 73*43a90889SApple OSS Distributions #include <sys/mount.h> 74*43a90889SApple OSS Distributions 75*43a90889SApple OSS Distributions #ifdef XNU_KERNEL_PRIVATE 76*43a90889SApple OSS Distributions 77*43a90889SApple OSS Distributions /* Userland structs for namespace handler */ 78*43a90889SApple OSS Distributions typedef struct user64_namespace_handler_info { 79*43a90889SApple OSS Distributions user64_addr_t token; 80*43a90889SApple OSS Distributions user64_addr_t flags; 81*43a90889SApple OSS Distributions user64_addr_t fdptr; 82*43a90889SApple OSS Distributions } user64_namespace_handler_info; 83*43a90889SApple OSS Distributions 84*43a90889SApple OSS Distributions typedef struct user32_namespace_handler_info { 85*43a90889SApple OSS Distributions user32_addr_t token; 86*43a90889SApple OSS Distributions user32_addr_t flags; 87*43a90889SApple OSS Distributions user32_addr_t fdptr; 88*43a90889SApple OSS Distributions } user32_namespace_handler_info; 89*43a90889SApple OSS Distributions 90*43a90889SApple OSS Distributions 91*43a90889SApple OSS Distributions /* Kernel-internal of namespace handler info */ 92*43a90889SApple OSS Distributions typedef struct namespace_handler_info { 93*43a90889SApple OSS Distributions user_addr_t token; 94*43a90889SApple OSS Distributions user_addr_t flags; 95*43a90889SApple OSS Distributions user_addr_t fdptr; 96*43a90889SApple OSS Distributions } namespace_handler_info; 97*43a90889SApple OSS Distributions 98*43a90889SApple OSS Distributions 99*43a90889SApple OSS Distributions /* Userland structs for extended namespace handler */ 100*43a90889SApple OSS Distributions typedef struct user64_namespace_handler_info_ext { 101*43a90889SApple OSS Distributions user64_addr_t token; 102*43a90889SApple OSS Distributions user64_addr_t flags; 103*43a90889SApple OSS Distributions user64_addr_t fdptr; 104*43a90889SApple OSS Distributions user64_addr_t infoptr; 105*43a90889SApple OSS Distributions } user64_namespace_handler_info_ext; 106*43a90889SApple OSS Distributions 107*43a90889SApple OSS Distributions typedef struct user32_namespace_handler_info_ext { 108*43a90889SApple OSS Distributions user32_addr_t token; 109*43a90889SApple OSS Distributions user32_addr_t flags; 110*43a90889SApple OSS Distributions user32_addr_t fdptr; 111*43a90889SApple OSS Distributions user32_addr_t infoptr; 112*43a90889SApple OSS Distributions } user32_namespace_handler_info_ext; 113*43a90889SApple OSS Distributions 114*43a90889SApple OSS Distributions 115*43a90889SApple OSS Distributions /* Kernel-internal of extended namespace handler */ 116*43a90889SApple OSS Distributions typedef struct namespace_handler_info_ext { 117*43a90889SApple OSS Distributions user_addr_t token; 118*43a90889SApple OSS Distributions user_addr_t flags; 119*43a90889SApple OSS Distributions user_addr_t fdptr; 120*43a90889SApple OSS Distributions user_addr_t infoptr; 121*43a90889SApple OSS Distributions } namespace_handler_info_ext; 122*43a90889SApple OSS Distributions 123*43a90889SApple OSS Distributions /* Size-Augmented namespace_handler_info */ 124*43a90889SApple OSS Distributions /* 64 bit userland*/ 125*43a90889SApple OSS Distributions typedef struct user64_namespace_handler_data { 126*43a90889SApple OSS Distributions user64_addr_t token; 127*43a90889SApple OSS Distributions user64_addr_t flags; 128*43a90889SApple OSS Distributions user64_addr_t fdptr; 129*43a90889SApple OSS Distributions user64_addr_t infoptr; 130*43a90889SApple OSS Distributions user64_addr_t objid; 131*43a90889SApple OSS Distributions user64_addr_t reserved1; 132*43a90889SApple OSS Distributions user64_addr_t reserved2; 133*43a90889SApple OSS Distributions user64_addr_t reserved3; 134*43a90889SApple OSS Distributions } user64_namespace_handler_data; 135*43a90889SApple OSS Distributions 136*43a90889SApple OSS Distributions /*32 bit userland*/ 137*43a90889SApple OSS Distributions typedef struct user32_namespace_handler_data { 138*43a90889SApple OSS Distributions user32_addr_t token; 139*43a90889SApple OSS Distributions user32_addr_t flags; 140*43a90889SApple OSS Distributions user32_addr_t fdptr; 141*43a90889SApple OSS Distributions user32_addr_t infoptr; 142*43a90889SApple OSS Distributions user32_addr_t objid; 143*43a90889SApple OSS Distributions user32_addr_t reserved1; 144*43a90889SApple OSS Distributions user32_addr_t reserved2; 145*43a90889SApple OSS Distributions user32_addr_t reserved3; 146*43a90889SApple OSS Distributions } user32_namespace_handler_data; 147*43a90889SApple OSS Distributions 148*43a90889SApple OSS Distributions /* kernel-internal */ 149*43a90889SApple OSS Distributions typedef struct namespace_handler_data { 150*43a90889SApple OSS Distributions user_addr_t token; 151*43a90889SApple OSS Distributions user_addr_t flags; 152*43a90889SApple OSS Distributions user_addr_t fdptr; 153*43a90889SApple OSS Distributions user_addr_t infoptr; 154*43a90889SApple OSS Distributions user_addr_t objid; 155*43a90889SApple OSS Distributions user_addr_t reserved1; 156*43a90889SApple OSS Distributions user_addr_t reserved2; 157*43a90889SApple OSS Distributions user_addr_t reserved3; 158*43a90889SApple OSS Distributions } namespace_handler_data; 159*43a90889SApple OSS Distributions 160*43a90889SApple OSS Distributions 161*43a90889SApple OSS Distributions #else 162*43a90889SApple OSS Distributions 163*43a90889SApple OSS Distributions typedef struct namespace_handler_info { 164*43a90889SApple OSS Distributions int32_t *token; 165*43a90889SApple OSS Distributions int64_t *flags; 166*43a90889SApple OSS Distributions int32_t *fdptr; 167*43a90889SApple OSS Distributions } namespace_handler_info; 168*43a90889SApple OSS Distributions 169*43a90889SApple OSS Distributions typedef struct namespace_handler_info_ext { 170*43a90889SApple OSS Distributions int32_t *token; 171*43a90889SApple OSS Distributions int64_t *flags; 172*43a90889SApple OSS Distributions int32_t *fdptr; 173*43a90889SApple OSS Distributions int64_t *infoptr; // for snapshot write events, the kernel puts an offset/length pair here 174*43a90889SApple OSS Distributions } namespace_handler_info_ext; 175*43a90889SApple OSS Distributions 176*43a90889SApple OSS Distributions typedef struct namespace_handler_data { 177*43a90889SApple OSS Distributions int32_t *token; 178*43a90889SApple OSS Distributions int64_t *flags; 179*43a90889SApple OSS Distributions int32_t *fdptr; 180*43a90889SApple OSS Distributions int64_t *infoptr; // for snapshot write events, the kernel puts an offset/length pair here 181*43a90889SApple OSS Distributions int64_t *objid; 182*43a90889SApple OSS Distributions uint32_t *reserved1; 183*43a90889SApple OSS Distributions uint32_t *reserved2; 184*43a90889SApple OSS Distributions uint32_t *reserved3; 185*43a90889SApple OSS Distributions } namespace_handler_data; 186*43a90889SApple OSS Distributions 187*43a90889SApple OSS Distributions #endif /* XNU_KERNEL_PRIVATE */ 188*43a90889SApple OSS Distributions 189*43a90889SApple OSS Distributions #ifdef KERNEL_PRIVATE 190*43a90889SApple OSS Distributions 191*43a90889SApple OSS Distributions #define NSPACE_REARM_NO_ARG ((void *)1) 192*43a90889SApple OSS Distributions int vfs_materialize_file(struct vnode *vp, uint64_t op, int64_t offset, int64_t size); 193*43a90889SApple OSS Distributions int vfs_materialize_dir(struct vnode *vp, uint64_t op, char *file_name, size_t namelen); 194*43a90889SApple OSS Distributions int vfs_materialize_reparent(struct vnode *vp, struct vnode *tdvp); 195*43a90889SApple OSS Distributions 196*43a90889SApple OSS Distributions #endif // defined(KERNEL_PRIVATE) 197*43a90889SApple OSS Distributions 198*43a90889SApple OSS Distributions #define NAMESPACE_HANDLER_READ_OP 0x0001 199*43a90889SApple OSS Distributions #define NAMESPACE_HANDLER_WRITE_OP 0x0002 200*43a90889SApple OSS Distributions #define NAMESPACE_HANDLER_DELETE_OP 0x0004 201*43a90889SApple OSS Distributions #define NAMESPACE_HANDLER_TRUNCATE_OP 0x0008 202*43a90889SApple OSS Distributions #define NAMESPACE_HANDLER_RENAME_OP 0x0010 203*43a90889SApple OSS Distributions #define NAMESPACE_HANDLER_METADATA_WRITE_OP 0x0020 204*43a90889SApple OSS Distributions #define NAMESPACE_HANDLER_METADATA_DELETE_OP 0x0040 205*43a90889SApple OSS Distributions #define NAMESPACE_HANDLER_METADATA_MOD 0x0080 206*43a90889SApple OSS Distributions // #define NAMESPACE_HANDLER_OP_DO_NOT_USE 0x0100 // SNAPSHOT_EVENT uses this value 207*43a90889SApple OSS Distributions #define NAMESPACE_HANDLER_LINK_CREATE 0x0200 208*43a90889SApple OSS Distributions #define NAMESPACE_HANDLER_RENAME_SUCCESS_OP 0x0400 209*43a90889SApple OSS Distributions #define NAMESPACE_HANDLER_RENAME_FAILED_OP 0x0800 210*43a90889SApple OSS Distributions 211*43a90889SApple OSS Distributions #define NAMESPACE_HANDLER_NSPACE_EVENT 0x1000 212*43a90889SApple OSS Distributions #define NAMESPACE_HANDLER_SNAPSHOT_EVENT 0x0100 213*43a90889SApple OSS Distributions #define NAMESPACE_HANDLER_TRACK_EVENT 0x2000 214*43a90889SApple OSS Distributions 215*43a90889SApple OSS Distributions #define NAMESPACE_HANDLER_LOOKUP_OP 0x4000 216*43a90889SApple OSS Distributions 217*43a90889SApple OSS Distributions #define NAMESPACE_HANDLER_EVENT_TYPE_MASK (NAMESPACE_HANDLER_NSPACE_EVENT | NAMESPACE_HANDLER_SNAPSHOT_EVENT | NAMESPACE_HANDLER_TRACK_EVENT) 218*43a90889SApple OSS Distributions 219*43a90889SApple OSS Distributions 220*43a90889SApple OSS Distributions typedef int32_t nspace_handler_info[2]; 221*43a90889SApple OSS Distributions typedef char fstypename_t[MFSTYPENAMELEN]; 222*43a90889SApple OSS Distributions 223*43a90889SApple OSS Distributions #ifdef KERNEL 224*43a90889SApple OSS Distributions 225*43a90889SApple OSS Distributions typedef struct user64_package_ext_info { 226*43a90889SApple OSS Distributions user64_addr_t strings; 227*43a90889SApple OSS Distributions uint32_t num_entries; 228*43a90889SApple OSS Distributions uint32_t max_width; 229*43a90889SApple OSS Distributions } user64_package_ext_info; 230*43a90889SApple OSS Distributions 231*43a90889SApple OSS Distributions typedef struct user32_package_ext_info { 232*43a90889SApple OSS Distributions user32_addr_t strings; 233*43a90889SApple OSS Distributions uint32_t num_entries; 234*43a90889SApple OSS Distributions uint32_t max_width; 235*43a90889SApple OSS Distributions } user32_package_ext_info; 236*43a90889SApple OSS Distributions 237*43a90889SApple OSS Distributions #endif // KERNEL 238*43a90889SApple OSS Distributions 239*43a90889SApple OSS Distributions typedef struct package_ext_info { 240*43a90889SApple OSS Distributions const char *strings; 241*43a90889SApple OSS Distributions uint32_t num_entries; 242*43a90889SApple OSS Distributions uint32_t max_width; 243*43a90889SApple OSS Distributions } package_ext_info; 244*43a90889SApple OSS Distributions 245*43a90889SApple OSS Distributions /* Disk conditioner configuration */ 246*43a90889SApple OSS Distributions typedef struct disk_conditioner_info { 247*43a90889SApple OSS Distributions int enabled; 248*43a90889SApple OSS Distributions uint64_t access_time_usec; // maximum latency until transfer begins 249*43a90889SApple OSS Distributions uint64_t read_throughput_mbps; // maximum throughput for reads 250*43a90889SApple OSS Distributions uint64_t write_throughput_mbps; // maximum throughput for writes 251*43a90889SApple OSS Distributions int is_ssd; // behave like an SSD 252*43a90889SApple OSS Distributions 253*43a90889SApple OSS Distributions /* revision 2 */ 254*43a90889SApple OSS Distributions uint32_t ioqueue_depth; 255*43a90889SApple OSS Distributions uint32_t maxreadcnt; 256*43a90889SApple OSS Distributions uint32_t maxwritecnt; 257*43a90889SApple OSS Distributions uint32_t segreadcnt; 258*43a90889SApple OSS Distributions uint32_t segwritecnt; 259*43a90889SApple OSS Distributions } disk_conditioner_info; 260*43a90889SApple OSS Distributions 261*43a90889SApple OSS Distributions /* 262*43a90889SApple OSS Distributions * BSD flags manipulation arguments. 263*43a90889SApple OSS Distributions * 264*43a90889SApple OSS Distributions * This provides a safe way to update the BSD flags field of an inode, 265*43a90889SApple OSS Distributions * which has some user components as well as some system components. 266*43a90889SApple OSS Distributions * What it provides is a compare-and-swap operation, whereby the caller 267*43a90889SApple OSS Distributions * fetches what the expected flags are, computes the new set, and then 268*43a90889SApple OSS Distributions * provides the old along with the new. If the old that's provided matches 269*43a90889SApple OSS Distributions * what's actually in the inode, the new value is set. The actual inode 270*43a90889SApple OSS Distributions * value is returned to the caller, and expected == actual is how the 271*43a90889SApple OSS Distributions * caller can determine that the operation succeeded. 272*43a90889SApple OSS Distributions * 273*43a90889SApple OSS Distributions * Some BSD flags (e.g. UF_COMPRESSED) can only be manipulated via this 274*43a90889SApple OSS Distributions * safe mechanism. 275*43a90889SApple OSS Distributions */ 276*43a90889SApple OSS Distributions struct fsioc_cas_bsdflags { 277*43a90889SApple OSS Distributions uint32_t expected_flags; /* [IN] expected flags */ 278*43a90889SApple OSS Distributions uint32_t new_flags; /* [IN] new value to set */ 279*43a90889SApple OSS Distributions uint32_t actual_flags; /* [OUT] the actual flags in inode */ 280*43a90889SApple OSS Distributions }; 281*43a90889SApple OSS Distributions 282*43a90889SApple OSS Distributions #define FSIOC_GRAFT_VERSION 2 283*43a90889SApple OSS Distributions 284*43a90889SApple OSS Distributions /* Grafting flags */ 285*43a90889SApple OSS Distributions #define FSCTL_GRAFT_PRESERVE_MOUNT 0x0001 /* Preserve underlying mount until shutdown */ 286*43a90889SApple OSS Distributions #define FSCTL_GRAFT_ALTERNATE_SHARED_REGION 0x0002 /* Binaries within should use alternate shared region */ 287*43a90889SApple OSS Distributions #define FSCTL_GRAFT_SYSTEM_CONTENT 0x0004 /* Cryptex contains system content */ 288*43a90889SApple OSS Distributions #define FSCTL_GRAFT_PANIC_ON_AUTHFAIL 0x0008 /* On failure to authenticate, panic */ 289*43a90889SApple OSS Distributions #define FSCTL_GRAFT_STRICT_AUTH 0x0010 /* Strict authentication mode */ 290*43a90889SApple OSS Distributions #define FSCTL_GRAFT_PRESERVE_GRAFT 0x0020 /* Preserve graft itself until unmount */ 291*43a90889SApple OSS Distributions 292*43a90889SApple OSS Distributions /* Ungrafting flags */ 293*43a90889SApple OSS Distributions #define FSCTL_UNGRAFT_UNGRAFTALL 0x0001 /* Ungraft all currently grafted filesystems */ 294*43a90889SApple OSS Distributions 295*43a90889SApple OSS Distributions #ifdef KERNEL 296*43a90889SApple OSS Distributions 297*43a90889SApple OSS Distributions typedef struct fsioc_graft_fs { 298*43a90889SApple OSS Distributions uint32_t graft_version; 299*43a90889SApple OSS Distributions uint32_t graft_type; 300*43a90889SApple OSS Distributions uint32_t graft_4cc; 301*43a90889SApple OSS Distributions uint64_t graft_flags; 302*43a90889SApple OSS Distributions uint64_t dir_ino; 303*43a90889SApple OSS Distributions 304*43a90889SApple OSS Distributions void *authentic_manifest; 305*43a90889SApple OSS Distributions size_t authentic_manifest_size; 306*43a90889SApple OSS Distributions void *user_manifest; 307*43a90889SApple OSS Distributions size_t user_manifest_size; 308*43a90889SApple OSS Distributions void *payload; 309*43a90889SApple OSS Distributions size_t payload_size; 310*43a90889SApple OSS Distributions } fsioc_graft_fs_t; 311*43a90889SApple OSS Distributions 312*43a90889SApple OSS Distributions typedef struct fsioc_ungraft_fs { 313*43a90889SApple OSS Distributions uint64_t ungraft_flags; 314*43a90889SApple OSS Distributions } fsioc_ungraft_fs_t; 315*43a90889SApple OSS Distributions 316*43a90889SApple OSS Distributions /* auth fs flags */ 317*43a90889SApple OSS Distributions #define AUTH_FS_ALLOW_UNAUTH_ROOT_HASH 0x0001 /* Allow a sealed volume with an unauthenticated root hash */ 318*43a90889SApple OSS Distributions 319*43a90889SApple OSS Distributions typedef struct fsioc_auth_fs { 320*43a90889SApple OSS Distributions vnode_t authvp; 321*43a90889SApple OSS Distributions uint64_t flags; 322*43a90889SApple OSS Distributions } fsioc_auth_fs_t; 323*43a90889SApple OSS Distributions 324*43a90889SApple OSS Distributions #endif /* KERNEL */ 325*43a90889SApple OSS Distributions 326*43a90889SApple OSS Distributions /* exclave fs filesystem tags */ 327*43a90889SApple OSS Distributions typedef enum { 328*43a90889SApple OSS Distributions EFT_EXCLAVE, 329*43a90889SApple OSS Distributions EFT_SYSTEM, 330*43a90889SApple OSS Distributions EFT_EXCLAVE_MAIN, 331*43a90889SApple OSS Distributions EFT_FS_NUM_TAGS, 332*43a90889SApple OSS Distributions } exclave_fs_tag_t; 333*43a90889SApple OSS Distributions 334*43a90889SApple OSS Distributions typedef struct fsioc_exclave_fs_register { 335*43a90889SApple OSS Distributions uint32_t fs_tag; 336*43a90889SApple OSS Distributions } fsioc_exclave_fs_register_t; 337*43a90889SApple OSS Distributions 338*43a90889SApple OSS Distributions #define FSCTL_SYNC_FULLSYNC (1<<0) /* Flush the data fully to disk, if supported by the filesystem */ 339*43a90889SApple OSS Distributions #define FSCTL_SYNC_WAIT (1<<1) /* Wait for the sync to complete */ 340*43a90889SApple OSS Distributions 341*43a90889SApple OSS Distributions 342*43a90889SApple OSS Distributions #define FSIOC_SYNC_VOLUME _IOW('A', 1, uint32_t) 343*43a90889SApple OSS Distributions #define FSCTL_SYNC_VOLUME IOCBASECMD(FSIOC_SYNC_VOLUME) 344*43a90889SApple OSS Distributions 345*43a90889SApple OSS Distributions #define FSIOC_SET_PACKAGE_EXTS _IOW('A', 2, struct package_ext_info) 346*43a90889SApple OSS Distributions #define FSCTL_SET_PACKAGE_EXTS IOCBASECMD(FSIOC_SET_PACKAGE_EXTS) 347*43a90889SApple OSS Distributions 348*43a90889SApple OSS Distributions /* Unsupported - previously FSIOC_WAIT_FOR_SYNC */ 349*43a90889SApple OSS Distributions #define FSIOC_UNSUPPORTED _IOR('A', 3, int32_t) 350*43a90889SApple OSS Distributions 351*43a90889SApple OSS Distributions /* 4 - 9 was used for NAMESPACE handler operation to support dataless file faults 352*43a90889SApple OSS Distributions * no and no longer user */ 353*43a90889SApple OSS Distributions 354*43a90889SApple OSS Distributions #define FSIOC_SET_FSTYPENAME_OVERRIDE _IOW('A', 10, fstypename_t) 355*43a90889SApple OSS Distributions #define FSCTL_SET_FSTYPENAME_OVERRIDE IOCBASECMD(FSIOC_SET_FSTYPENAME_OVERRIDE) 356*43a90889SApple OSS Distributions 357*43a90889SApple OSS Distributions /* 12 was used for TRACKED_HANDLER_GET which has now been removed 358*43a90889SApple OSS Distributions * as it is no longer used. */ 359*43a90889SApple OSS Distributions 360*43a90889SApple OSS Distributions /* 13 was used for FSIOC_SNAPSHOT_HANDLER_GET_EXT and now been removed */ 361*43a90889SApple OSS Distributions 362*43a90889SApple OSS Distributions /* 14 was used for NAMESPACE_HANDLER_GETDATA which has now been 363*43a90889SApple OSS Distributions * removed as it is no longer used. */ 364*43a90889SApple OSS Distributions 365*43a90889SApple OSS Distributions #define FSIOC_ROUTEFS_SETROUTEID _IO('A', 15) 366*43a90889SApple OSS Distributions #define FSCTL_ROUTEFS_SETROUTEID IOCBASECMD(FSIOC_ROUTEFS_SETROUTEID) 367*43a90889SApple OSS Distributions 368*43a90889SApple OSS Distributions /* ioctls to support SEEK_HOLE SEEK_DATA */ 369*43a90889SApple OSS Distributions #define FSIOC_FIOSEEKHOLE _IOWR('A', 16, off_t) 370*43a90889SApple OSS Distributions #define FSCTL_FIOSEEKHOLE IOCBASECMD(FSIOC_FIOSEEKHOLE) 371*43a90889SApple OSS Distributions #define FSIOC_FIOSEEKDATA _IOWR('A', 17, off_t) 372*43a90889SApple OSS Distributions #define FSCTL_FIOSEEKDATA IOCBASECMD(FSIOC_FIOSEEKDATA) 373*43a90889SApple OSS Distributions 374*43a90889SApple OSS Distributions /* Disk conditioner */ 375*43a90889SApple OSS Distributions #define DISK_CONDITIONER_IOC_GET _IOR('A', 18, disk_conditioner_info) 376*43a90889SApple OSS Distributions #define DISK_CONDITIONER_FSCTL_GET IOCBASECMD(DISK_CONDITIONER_IOC_GET) 377*43a90889SApple OSS Distributions #define DISK_CONDITIONER_IOC_SET _IOW('A', 19, disk_conditioner_info) 378*43a90889SApple OSS Distributions #define DISK_CONDITIONER_FSCTL_SET IOCBASECMD(DISK_CONDITIONER_IOC_SET) 379*43a90889SApple OSS Distributions 380*43a90889SApple OSS Distributions /* Set the value of a file's BSD flags in a safe way. */ 381*43a90889SApple OSS Distributions #define FSIOC_CAS_BSDFLAGS _IOWR('A', 20, struct fsioc_cas_bsdflags) 382*43a90889SApple OSS Distributions 383*43a90889SApple OSS Distributions /* Check if a file is only open once (pass zero for the extra arg) */ 384*43a90889SApple OSS Distributions #define FSIOC_FD_ONLY_OPEN_ONCE _IOWR('A', 21, uint32_t) 385*43a90889SApple OSS Distributions 386*43a90889SApple OSS Distributions #ifdef KERNEL 387*43a90889SApple OSS Distributions 388*43a90889SApple OSS Distributions /* Graft a filesystem onto a directory in its parent filesystem */ 389*43a90889SApple OSS Distributions #define FSIOC_GRAFT_FS _IOW('A', 22, fsioc_graft_fs_t) 390*43a90889SApple OSS Distributions 391*43a90889SApple OSS Distributions /* Ungraft filesystem(s) */ 392*43a90889SApple OSS Distributions #define FSIOC_UNGRAFT_FS _IOW('A', 23, fsioc_ungraft_fs_t) 393*43a90889SApple OSS Distributions 394*43a90889SApple OSS Distributions /* Check if a file is on an authenticated volume/Cryptex */ 395*43a90889SApple OSS Distributions #define FSIOC_AUTH_FS _IOW('A', 24, fsioc_auth_fs_t) 396*43a90889SApple OSS Distributions 397*43a90889SApple OSS Distributions #endif /* KERNEL */ 398*43a90889SApple OSS Distributions 399*43a90889SApple OSS Distributions /* Register an exclave fs base directory */ 400*43a90889SApple OSS Distributions #define FSIOC_EXCLAVE_FS_REGISTER _IOW('A', 25, fsioc_exclave_fs_register_t) 401*43a90889SApple OSS Distributions 402*43a90889SApple OSS Distributions /* Unregister an exclave fs base directory (pass zero for the extra arg) */ 403*43a90889SApple OSS Distributions #define FSIOC_EXCLAVE_FS_UNREGISTER _IOW('A', 26, uint32_t) 404*43a90889SApple OSS Distributions 405*43a90889SApple OSS Distributions typedef struct { 406*43a90889SApple OSS Distributions uint32_t fs_tag; // exclave fs tag associated with base directory 407*43a90889SApple OSS Distributions fsid_t fsid; // fsid of volume which contains base directory 408*43a90889SApple OSS Distributions uint64_t base_dir; // inode number of base directory 409*43a90889SApple OSS Distributions uint64_t graft_file; // inode number of graft file (0 if not a graft) 410*43a90889SApple OSS Distributions } exclave_fs_base_dir_t; 411*43a90889SApple OSS Distributions 412*43a90889SApple OSS Distributions typedef struct { 413*43a90889SApple OSS Distributions uint32_t count; // input: number of records that can be written to output buffer 414*43a90889SApple OSS Distributions // output: if output buffer is null, number of registered base dirs 415*43a90889SApple OSS Distributions // if non-null, number of entries written to base_dirs buffer 416*43a90889SApple OSS Distributions exclave_fs_base_dir_t *base_dirs; // output buffer (base directory entries) 417*43a90889SApple OSS Distributions } exclave_fs_get_base_dirs_t; 418*43a90889SApple OSS Distributions 419*43a90889SApple OSS Distributions #define EXCLAVE_FS_GET_BASE_DIRS_MAX_COUNT (10 * 1024) 420*43a90889SApple OSS Distributions 421*43a90889SApple OSS Distributions #define FSIOC_EXCLAVE_FS_GET_BASE_DIRS _IOWR('A', 27, exclave_fs_get_base_dirs_t) 422*43a90889SApple OSS Distributions 423*43a90889SApple OSS Distributions typedef struct { 424*43a90889SApple OSS Distributions uint64_t gi_graft_file; // inode number of graft file 425*43a90889SApple OSS Distributions uint64_t gi_graft_dir; // inode number of graft directory 426*43a90889SApple OSS Distributions uint64_t gi_inum_base; // base of inode range allocated to graft 427*43a90889SApple OSS Distributions uint64_t gi_inum_len:56; // length of inode range allocated to graft 428*43a90889SApple OSS Distributions uint64_t gi_graft_lut_reduction:8; // reduction in lut size when switching to metadata based (in percents) 429*43a90889SApple OSS Distributions uint64_t gi_graft_flags; // FSCTL_GRAFT_* flags from bsd/sys/fsctl.h 430*43a90889SApple OSS Distributions } fsioc_graft_info_t; 431*43a90889SApple OSS Distributions 432*43a90889SApple OSS Distributions typedef struct { 433*43a90889SApple OSS Distributions uint16_t ggi_count; // input: number of records that can be written to output buffer 434*43a90889SApple OSS Distributions // output: if output buffer is null, number of grafts in volume 435*43a90889SApple OSS Distributions // if non-null, number of records written to buffer 436*43a90889SApple OSS Distributions uint16_t ggi_graft_index; // output: if inode is in a graft and buffer is not null, 437*43a90889SApple OSS Distributions // the index of the graft which contains this inode, 0 otherwise 438*43a90889SApple OSS Distributions uint8_t ggi_is_in_graft; // output: 1 if inode in a graft, 0 otherwise 439*43a90889SApple OSS Distributions uint8_t ggi_padding[3]; // padding, should be zero 440*43a90889SApple OSS Distributions #ifdef KERNEL 441*43a90889SApple OSS Distributions user64_addr_t ggi_buffer; // graft info records buffer 442*43a90889SApple OSS Distributions #else 443*43a90889SApple OSS Distributions void *ggi_buffer; 444*43a90889SApple OSS Distributions #if __SIZEOF_POINTER__ == 4 445*43a90889SApple OSS Distributions uint32_t padding; 446*43a90889SApple OSS Distributions #endif 447*43a90889SApple OSS Distributions #endif 448*43a90889SApple OSS Distributions } fsioc_get_graft_info_t; 449*43a90889SApple OSS Distributions 450*43a90889SApple OSS Distributions /* This used to be defined in APFS, we keep the group as 'J' for backward compatability */ 451*43a90889SApple OSS Distributions #define FSIOC_GET_GRAFT_INFO _IOWR('J', 102, fsioc_get_graft_info_t) 452*43a90889SApple OSS Distributions 453*43a90889SApple OSS Distributions // 454*43a90889SApple OSS Distributions // Spotlight and fseventsd use these fsctl()'s to find out 455*43a90889SApple OSS Distributions // the mount time of a volume and the last time it was 456*43a90889SApple OSS Distributions // unmounted. Both HFS and APFS support these calls. 457*43a90889SApple OSS Distributions // 458*43a90889SApple OSS Distributions // NOTE: the values for these defines should _not_ be changed 459*43a90889SApple OSS Distributions // or else it will break binary compatibility with mds 460*43a90889SApple OSS Distributions // and fseventsd. 461*43a90889SApple OSS Distributions // 462*43a90889SApple OSS Distributions #define SPOTLIGHT_IOC_GET_MOUNT_TIME _IOR('h', 18, u_int32_t) 463*43a90889SApple OSS Distributions #define SPOTLIGHT_FSCTL_GET_MOUNT_TIME IOCBASECMD(SPOTLIGHT_IOC_GET_MOUNT_TIME) 464*43a90889SApple OSS Distributions #define SPOTLIGHT_IOC_GET_LAST_MTIME _IOR('h', 19, u_int32_t) 465*43a90889SApple OSS Distributions #define SPOTLIGHT_FSCTL_GET_LAST_MTIME IOCBASECMD(SPOTLIGHT_IOC_GET_LAST_MTIME) 466*43a90889SApple OSS Distributions 467*43a90889SApple OSS Distributions /* Mark file's extents as "frozen" because someone has references to physical address */ 468*43a90889SApple OSS Distributions #define FSIOC_FREEZE_EXTENTS _IO('h', 20) 469*43a90889SApple OSS Distributions #define FSCTL_FREEZE_EXTENTS IOCBASECMD(FSIOC_FREEZE_EXTENTS) 470*43a90889SApple OSS Distributions 471*43a90889SApple OSS Distributions /* Clear the "frozen" status of file's extents */ 472*43a90889SApple OSS Distributions #define FSIOC_THAW_EXTENTS _IO('h', 21) 473*43a90889SApple OSS Distributions #define FSCTL_THAW_EXTENTS IOCBASECMD(FSIOC_THAW_EXTENTS) 474*43a90889SApple OSS Distributions 475*43a90889SApple OSS Distributions /* Selectors on 'h' from 22 -> 49 are defined in HFS repo */ 476*43a90889SApple OSS Distributions 477*43a90889SApple OSS Distributions #define FSIOC_EVAL_ROOTAUTH _IO('h', 50) 478*43a90889SApple OSS Distributions #define FSCTL_EVAL_ROOTAUTH IOCBASECMD(FSIOC_EVAL_ROOTAUTH) 479*43a90889SApple OSS Distributions 480*43a90889SApple OSS Distributions /* This op should only be invoked from within the kernel */ 481*43a90889SApple OSS Distributions #define FSIOC_KERNEL_ROOTAUTH _IOW('h', 51, uint32_t) 482*43a90889SApple OSS Distributions 483*43a90889SApple OSS Distributions #define FIRMLINK_STRUCT_LEN 1032 484*43a90889SApple OSS Distributions typedef struct generic_firmlink { 485*43a90889SApple OSS Distributions uint8_t array[FIRMLINK_STRUCT_LEN]; 486*43a90889SApple OSS Distributions } generic_firmlink_t; 487*43a90889SApple OSS Distributions 488*43a90889SApple OSS Distributions #define FSIOC_FIRMLINK_CTL _IOWR ('J', 60, generic_firmlink_t) 489*43a90889SApple OSS Distributions 490*43a90889SApple OSS Distributions /* For testing /dev/fsevents FSE_ACCESS_GRANTED. */ 491*43a90889SApple OSS Distributions #define FSIOC_TEST_FSE_ACCESS_GRANTED _IO('h', 52) 492*43a90889SApple OSS Distributions 493*43a90889SApple OSS Distributions #ifndef KERNEL 494*43a90889SApple OSS Distributions 495*43a90889SApple OSS Distributions #include <sys/cdefs.h> 496*43a90889SApple OSS Distributions 497*43a90889SApple OSS Distributions __BEGIN_DECLS 498*43a90889SApple OSS Distributions 499*43a90889SApple OSS Distributions int fsctl(const char *, unsigned long, void*, unsigned int); 500*43a90889SApple OSS Distributions int ffsctl(int, unsigned long, void*, unsigned int); 501*43a90889SApple OSS Distributions 502*43a90889SApple OSS Distributions __END_DECLS 503*43a90889SApple OSS Distributions #endif /* !KERNEL */ 504*43a90889SApple OSS Distributions #endif /* !_SYS_FSCTL_H_ */ 505