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