1 /* 2 * Copyright (c) 2000-2016 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 /* 29 * Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved 30 * Copyright (c) 1992, 1993, 1994, 1995 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 /* 62 * NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce 63 * support for mandatory and extensible security protections. This notice 64 * is included in support of clause 2.2 (b) of the Apple Public License, 65 * Version 2.0. 66 */ 67 68 /* 69 * Warning: This file is generated automatically. 70 * (Modifications made here may easily be lost!) 71 * 72 * Created by the script: 73 * @(#)vnode_if.sh 8.7 (Berkeley) 5/11/95 74 */ 75 76 77 #ifndef _SYS_VNODE_IF_H_ 78 #define _SYS_VNODE_IF_H_ 79 80 #include <sys/appleapiopts.h> 81 #include <sys/cdefs.h> 82 #include <sys/kernel_types.h> 83 #include <sys/buf.h> 84 #ifdef BSD_KERNEL_PRIVATE 85 #include <sys/vm.h> 86 #endif 87 #include <mach/memory_object_types.h> 88 89 90 #pragma clang diagnostic push 91 #pragma clang diagnostic ignored "-Wdocumentation" 92 93 #ifdef KERNEL 94 95 extern struct vnodeop_desc vnop_default_desc; 96 extern struct vnodeop_desc vnop_lookup_desc; 97 #ifdef KERNEL_PRIVATE 98 extern struct vnodeop_desc vnop_compound_open_desc; 99 extern struct vnodeop_desc vnop_compound_remove_desc; 100 extern struct vnodeop_desc vnop_compound_rename_desc; 101 extern struct vnodeop_desc vnop_compound_mkdir_desc; 102 extern struct vnodeop_desc vnop_compound_rmdir_desc; 103 #endif /* KERNEL_PRIVATE */ 104 extern struct vnodeop_desc vnop_create_desc; 105 extern struct vnodeop_desc vnop_whiteout_desc; // obsolete 106 extern struct vnodeop_desc vnop_mknod_desc; 107 extern struct vnodeop_desc vnop_open_desc; 108 extern struct vnodeop_desc vnop_close_desc; 109 extern struct vnodeop_desc vnop_access_desc; 110 extern struct vnodeop_desc vnop_getattr_desc; 111 extern struct vnodeop_desc vnop_setattr_desc; 112 extern struct vnodeop_desc vnop_read_desc; 113 extern struct vnodeop_desc vnop_write_desc; 114 extern struct vnodeop_desc vnop_ioctl_desc; 115 extern struct vnodeop_desc vnop_select_desc; 116 extern struct vnodeop_desc vnop_exchange_desc; 117 extern struct vnodeop_desc vnop_revoke_desc; 118 extern struct vnodeop_desc vnop_mmap_check_desc; 119 extern struct vnodeop_desc vnop_mmap_desc; 120 extern struct vnodeop_desc vnop_mnomap_desc; 121 extern struct vnodeop_desc vnop_fsync_desc; 122 extern struct vnodeop_desc vnop_remove_desc; 123 extern struct vnodeop_desc vnop_link_desc; 124 extern struct vnodeop_desc vnop_rename_desc; 125 extern struct vnodeop_desc vnop_renamex_desc; 126 extern struct vnodeop_desc vnop_mkdir_desc; 127 extern struct vnodeop_desc vnop_rmdir_desc; 128 extern struct vnodeop_desc vnop_symlink_desc; 129 extern struct vnodeop_desc vnop_readdir_desc; 130 extern struct vnodeop_desc vnop_readdirattr_desc; 131 extern struct vnodeop_desc vnop_getattrlistbulk_desc; 132 extern struct vnodeop_desc vnop_readlink_desc; 133 extern struct vnodeop_desc vnop_inactive_desc; 134 extern struct vnodeop_desc vnop_reclaim_desc; 135 extern struct vnodeop_desc vnop_print_desc; 136 extern struct vnodeop_desc vnop_pathconf_desc; 137 extern struct vnodeop_desc vnop_advlock_desc; 138 extern struct vnodeop_desc vnop_truncate_desc; 139 extern struct vnodeop_desc vnop_allocate_desc; 140 extern struct vnodeop_desc vnop_pagein_desc; 141 extern struct vnodeop_desc vnop_pageout_desc; 142 extern struct vnodeop_desc vnop_searchfs_desc; 143 extern struct vnodeop_desc vnop_copyfile_desc; 144 extern struct vnodeop_desc vnop_clonefile_desc; 145 extern struct vnodeop_desc vnop_blktooff_desc; 146 extern struct vnodeop_desc vnop_offtoblk_desc; 147 extern struct vnodeop_desc vnop_blockmap_desc; 148 extern struct vnodeop_desc vnop_strategy_desc; 149 extern struct vnodeop_desc vnop_bwrite_desc; 150 extern struct vnodeop_desc vnop_monitor_desc; 151 #ifdef KERNEL_PRIVATE 152 extern struct vnodeop_desc vnop_verify_desc; 153 #endif 154 155 #ifdef __APPLE_API_UNSTABLE 156 157 #if NAMEDSTREAMS 158 extern struct vnodeop_desc vnop_getnamedstream_desc; 159 extern struct vnodeop_desc vnop_makenamedstream_desc; 160 extern struct vnodeop_desc vnop_removenamedstream_desc; 161 #endif 162 163 #endif 164 165 #ifdef KERNEL_PRIVATE 166 /* 167 * This pair of functions register and unregister callout with 168 * buffer_cache_gc() code path. This callout enables underlying 169 * fs to kick off any memory reclamation that would be otherwise 170 * satisfied by buffer_cache_gc(). callout() will be called in the 171 * vm_pageout code path, so precautions should be taken to not 172 * allocate memory or take any locks which might have memory 173 * allocation behind them. callout() can be called with first parameter 174 * set to false, in which case memory reclamation should be 175 * limited in scope. In case of the first parameter set to true, fs 176 * MUST free some memory if possible. Second parameter to the 177 * register function will be passed as a second parameter to the 178 * callout() as is. 179 * fs_buffer_cache_gc_unregister() second parameter will be used 180 * to distinguish between same callout() and this parameter should 181 * match the one passed during registration. It will unregister all 182 * instances of the matching callout() and argument from the callout 183 * list. 184 */ 185 186 187 extern int fs_buffer_cache_gc_register(void (* callout)(int, void *), void *); 188 extern int fs_buffer_cache_gc_unregister(void (* callout)(int, void *), void *); 189 #endif 190 191 __BEGIN_DECLS 192 193 struct vnop_lookup_args { 194 struct vnodeop_desc *a_desc; 195 vnode_t a_dvp; 196 vnode_t *a_vpp; 197 struct componentname *a_cnp; 198 vfs_context_t a_context; 199 }; 200 201 /*! 202 * @function VNOP_LOOKUP 203 * @abstract Call down to a filesystem to look for a directory entry by name. 204 * @discussion VNOP_LOOKUP is the key pathway through which VFS asks a filesystem to find a file. The vnode 205 * should be returned with an iocount to be dropped by the caller. A VNOP_LOOKUP() calldown can come without 206 * a preceding VNOP_OPEN(). 207 * @param dvp Directory in which to look up file. 208 * @param vpp Destination for found vnode. 209 * @param cnp Structure describing filename to find, reason for lookup, and various other data. 210 * @param ctx Context against which to authenticate lookup request. 211 * @return 0 for success or a filesystem-specific error. 212 */ 213 #ifdef XNU_KERNEL_PRIVATE 214 extern errno_t VNOP_LOOKUP(vnode_t, vnode_t *, struct componentname *, vfs_context_t); 215 #endif /* XNU_KERNEL_PRIVATE */ 216 217 struct vnop_create_args { 218 struct vnodeop_desc *a_desc; 219 vnode_t a_dvp; 220 vnode_t *a_vpp; 221 struct componentname *a_cnp; 222 struct vnode_attr *a_vap; 223 vfs_context_t a_context; 224 }; 225 226 /*! 227 * @function VNOP_CREATE 228 * @abstract Call down to a filesystem to create a regular file (VREG). 229 * @discussion If file creation succeeds, "vpp" should be returned with an iocount to be dropped by the caller. 230 * A VNOP_CREATE() calldown can come without a preceding VNOP_OPEN(). 231 * @param dvp Directory in which to create file. 232 * @param vpp Destination for vnode for newly created file. 233 * @param cnp Description of filename to create. 234 * @param vap File creation properties, as seen in vnode_getattr(). Manipulated with VATTR_ISACTIVE, VATTR_RETURN, 235 * VATTR_SET_SUPPORTED, and so forth. 236 * @param ctx Context against which to authenticate file creation. 237 * @return 0 for success or a filesystem-specific error. 238 */ 239 #ifdef XNU_KERNEL_PRIVATE 240 extern errno_t VNOP_CREATE(vnode_t, vnode_t *, struct componentname *, struct vnode_attr *, vfs_context_t); 241 #endif /* XNU_KERNEL_PRIVATE */ 242 243 struct vnop_whiteout_args { 244 struct vnodeop_desc *a_desc; 245 vnode_t a_dvp; 246 struct componentname *a_cnp; 247 int a_flags; 248 vfs_context_t a_context; 249 }; 250 251 /*! 252 * @function VNOP_WHITEOUT 253 * @abstract Obsolete - no longer supported. 254 * @discussion Whiteouts are used to support the union filesystem, whereby one filesystem is mounted "transparently" 255 * on top of another. A whiteout in the upper layer of a union mount is a "deletion" of a file in the lower layer; 256 * lookups will catch the whiteout and fail, setting ISWHITEOUT in the componentname structure, even if an underlying 257 * file of the same name exists. The whiteout vnop is used for creation, deletion, and checking whether a directory 258 * supports whiteouts (see flags). 259 * also support the LOOKUP flag, which is used to test whether a directory supports whiteouts. 260 * @param dvp Directory in which to create. 261 * @param cnp Name information for whiteout. 262 * @param flags CREATE: create a whiteout. LOOKUP: check whether a directory supports whiteouts, DELETE: remove a whiteout. 263 * @param ctx Context against which to authenticate whiteout creation. 264 * @return 0 for success or a filesystem-specific error. Returning 0 for LOOKUP indicates that a directory does support whiteouts. 265 */ 266 #ifdef XNU_KERNEL_PRIVATE 267 extern errno_t VNOP_WHITEOUT(vnode_t, struct componentname *, int, vfs_context_t); 268 #endif /* XNU_KERNEL_PRIVATE */ 269 270 struct vnop_mknod_args { 271 struct vnodeop_desc *a_desc; 272 vnode_t a_dvp; 273 vnode_t *a_vpp; 274 struct componentname *a_cnp; 275 struct vnode_attr *a_vap; 276 vfs_context_t a_context; 277 }; 278 279 /*! 280 * @function VNOP_MKNOD 281 * @abstract Call down to a filesystem to create a special file. 282 * @discussion The mknod vnop is used to create character and block device files, named pipe (FIFO) files, and named sockets. 283 * The newly created file should be returned with an iocount which will be dropped by the caller. A VNOP_MKNOD() call 284 * can come down without a preceding VNOP_OPEN(). 285 * @param dvp Directory in which to create the special file. 286 * @param vpp Destination for newly created vnode. 287 * @param cnp Name information for new file. 288 * @param vap Attributes for new file, including type. 289 * @param ctx Context against which to authenticate node creation. 290 * @return 0 for success or a filesystem-specific error. 291 */ 292 #ifdef XNU_KERNEL_PRIVATE 293 extern errno_t VNOP_MKNOD(vnode_t, vnode_t *, struct componentname *, struct vnode_attr *, vfs_context_t); 294 #endif /* XNU_KERNEL_PRIVATE */ 295 296 struct vnop_open_args { 297 struct vnodeop_desc *a_desc; 298 vnode_t a_vp; 299 int a_mode; 300 vfs_context_t a_context; 301 }; 302 303 #ifdef KERNEL_PRIVATE 304 struct vnop_compound_open_args { 305 struct vnodeop_desc *a_desc; 306 307 vnode_t a_dvp; /* Directory in which to open/create */ 308 vnode_t *a_vpp; /* Resulting vnode */ 309 int a_fmode; /* Open mode */ 310 struct componentname *a_cnp; /* Path to look up */ 311 struct vnode_attr *a_vap; /* Attributes with which to create, if appropriate */ 312 uint32_t a_flags; /* VNOP-control flags */ 313 uint32_t *a_status; /* Information about results */ 314 315 vfs_context_t a_context; /* Authorization context */ 316 317 int (*a_open_create_authorizer)( /* Authorizer for create case */ 318 vnode_t dvp, /* Directory in which to create */ 319 struct componentname *cnp, /* As passed to VNOP */ 320 struct vnode_attr *vap, /* As passed to VNOP */ 321 vfs_context_t ctx, /* Context */ 322 void *reserved); /* Who knows */ 323 324 int (*a_open_existing_authorizer)( /* Authorizer for preexisting case */ 325 vnode_t vp, /* vp to open */ 326 struct componentname *cnp, /* Lookup state */ 327 int fmode, /* As passed to VNOP */ 328 vfs_context_t ctx, /* Context */ 329 void *reserved); /* Who knows */ 330 331 void *a_reserved; 332 }; 333 334 /* Results */ 335 #define COMPOUND_OPEN_STATUS_DID_CREATE 0x00000001 336 #endif /* KERNEL_PRIVATE */ 337 338 /*! 339 * @function VNOP_OPEN 340 * @abstract Call down to a filesystem to open a file. 341 * @discussion The open vnop gives a filesystem a chance to initialize a file for 342 * operations like reading, writing, and ioctls. VFS promises to send down exactly one VNOP_CLOSE() 343 * for each VNOP_OPEN(). 344 * @param vp File to open. 345 * @param mode FREAD and/or FWRITE. 346 * @param ctx Context against which to authenticate open. 347 * @return 0 for success or a filesystem-specific error. 348 */ 349 #ifdef XNU_KERNEL_PRIVATE 350 extern errno_t VNOP_OPEN(vnode_t, int, vfs_context_t); 351 #endif /* XNU_KERNEL_PRIVATE */ 352 353 #ifdef BSD_KERNEL_PRIVATE 354 struct nameidata; 355 extern int VNOP_COMPOUND_OPEN(vnode_t dvp, vnode_t *vpp, struct nameidata *ndp, int32_t flags, int32_t fmode, uint32_t *status, struct vnode_attr *vap, vfs_context_t ctx); 356 #endif 357 358 struct vnop_close_args { 359 struct vnodeop_desc *a_desc; 360 vnode_t a_vp; 361 int a_fflag; 362 vfs_context_t a_context; 363 }; 364 365 /*! 366 * @function VNOP_CLOSE 367 * @abstract Call down to a filesystem to close a file. 368 * @discussion The close vnop gives a filesystem a chance to release state set up 369 * by a VNOP_OPEN(). VFS promises to send down exactly one VNOP_CLOSE() for each VNOP_OPEN(). 370 * @param vp File to close. 371 * @param fflag FREAD and/or FWRITE; in the case of a file opened with open(2), fflag corresponds 372 * to how the file was opened. 373 * @param ctx Context against which to authenticate close. 374 * @return 0 for success or a filesystem-specific error. 375 */ 376 #ifdef XNU_KERNEL_PRIVATE 377 extern errno_t VNOP_CLOSE(vnode_t, int, vfs_context_t); 378 #endif /* XNU_KERNEL_PRIVATE */ 379 380 struct vnop_access_args { 381 struct vnodeop_desc *a_desc; 382 vnode_t a_vp; 383 int a_action; 384 vfs_context_t a_context; 385 }; 386 387 /*! 388 * @function VNOP_ACCESS 389 * @abstract Call down to a filesystem to see if a kauth-style operation is permitted. 390 * @discussion VNOP_ACCESS is currently only called on filesystems which mark themselves 391 * as doing their authentication remotely (vfs_setauthopaque(), vfs_authopaque()). A VNOP_ACCESS() 392 * calldown may come without any preceding VNOP_OPEN(). 393 * @param vp File to authorize action for. 394 * @param action kauth-style action to be checked for permissions, e.g. KAUTH_VNODE_DELETE. 395 * @param ctx Context against which to authenticate action. 396 * @return 0 for success or a filesystem-specific error. 397 */ 398 #ifdef XNU_KERNEL_PRIVATE 399 extern errno_t VNOP_ACCESS(vnode_t, int, vfs_context_t); 400 #endif /* XNU_KERNEL_PRIVATE */ 401 402 struct vnop_getattr_args { 403 struct vnodeop_desc *a_desc; 404 vnode_t a_vp; 405 struct vnode_attr *a_vap; 406 vfs_context_t a_context; 407 }; 408 409 /*! 410 * @function VNOP_GETATTR 411 * @abstract Call down to a filesystem to get vnode attributes. 412 * @discussion Supported attributes ("Yes, I am returning this information") are set with VATTR_SET_SUPPORTED. 413 * Which attributes have been requested is checked with VATTR_IS_ACTIVE. Attributes 414 * are returned with VATTR_RETURN. It is through VNOP_GETATTR that routines like stat() get their information. 415 * A VNOP_GETATTR() calldown may come without any preceding VNOP_OPEN(). 416 * @param vp The vnode whose attributes to get. 417 * @param vap Container for which attributes are requested, which attributes are supported by the filesystem, and attribute values. 418 * @param ctx Context against which to authenticate request for attributes. 419 * @return 0 for success or a filesystem-specific error. VNOP_GETATTR() can return success even if not 420 * all requested attributes were returned; returning an error-value should indicate that something went wrong, rather than that 421 * some attribute is not supported. 422 */ 423 #ifdef XNU_KERNEL_PRIVATE 424 extern errno_t VNOP_GETATTR(vnode_t, struct vnode_attr *, vfs_context_t); 425 #endif /* XNU_KERNEL_PRIVATE */ 426 427 struct vnop_setattr_args { 428 struct vnodeop_desc *a_desc; 429 vnode_t a_vp; 430 struct vnode_attr *a_vap; 431 vfs_context_t a_context; 432 }; 433 434 /*! 435 * @function VNOP_SETATTR 436 * @abstract Call down to a filesystem to set vnode attributes. 437 * @discussion Supported attributes ("Yes, I am setting this attribute.") are set with VATTR_SET_SUPPORTED. 438 * Requested attributes are checked with VATTR_IS_ACTIVE. Attribute values are accessed directly through 439 * structure fields. VNOP_SETATTR() is the core of the KPI function vnode_setattr(), which is used by chmod(), 440 * chown(), truncate(), and many others. A VNOP_SETATTR() call may come without any preceding VNOP_OPEN(). 441 * @param vp The vnode whose attributes to set. 442 * @param vap Container for which attributes are to be set and their desired values, as well as for the filesystem to 443 * return information about which attributes were successfully set. 444 * @param ctx Context against which to authenticate request for attribute change. 445 * @return 0 for success or a filesystem-specific error. VNOP_SETATTR() can return success even if not 446 * all requested attributes were set; returning an error-value should indicate that something went wrong, rather than that 447 * some attribute is not supported. 448 */ 449 #ifdef XNU_KERNEL_PRIVATE 450 extern errno_t VNOP_SETATTR(vnode_t, struct vnode_attr *, vfs_context_t); 451 #endif /* XNU_KERNEL_PRIVATE */ 452 453 struct vnop_read_args { 454 struct vnodeop_desc *a_desc; 455 vnode_t a_vp; 456 struct uio *a_uio; 457 int a_ioflag; 458 vfs_context_t a_context; 459 }; 460 461 /*! 462 * @function VNOP_READ 463 * @abstract Call down to a filesystem to read file data. 464 * @discussion VNOP_READ() is where the hard work of of the read() system call happens. The filesystem may use 465 * the buffer cache, the cluster layer, or an alternative method to get its data; uio routines will be used to see that data 466 * is copied to the correct virtual address in the correct address space and will update its uio argument 467 * to indicate how much data has been moved. 468 * @param vp The vnode to read from. 469 * @param uio Description of request, including file offset, amount of data requested, destination address for data, 470 * and whether that destination is in kernel or user space. 471 * @param ioflag IO flags as defined in vnode.h, e.g. IO_SYNC, IO_NODELOCKED 472 * @param ctx Context against which to authenticate read request. 473 * @return 0 for success or a filesystem-specific error. VNOP_READ() can return success even if less data was 474 * read than originally requested; returning an error value should indicate that something actually went wrong. 475 */ 476 extern errno_t VNOP_READ(vnode_t vp, struct uio *uio, int ioflag, vfs_context_t ctx); 477 478 struct vnop_write_args { 479 struct vnodeop_desc *a_desc; 480 vnode_t a_vp; 481 struct uio *a_uio; 482 int a_ioflag; 483 vfs_context_t a_context; 484 }; 485 486 /*! 487 * @function VNOP_WRITE 488 * @abstract Call down to the filesystem to write file data. 489 * @discussion VNOP_WRITE() is to write() as VNOP_READ() is to read(). The filesystem may use 490 * the buffer cache, the cluster layer, or an alternative method to write its data; uio routines will be used to see that data 491 * is copied to the correct virtual address in the correct address space and will update its uio argument 492 * to indicate how much data has been moved. 493 * @param vp The vnode to write to. 494 * @param uio Description of request, including file offset, amount of data to write, source address for data, 495 * and whether that destination is in kernel or user space. 496 * @param ioflag IO flags as defined in vnode.h, e.g. IO_SYNC, IO_NODELOCKED 497 * @param ctx Context against which to authenticate write request. 498 * @return 0 for success or a filesystem-specific error. VNOP_WRITE() can return success even if less data was 499 * written than originally requested; returning an error value should indicate that something actually went wrong. 500 */ 501 extern errno_t VNOP_WRITE(vnode_t vp, struct uio *uio, int ioflag, vfs_context_t ctx); 502 503 struct vnop_ioctl_args { 504 struct vnodeop_desc *a_desc; 505 vnode_t a_vp; 506 u_long a_command; 507 caddr_t a_data; 508 int a_fflag; 509 vfs_context_t a_context; 510 }; 511 512 /*! 513 * @function VNOP_IOCTL 514 * @abstract Call down to a filesystem or device driver to execute various control operations on or request data about a file. 515 * @discussion Ioctl controls are typically associated with devices, but they can in fact be passed 516 * down for any file; they are used to implement any of a wide range of controls and information requests. 517 * fcntl() calls VNOP_IOCTL for several commands, and will attempt a VNOP_IOCTL if it is passed an unknown command, 518 * though no copyin or copyout of arguments can occur in this case--the "arg" must be an integer value. 519 * Filesystems can define their own fcntls using this mechanism. How ioctl commands are structured 520 * is slightly complicated; see the manual page for ioctl(2). 521 * @param vp The vnode to execute the command on. 522 * @param command Identifier for action to take. 523 * @param data Pointer to data; this can be an integer constant (of 32 bits only) or an address to be read from or written to, 524 * depending on "command." If it is an address, it is valid and resides in the kernel; callers of VNOP_IOCTL() are 525 * responsible for copying to and from userland. 526 * @param ctx Context against which to authenticate ioctl request. 527 * @return 0 for success or a filesystem-specific error. 528 */ 529 extern errno_t VNOP_IOCTL(vnode_t vp, u_long command, caddr_t data, int fflag, vfs_context_t ctx); 530 531 struct vnop_select_args { 532 struct vnodeop_desc *a_desc; 533 vnode_t a_vp; 534 int a_which; 535 int a_fflags; 536 void *a_wql; 537 vfs_context_t a_context; 538 }; 539 540 /*! 541 * @function VNOP_SELECT 542 * @abstract Call down to a filesystem or device to check if a file is ready for I/O and request later notification if it is not currently ready. 543 * @discussion In general, regular are always "ready for I/O" and their select vnops simply return "1." 544 * Devices, though, may or may not be read; they keep track of who is selecting on them and send notifications 545 * when they become ready. xnu provides structures and routines for tracking threads waiting for I/O and waking up 546 * those threads: see selrecord(), selthreadclear(), seltrue(), selwait(), selwakeup(), and the selinfo structure (sys/select.h). 547 * @param vp The vnode to check for I/O readiness. 548 * @param which What kind of I/O is desired: FREAD, FWRITE. 549 * @param fflags Flags from fileglob as seen in fcntl.h, e.g. O_NONBLOCK, O_APPEND. 550 * @param wql Opaque object to pass to selrecord(). 551 * @param ctx Context to authenticate for select request. 552 * @return Nonzero indicates that a file is ready for I/O. 0 indicates that the file is not ready for I/O; 553 * there is no way to return an error. 0 should be returned if the device (or file) is not ready for I/O 554 * and the driver (or filesystem) is going to track the request and provide subsequent wakeups. 555 * the device (or filesystem) will provide a wakeup. 556 */ 557 #ifdef XNU_KERNEL_PRIVATE 558 extern errno_t VNOP_SELECT(vnode_t, int, int, void *, vfs_context_t); 559 #endif /* XNU_KERNEL_PRIVATE */ 560 561 struct vnop_exchange_args { 562 struct vnodeop_desc *a_desc; 563 vnode_t a_fvp; 564 vnode_t a_tvp; 565 int a_options; 566 vfs_context_t a_context; 567 }; 568 569 /*! 570 * @function VNOP_EXCHANGE 571 * @abstract Call down to a filesystem to atomically exchange the data of two files. 572 * @discussion VNOP_EXCHANGE() is currently only called by the exchangedata() system call. It will only 573 * be applied to files on the same volume. 574 * @param fvp First vnode. 575 * @param tvp Second vnode. 576 * @param options Unused. 577 * @param ctx Context to authenticate for exchangedata request. 578 * @return 0 for success, else an error code. 579 */ 580 #ifdef XNU_KERNEL_PRIVATE 581 extern errno_t VNOP_EXCHANGE(vnode_t, vnode_t, int, vfs_context_t); 582 #endif /* XNU_KERNEL_PRIVATE */ 583 584 struct vnop_revoke_args { 585 struct vnodeop_desc *a_desc; 586 vnode_t a_vp; 587 int a_flags; 588 vfs_context_t a_context; 589 }; 590 591 /*! 592 * @function VNOP_REVOKE 593 * @abstract Call down to a filesystem to invalidate all open file descriptors for a vnode. 594 * @discussion This function is typically called as part of a TTY revoke, but can also be 595 * used on regular files. Most filesystems simply use nop_revoke(), which calls vn_revoke(), 596 * as their revoke vnop implementation. 597 * @param vp The vnode to revoke. 598 * @param flags Unused. 599 * @param ctx Context to authenticate for revoke request. 600 * @return 0 for success, else an error code. 601 */ 602 #ifdef XNU_KERNEL_PRIVATE 603 extern errno_t VNOP_REVOKE(vnode_t, int, vfs_context_t); 604 #endif /* XNU_KERNEL_PRIVATE */ 605 606 struct vnop_mmap_check_args { 607 struct vnodeop_desc *a_desc; 608 vnode_t a_vp; 609 int a_flags; 610 vfs_context_t a_context; 611 }; 612 613 /*! 614 * @function VNOP_MMAP_CHECK 615 * @abstract Check with a filesystem if a file can be mmap-ed. 616 * @discussion VNOP_MMAP_CHECK is used to check with the file system if a 617 * file can be mmap-ed. It will be called before any call to VNOP_MMAP(). 618 * @param vp The vnode being mmapped. 619 * @param flags Memory protection: PROT_READ, PROT_WRITE, PROT_EXEC. 620 * @param ctx Context to authenticate for mmap request. 621 * @return 0 for success; EPERM if the operation is not permitted; other 622 * errors (except ENOTSUP) may be returned at the discretion of the file 623 * system. ENOTSUP will never be returned by VNOP_MMAP_CHECK(). 624 */ 625 #ifdef XNU_KERNEL_PRIVATE 626 extern errno_t VNOP_MMAP_CHECK(vnode_t, int, vfs_context_t); 627 #endif /* XNU_KERNEL_PRIVATE */ 628 629 630 struct vnop_mmap_args { 631 struct vnodeop_desc *a_desc; 632 vnode_t a_vp; 633 int a_fflags; 634 vfs_context_t a_context; 635 }; 636 637 /*! 638 * @function VNOP_MMAP 639 * @abstract Notify a filesystem that a file is being mmap-ed. 640 * @discussion VNOP_MMAP is an advisory calldown to say that the system is mmap-ing a file. 641 * @param vp The vnode being mmapped. 642 * @param flags Memory protection: PROT_READ, PROT_WRITE, PROT_EXEC. 643 * @param ctx Context to authenticate for mmap request. 644 * @return 0 for success; all errors except EPERM are ignored. 645 */ 646 #ifdef XNU_KERNEL_PRIVATE 647 extern errno_t VNOP_MMAP(vnode_t, int, vfs_context_t); 648 #endif /* XNU_KERNEL_PRIVATE */ 649 650 struct vnop_mnomap_args { 651 struct vnodeop_desc *a_desc; 652 vnode_t a_vp; 653 vfs_context_t a_context; 654 }; 655 656 /*! 657 * @function VNOP_MNOMAP 658 * @abstract Inform a filesystem that a file is no longer mapped. 659 * @discussion In general, no action is required of a filesystem for VNOP_MNOMAP. 660 * @param vp The vnode which is no longer mapped. 661 * @param ctx Context to authenticate for mnomap request. 662 * @return Return value is ignored. 663 */ 664 #ifdef XNU_KERNEL_PRIVATE 665 extern errno_t VNOP_MNOMAP(vnode_t, vfs_context_t); 666 #endif /* XNU_KERNEL_PRIVATE */ 667 668 struct vnop_fsync_args { 669 struct vnodeop_desc *a_desc; 670 vnode_t a_vp; 671 int a_waitfor; 672 vfs_context_t a_context; 673 }; 674 675 /*! 676 * @function VNOP_FSYNC 677 * @abstract Call down to a filesystem to synchronize a file with on-disk state. 678 * @discussion VNOP_FSYNC is called whenever we need to make sure that a file's data has been 679 * pushed to backing store, for example when recycling; it is also the heart of the fsync() system call. 680 * @param vp The vnode whose data to flush to backing store. 681 * @param ctx Context to authenticate for fsync request. 682 * @return 0 for success, else an error code. 683 */ 684 extern errno_t VNOP_FSYNC(vnode_t vp, int waitfor, vfs_context_t ctx); 685 686 struct vnop_remove_args { 687 struct vnodeop_desc *a_desc; 688 vnode_t a_dvp; 689 vnode_t a_vp; 690 struct componentname *a_cnp; 691 int a_flags; 692 vfs_context_t a_context; 693 }; 694 695 /*! 696 * @function VNOP_REMOVE 697 * @abstract Call down to a filesystem to delete a file. 698 * @discussion VNOP_REMOVE is called to remove a file from a filesystem's namespace, for example by unlink(). 699 * It can operate on regular files, named pipes, special files, and in some cases on directories. 700 * @param dvp Directory in which to delete a file. 701 * @param vp The file to delete. 702 * @param cnp Filename information. 703 * @param ctx Context to authenticate for fsync request. 704 * @return 0 for success, else an error code. 705 */ 706 #ifdef XNU_KERNEL_PRIVATE 707 extern errno_t VNOP_REMOVE(vnode_t, vnode_t, struct componentname *, int, vfs_context_t); 708 #endif /* XNU_KERNEL_PRIVATE */ 709 710 #ifdef KERNEL_PRIVATE 711 struct vnop_compound_remove_args { 712 struct vnodeop_desc *a_desc; 713 vnode_t a_dvp; /* Directory in which to lookup and remove */ 714 vnode_t *a_vpp; /* File to remove; may or may not point to NULL pointer */ 715 struct componentname *a_cnp; /* Name of file to remove */ 716 struct vnode_attr *a_vap; /* Destination for file attributes on successful delete */ 717 uint32_t a_flags; /* Control flags (unused) */ 718 vfs_context_t a_context; /* Authorization context */ 719 int (*a_remove_authorizer)( /* Authorizer callback */ 720 vnode_t dvp, /* Directory in which to delete */ 721 vnode_t vp, /* File to delete */ 722 struct componentname *cnp, /* As passed to VNOP */ 723 vfs_context_t ctx, /* As passed to VNOP */ 724 void *reserved); /* Always NULL */ 725 void *a_reserved; /* Unused */ 726 }; 727 #endif /* KERNEL_PRIVATE */ 728 729 #ifdef BSD_KERNEL_PRIVATE 730 extern errno_t VNOP_COMPOUND_REMOVE(vnode_t, vnode_t*, struct nameidata *, int32_t flags, struct vnode_attr *vap, vfs_context_t); 731 #endif 732 struct vnop_link_args { 733 struct vnodeop_desc *a_desc; 734 vnode_t a_vp; 735 vnode_t a_tdvp; 736 struct componentname *a_cnp; 737 vfs_context_t a_context; 738 }; 739 740 /*! 741 * @function VNOP_LINK 742 * @abstract Call down to a filesystem to create a hardlink to a file. 743 * @discussion See "man 2 link". 744 * @param vp File to link to. 745 * @param dvp Directory in which to create the link. 746 * @param cnp Filename information for new link. 747 * @param ctx Context to authenticate for link request. 748 * @return 0 for success, else an error code. 749 */ 750 #ifdef XNU_KERNEL_PRIVATE 751 extern errno_t VNOP_LINK(vnode_t, vnode_t, struct componentname *, vfs_context_t); 752 #endif /* XNU_KERNEL_PRIVATE */ 753 754 struct vnop_rename_args { 755 struct vnodeop_desc *a_desc; 756 vnode_t a_fdvp; 757 vnode_t a_fvp; 758 struct componentname *a_fcnp; 759 vnode_t a_tdvp; 760 vnode_t a_tvp; 761 struct componentname *a_tcnp; 762 vfs_context_t a_context; 763 }; 764 765 /*! 766 * @function VNOP_RENAME 767 * @abstract Call down to a filesystem to rename a file. 768 * @discussion VNOP_RENAME() will only be called with a source and target on the same volume. 769 * @param fdvp Directory in which source file resides. 770 * @param fvp File being renamed. 771 * @param fcnp Name information for source file. 772 * @param tdvp Directory file is being moved to. 773 * @param tvp Existing file with same name as target, should one exist. 774 * @param tcnp Name information for target path. 775 * @param ctx Context to authenticate for rename request. 776 * @return 0 for success, else an error code. 777 */ 778 #ifdef XNU_KERNEL_PRIVATE 779 extern errno_t VNOP_RENAME(vnode_t, vnode_t, struct componentname *, vnode_t, vnode_t, struct componentname *, vfs_context_t); 780 #endif /* XNU_KERNEL_PRIVATE */ 781 782 typedef unsigned int vfs_rename_flags_t; 783 784 // Must match sys/stdio.h 785 enum { 786 VFS_RENAME_SECLUDE = 0x00000001, 787 VFS_RENAME_SWAP = 0x00000002, 788 VFS_RENAME_EXCL = 0x00000004, 789 790 /* 791 * VFS_RENAME_DATALESS is kernel-only and is intentionally 792 * not included in VFS_RENAME_FLAGS_MASK. 793 */ 794 VFS_RENAME_DATALESS = 0x00000008, 795 /* used by sys/stdio for RENAME_NOFOLLOW_ANY */ 796 VFS_RENAME_RESERVED1 = 0x00000010, 797 798 VFS_RENAME_FLAGS_MASK = (VFS_RENAME_SECLUDE | VFS_RENAME_SWAP 799 | VFS_RENAME_EXCL), 800 }; 801 802 struct vnop_renamex_args { 803 struct vnodeop_desc *a_desc; 804 vnode_t a_fdvp; 805 vnode_t a_fvp; 806 struct componentname *a_fcnp; 807 vnode_t a_tdvp; 808 vnode_t a_tvp; 809 struct componentname *a_tcnp; 810 struct vnode_attr *a_vap; // Reserved for future use 811 vfs_rename_flags_t a_flags; 812 vfs_context_t a_context; 813 }; 814 815 /*! 816 * @function VNOP_RENAMEX 817 * @abstract Call down to a filesystem to rename a file. 818 * @discussion VNOP_RENAMEX() will only be called with a source and target on the same volume. 819 * @param fdvp Directory in which source file resides. 820 * @param fvp File being renamed. 821 * @param fcnp Name information for source file. 822 * @param tdvp Directory file is being moved to. 823 * @param tvp Existing file with same name as target, should one exist. 824 * @param tcnp Name information for target path. 825 * @param flags Control certain rename semantics. 826 * @param ctx Context to authenticate for rename request. 827 * @return 0 for success, else an error code. 828 */ 829 #ifdef XNU_KERNEL_PRIVATE 830 extern errno_t VNOP_RENAMEX(vnode_t, vnode_t, struct componentname *, vnode_t, vnode_t, struct componentname *, vfs_rename_flags_t, vfs_context_t); 831 #endif /* XNU_KERNEL_PRIVATE */ 832 833 #ifdef KERNEL_PRIVATE 834 struct vnop_compound_rename_args { 835 struct vnodeop_desc *a_desc; 836 837 vnode_t a_fdvp; /* Directory from which to rename */ 838 vnode_t *a_fvpp; /* Vnode to rename (can point to a NULL pointer) */ 839 struct componentname *a_fcnp; /* Source name */ 840 struct vnode_attr *a_fvap; 841 842 vnode_t a_tdvp; /* Directory to which to rename */ 843 vnode_t *a_tvpp; /* Vnode to rename over (can point to a NULL pointer) */ 844 struct componentname *a_tcnp; /* Destination name */ 845 struct vnode_attr *a_tvap; 846 847 uint32_t a_flags; /* Control flags: currently unused */ 848 vfs_context_t a_context; /* Authorization context */ 849 int (*a_rename_authorizer)( /* Authorization callback */ 850 vnode_t fdvp, /* As passed to VNOP */ 851 vnode_t fvp, /* Vnode to rename */ 852 struct componentname *fcnp, /* As passed to VNOP */ 853 vnode_t tdvp, /* As passed to VNOP */ 854 vnode_t tvp, /* Vnode to rename over (can be NULL) */ 855 struct componentname *tcnp, /* As passed to VNOP */ 856 vfs_context_t ctx, /* As passed to VNOP */ 857 void *reserved); /* Always NULL */ 858 void *a_reserved; /* Currently unused */ 859 }; 860 #endif /* KERNEL_PRIVATE */ 861 862 #ifdef XNU_KERNEL_PRIVATE 863 errno_t 864 VNOP_COMPOUND_RENAME( 865 struct vnode *fdvp, struct vnode **fvpp, struct componentname *fcnp, struct vnode_attr *fvap, 866 struct vnode *tdvp, struct vnode **tvpp, struct componentname *tcnp, struct vnode_attr *tvap, 867 uint32_t flags, vfs_context_t ctx); 868 #endif /* XNU_KERNEL_PRIVATE */ 869 870 struct vnop_mkdir_args { 871 struct vnodeop_desc *a_desc; 872 vnode_t a_dvp; 873 vnode_t *a_vpp; 874 struct componentname *a_cnp; 875 struct vnode_attr *a_vap; 876 vfs_context_t a_context; 877 }; 878 879 /*! 880 * @function VNOP_MKDIR 881 * @abstract Call down to a filesystem to create a directory. 882 * @discussion The newly created directory should be returned with an iocount which will be dropped by the caller. 883 * @param dvp Directory in which to create new directory. 884 * @param vpp Destination for pointer to new directory's vnode. 885 * @param cnp Name information for new directory. 886 * @param vap Attributes for new directory. 887 * @param ctx Context to authenticate for mkdir request. 888 * @return 0 for success, else an error code. 889 */ 890 #ifdef XNU_KERNEL_PRIVATE 891 extern errno_t VNOP_MKDIR(vnode_t, vnode_t *, struct componentname *, struct vnode_attr *, vfs_context_t); 892 #endif /* XNU_KERNEL_PRIVATE */ 893 894 895 #ifdef KERNEL_PRIVATE 896 struct vnop_compound_mkdir_args { 897 struct vnodeop_desc *a_desc; 898 vnode_t a_dvp; /* Directory in which to create */ 899 vnode_t *a_vpp; /* Destination for found or created vnode */ 900 struct componentname *a_cnp; /* Name of directory to create */ 901 struct vnode_attr *a_vap; /* Creation attributes */ 902 uint32_t a_flags; /* Control flags (unused) */ 903 vfs_context_t a_context; /* Authorization context */ 904 #if 0 905 int (*a_mkdir_authorizer)(vnode_t dvp, struct componentname *cnp, struct vnode_attr *vap, vfs_context_t ctx, void *reserved); 906 #endif /* 0 */ 907 void *a_reserved; /* Unused */ 908 }; 909 #endif /* KERNEL_PRIVATE */ 910 911 #ifdef XNU_KERNEL_PRIVATE 912 extern errno_t VNOP_COMPOUND_MKDIR(vnode_t, vnode_t *, struct nameidata *, struct vnode_attr *, vfs_context_t); 913 #endif /* XNU_KERNEL_PRIVATE */ 914 915 struct vnop_rmdir_args { 916 struct vnodeop_desc *a_desc; 917 vnode_t a_dvp; 918 vnode_t a_vp; 919 struct componentname *a_cnp; 920 vfs_context_t a_context; 921 }; 922 923 /*! 924 * @function VNOP_RMDIR 925 * @abstract Call down to a filesystem to delete a directory. 926 * @param dvp Parent of directory to be removed. 927 * @param vp Directory to remove. 928 * @param cnp Name information for directory to be deleted. 929 * @param ctx Context to authenticate for rmdir request. 930 * @return 0 for success, else an error code. 931 */ 932 #ifdef XNU_KERNEL_PRIVATE 933 extern errno_t VNOP_RMDIR(vnode_t, vnode_t, struct componentname *, vfs_context_t); 934 #endif /* XNU_KERNEL_PRIVATE */ 935 936 #ifdef KERNEL_PRIVATE 937 struct vnop_compound_rmdir_args { 938 struct vnodeop_desc *a_desc; 939 vnode_t a_dvp; /* Directory in which to look up and delete */ 940 vnode_t *a_vpp; /* Destination for found vnode */ 941 struct componentname *a_cnp; /* Name to delete */ 942 struct vnode_attr *a_vap; /* Location in which to store attributes if delete succeeds (can be NULL) */ 943 uint32_t a_flags; /* Control flags (currently unused) */ 944 vfs_context_t a_context; /* Context for authorization */ 945 int (*a_rmdir_authorizer)( /* Authorization callback */ 946 vnode_t dvp, /* As passed to VNOP */ 947 vnode_t vp, /* Directory to delete */ 948 struct componentname *cnp, /* As passed to VNOP */ 949 vfs_context_t ctx, /* As passed to VNOP */ 950 void *reserved); /* Always NULL */ 951 void *a_reserved; /* Unused */ 952 }; 953 #endif /* KERNEL_PRIVATE */ 954 955 #ifdef XNU_KERNEL_PRIVATE 956 extern errno_t VNOP_COMPOUND_RMDIR(vnode_t, vnode_t*, struct nameidata *, struct vnode_attr *vap, vfs_context_t); 957 #endif /* XNU_KERNEL_PRIVATE */ 958 959 960 struct vnop_symlink_args { 961 struct vnodeop_desc *a_desc; 962 vnode_t a_dvp; 963 vnode_t *a_vpp; 964 struct componentname *a_cnp; 965 struct vnode_attr *a_vap; 966 char *a_target; 967 vfs_context_t a_context; 968 }; 969 970 /*! 971 * @function VNOP_SYMLINK 972 * @abstract Call down to a filesystem to create a symbolic link. 973 * @param If VNOP_SYMLINK() is successful, the new file should be returned with an iocount which will 974 * be dropped by the caller. VFS does not ensure that the target path will have a length shorter 975 * than the max symlink length for the filesystem. 976 * @param dvp Parent directory for new symlink file. 977 * @param vpp 978 * @param cnp Name information for new symlink. 979 * @param vap Attributes for symlink. 980 * @param target Path for symlink to store; for "ln -s /var/vardir linktovardir", "target" would be "/var/vardir" 981 * @param ctx Context to authenticate for symlink request. 982 * @return 0 for success, else an error code. 983 */ 984 #ifdef XNU_KERNEL_PRIVATE 985 extern errno_t VNOP_SYMLINK(vnode_t, vnode_t *, struct componentname *, struct vnode_attr *, char *, vfs_context_t); 986 #endif /* XNU_KERNEL_PRIVATE */ 987 988 /* 989 * 990 * When VNOP_READDIR is called from the NFS Server, the nfs_data 991 * argument is non-NULL. 992 * 993 * The value of nfs_eofflag should be set to TRUE if the end of 994 * the directory was reached while reading. 995 * 996 * The directory seek offset (cookies) are returned to the NFS client and 997 * may be used later to restart a directory read part way through 998 * the directory. There is one cookie returned for each directory 999 * entry returned and its size is determince from nfs_sizeofcookie. 1000 * The value of the cookie should be the logical offset within the 1001 * directory where the on-disc version of the appropriate directory 1002 * entry starts. Memory for the cookies is allocated from M_TEMP 1003 * and it is freed by the caller of VNOP_READDIR. 1004 * 1005 */ 1006 1007 struct vnop_readdir_args { 1008 struct vnodeop_desc *a_desc; 1009 vnode_t a_vp; 1010 struct uio *a_uio; 1011 int a_flags; 1012 int *a_eofflag; 1013 int *a_numdirent; 1014 vfs_context_t a_context; 1015 }; 1016 1017 /*! 1018 * @function VNOP_READDIR 1019 * @abstract Call down to a filesystem to enumerate directory entries. 1020 * @discussion VNOP_READDIR() packs a buffer with "struct dirent" directory entry representations as described 1021 * by the "getdirentries" manual page. 1022 * @param vp Directory to enumerate. 1023 * @param uio Destination information for resulting direntries. 1024 * @param flags VNODE_READDIR_EXTENDED, VNODE_READDIR_REQSEEKOFF, VNODE_READDIR_SEEKOFF32: Apple-internal flags. 1025 * @param eofflag Should be set to 1 if the end of the directory has been reached. 1026 * @param numdirent Should be set to number of entries written into buffer. 1027 * @param ctx Context to authenticate for readdir request. 1028 * @return 0 for success, else an error code. 1029 */ 1030 #ifdef XNU_KERNEL_PRIVATE 1031 extern errno_t VNOP_READDIR(vnode_t, struct uio *, int, int *, int *, vfs_context_t); 1032 #endif /* XNU_KERNEL_PRIVATE */ 1033 1034 struct vnop_readdirattr_args { 1035 struct vnodeop_desc *a_desc; 1036 vnode_t a_vp; 1037 struct attrlist *a_alist; 1038 struct uio *a_uio; 1039 uint32_t a_maxcount; 1040 uint32_t a_options; 1041 uint32_t *a_newstate; 1042 int *a_eofflag; 1043 uint32_t *a_actualcount; 1044 vfs_context_t a_context; 1045 }; 1046 1047 /*! 1048 * @function VNOP_READDIRATTR 1049 * @abstract Call down to get file attributes for many files in a directory at once. 1050 * @discussion VNOP_READDIRATTR() packs a buffer with file attributes, as if the results of many "getattrlist" calls. 1051 * @param vp Directory in which to enumerate entries' attributes. 1052 * @param alist Which attributes are wanted for each directory entry. 1053 * @param uio Destination information for resulting attributes. 1054 * @param maxcount Maximum count of files to get attributes for. 1055 * @param options FSOPT_NOFOLLOW: do not follow symbolic links. FSOPT_NOINMEMUPDATE: do not use data which have been 1056 * updated since an inode was loaded into memory. 1057 * @param newstate The "newstate" should be set to a value which changes if the contents of a directory change 1058 * through an addition or deletion but stays the same otherwise. 1059 * @param eofflag Should be set to 1 if the end of the directory has been reached. 1060 * @param actualcount Should be set to number of files whose attributes were written into buffer. 1061 * @param ctx Context to authenticate for readdirattr request. 1062 * @return 0 for success, else an error code. 1063 */ 1064 #ifdef XNU_KERNEL_PRIVATE 1065 extern errno_t VNOP_READDIRATTR(vnode_t, struct attrlist *, struct uio *, uint32_t, uint32_t, uint32_t *, int *, uint32_t *, vfs_context_t); 1066 #endif /* XNU_KERNEL_PRIVATE */ 1067 1068 struct vnop_getattrlistbulk_args { 1069 struct vnodeop_desc *a_desc; 1070 vnode_t a_vp; 1071 struct attrlist *a_alist; 1072 struct vnode_attr *a_vap; 1073 struct uio *a_uio; 1074 void *a_private; 1075 uint64_t a_options; 1076 int32_t *a_eofflag; 1077 int32_t *a_actualcount; 1078 vfs_context_t a_context; 1079 }; 1080 1081 /*! 1082 * @function VNOP_GETATTRLISTBULK 1083 * @abstract Call down to get file attributes for many files in a directory at once. 1084 * @discussion VNOP_GETATTRLISTBULK() packs a buffer with file attributes, as if the results of many "getattrlist" calls. 1085 * @param vp Directory in which to enumerate entries' attributes. 1086 * @param alist Which attributes are wanted for each directory entry. 1087 * @param uio Destination information for resulting attributes. 1088 * @param vap initialised vnode_attr structure pointer. This structure also has memory allocated (MAXPATHLEN bytes) and assigned to the va_name field for filesystems to use. 1089 * @param private reserved for future use. 1090 * @param options 1091 * @param eofflag Should be set to 1 if the end of the directory has been reached. 1092 * @param actualcount Should be set to number of files whose attributes were written into buffer. 1093 * @param ctx Context to authenticate for getattrlistbulk request. 1094 * @return 0 for success, else an error code. 1095 */ 1096 #ifdef XNU_KERNEL_PRIVATE 1097 extern errno_t VNOP_GETATTRLISTBULK(vnode_t, struct attrlist *, struct vnode_attr *, uio_t, void *, uint64_t, int32_t *, int32_t *, vfs_context_t); 1098 #endif /* XNU_KERNEL_PRIVATE */ 1099 1100 struct vnop_readlink_args { 1101 struct vnodeop_desc *a_desc; 1102 vnode_t a_vp; 1103 struct uio *a_uio; 1104 vfs_context_t a_context; 1105 }; 1106 1107 /*! 1108 * @function VNOP_READLINK 1109 * @abstract Call down to a filesystem to get the pathname represented by a symbolic link. 1110 * @discussion VNOP_READLINK() gets the path stored in a symbolic link; it is called by namei() and the readlink() system call. 1111 * @param vp Symbolic link to read from. 1112 * @param uio Destination information for link path. 1113 * @param ctx Context to authenticate for readlink request. 1114 * @return 0 for success, else an error code. 1115 */ 1116 #ifdef XNU_KERNEL_PRIVATE 1117 extern errno_t VNOP_READLINK(vnode_t, struct uio *, vfs_context_t); 1118 #endif /* XNU_KERNEL_PRIVATE */ 1119 1120 struct vnop_inactive_args { 1121 struct vnodeop_desc *a_desc; 1122 vnode_t a_vp; 1123 vfs_context_t a_context; 1124 }; 1125 1126 /*! 1127 * @function VNOP_INACTIVE 1128 * @abstract Notify a filesystem that the last usecount (persistent reference) on a vnode has been dropped. 1129 * @discussion VNOP_INACTVE() gives a filesystem a chance to aggressively release resources assocated with a vnode, perhaps 1130 * even to call vnode_recycle(), but no action is prescribed; it is acceptable for VNOP_INACTIVE to be a no-op and 1131 * to defer all reclamation until VNOP_RECLAIM(). 1132 * VNOP_INACTVE() will not be called on a vnode if no persistent reference is ever taken; an 1133 * important example is a stat(), which takes an iocount, reads its data, and drops that iocount. 1134 * @param vp The vnode which is now inactive. 1135 * @param ctx Context to authenticate for inactive message. 1136 * @return 0 for success, else an error code, but return value is currently ignored. 1137 */ 1138 #ifdef XNU_KERNEL_PRIVATE 1139 extern errno_t VNOP_INACTIVE(vnode_t, vfs_context_t); 1140 #endif /* XNU_KERNEL_PRIVATE */ 1141 1142 struct vnop_reclaim_args { 1143 struct vnodeop_desc *a_desc; 1144 vnode_t a_vp; 1145 vfs_context_t a_context; 1146 }; 1147 1148 /*! 1149 * @function VNOP_RECLAIM 1150 * @abstract Release filesystem-internal resources for a vnode. 1151 * @discussion VNOP_RECLAIM() is called as part of the process of recycling a vnode. During 1152 * a reclaim routine, a filesystem should remove a vnode from its hash and deallocate any resources 1153 * allocated to that vnode. VFS guarantees that when VNOP_RECLAIM() is called, there are no more 1154 * iocount references on a vnode (though there may still be usecount references--these are invalidated 1155 * by the reclaim) and that no more will be granted. This means in practice that there will be no 1156 * filesystem calls on the vnode being reclaimed until the reclaim has finished and the vnode has 1157 * been reused. 1158 * @param vp The vnode to reclaim. 1159 * @param ctx Context to authenticate for reclaim. 1160 * @return 0 for success, or an error code. A nonzero return value results in a panic. 1161 */ 1162 #ifdef XNU_KERNEL_PRIVATE 1163 extern errno_t VNOP_RECLAIM(vnode_t, vfs_context_t); 1164 #endif /* XNU_KERNEL_PRIVATE */ 1165 1166 struct vnop_pathconf_args { 1167 struct vnodeop_desc *a_desc; 1168 vnode_t a_vp; 1169 int a_name; 1170 int32_t *a_retval; 1171 vfs_context_t a_context; 1172 }; 1173 1174 /*! 1175 * @function VNOP_PATHCONF 1176 * @abstract Query a filesystem for path properties. 1177 * @param vp The vnode whose filesystem to query. 1178 * @param name Which property to request: see unistd.h. For example: _PC_CASE_SENSITIVE (is 1179 * a filesystem case-sensitive?). Only one property can be requested at a time. 1180 * @param retval Destination for value of property. 1181 * @param ctx Context to authenticate for pathconf request. 1182 * @return 0 for success, or an error code. 1183 */ 1184 #ifdef XNU_KERNEL_PRIVATE 1185 extern errno_t VNOP_PATHCONF(vnode_t, int, int32_t *, vfs_context_t); 1186 #endif /* XNU_KERNEL_PRIVATE */ 1187 1188 struct vnop_advlock_args { 1189 struct vnodeop_desc *a_desc; 1190 vnode_t a_vp; 1191 caddr_t a_id; 1192 int a_op; 1193 struct flock *a_fl; 1194 int a_flags; 1195 vfs_context_t a_context; 1196 struct timespec *a_timeout; 1197 }; 1198 1199 /*! 1200 * @function VNOP_ADVLOCK 1201 * @abstract Aquire or release and advisory lock on a vnode. 1202 * @discussion Advisory locking is somewhat complicated. VNOP_ADVLOCK is overloaded for 1203 * both flock() and POSIX advisory locking usage, though not all filesystems support both (or any). VFS 1204 * provides an advisory locking mechanism for filesystems which can take advantage of it; vfs_setlocklocal() 1205 * marks a filesystem as using VFS advisory locking support. 1206 * @param vp The vnode to lock or unlock. 1207 * @param id Identifier for lock holder: ignored by most filesystems. 1208 * @param op Which locking operation: F_SETLK: set locking information about a region. 1209 * F_GETLK: get locking information about the specified region. F_UNLCK: Unlock a region. 1210 * @param fl Description of file region to lock. l_whence is as with "lseek." 1211 * Includes a type: F_RDLCK (shared lock), F_UNLCK (unlock) , and F_WRLCK (exclusive lock). 1212 * @param flags F_FLOCK: use flock() semantics. F_POSIX: use POSIX semantics. F_WAIT: sleep if necessary. 1213 * F_PROV: Non-coelesced provisional lock (unused in xnu). 1214 * @param ctx Context to authenticate for advisory locking request. 1215 * @param timeout Timespec for timeout in case of F_SETLKWTIMEOUT. 1216 * @return 0 for success, or an error code. 1217 */ 1218 #ifdef XNU_KERNEL_PRIVATE 1219 extern errno_t VNOP_ADVLOCK(vnode_t, caddr_t, int, struct flock *, int, vfs_context_t, struct timespec *); 1220 #endif /* XNU_KERNEL_PRIVATE */ 1221 1222 struct vnop_allocate_args { 1223 struct vnodeop_desc *a_desc; 1224 vnode_t a_vp; 1225 off_t a_length; 1226 u_int32_t a_flags; 1227 off_t *a_bytesallocated; 1228 off_t a_offset; 1229 vfs_context_t a_context; 1230 }; 1231 1232 /*! 1233 * @function VNOP_ALLOCATE 1234 * @abstract Pre-allocate space for a file. 1235 * @discussion VNOP_ALLOCATE() changes the amount of backing store set aside to 1236 * a file. It can be used to either shrink or grow a file. If the file shrinks, 1237 * its ubc size will be modified accordingly, but if it grows, then the ubc size is unchanged; 1238 * space is set aside without being actively used by the file. VNOP_ALLOCATE() is currently only 1239 * called as part of the F_PREALLOCATE fcntl. 1240 * @param vp The vnode for which to preallocate space. 1241 * @param length Desired preallocated file length. 1242 * @param flags 1243 * PREALLOCATE: preallocate allocation blocks. 1244 * ALLOCATECONTIG: allocate contigious space. 1245 * ALLOCATEALL: allocate all requested space or no space at all. 1246 * ALLOCATEPERSIST: do not deallocate allocated but unfilled blocks at close(2). 1247 * ALLOCATEFROMPEOF: allocate from the physical eof. 1248 * ALLOCATEFROMVOL: allocate from the volume offset. 1249 * @param bytesallocated Additional bytes set aside for file. Set to 0 if none are allocated 1250 * OR if the file is contracted. 1251 * @param offset Hint for where to find free blocks. 1252 * @param ctx Context to authenticate for allocation request. 1253 * @return 0 for success, or an error code. 1254 */ 1255 #ifdef XNU_KERNEL_PRIVATE 1256 extern errno_t VNOP_ALLOCATE(vnode_t, off_t, u_int32_t, off_t *, off_t, vfs_context_t); 1257 #endif /* XNU_KERNEL_PRIVATE */ 1258 1259 struct vnop_pagein_args { 1260 struct vnodeop_desc *a_desc; 1261 vnode_t a_vp; 1262 upl_t a_pl; 1263 upl_offset_t a_pl_offset; 1264 off_t a_f_offset; 1265 size_t a_size; 1266 int a_flags; 1267 vfs_context_t a_context; 1268 }; 1269 1270 /*! 1271 * @function VNOP_PAGEIN 1272 * @abstract Pull file data into memory. 1273 * @discussion VNOP_PAGEIN() is called by when a process faults on data mapped from a file or 1274 * when madvise() demands pre-fetching. It is conceptually somewhat similar to VNOP_READ(). Filesystems 1275 * are typically expected to call cluster_pagein() to handle the labor of mapping and committing the UPL. 1276 * @param vp The vnode for which to page in data. 1277 * @param pl UPL describing pages needing to be paged in. 1278 * @param pl_offset Offset in UPL at which to start placing data. 1279 * @param f_offset Offset in file of data needing to be paged in. 1280 * @param size Amount of data to page in (in bytes). 1281 * @param flags UPL-style flags: UPL_IOSYNC, UPL_NOCOMMIT, UPL_NORDAHEAD, UPL_VNODE_PAGER, UPL_MSYNC. 1282 * Filesystems should generally leave it to the cluster layer to handle these flags. See the 1283 * memory_object_types.h header in the kernel framework if interested. 1284 * @param ctx Context to authenticate for pagein request. 1285 * @return 0 for success, or an error code. 1286 */ 1287 #ifdef XNU_KERNEL_PRIVATE 1288 extern errno_t VNOP_PAGEIN(vnode_t, upl_t, upl_offset_t, off_t, size_t, int, vfs_context_t); 1289 #endif /* XNU_KERNEL_PRIVATE */ 1290 1291 struct vnop_pageout_args { 1292 struct vnodeop_desc *a_desc; 1293 vnode_t a_vp; 1294 upl_t a_pl; 1295 upl_offset_t a_pl_offset; 1296 off_t a_f_offset; 1297 size_t a_size; 1298 int a_flags; 1299 vfs_context_t a_context; 1300 }; 1301 1302 /*! 1303 * @function VNOP_PAGEOUT 1304 * @abstract Write data from a mapped file back to disk. 1305 * @discussion VNOP_PAGEOUT() is called when data from a mapped file needs to be flushed to disk, either 1306 * because of an msync() call or due to memory pressure. Filesystems are for the most part expected to 1307 * just call cluster_pageout(). However, if they opt into the VFC_VFSVNOP_PAGEOUTV2 flag, then 1308 * they will be responsible for creating their own UPLs. 1309 * @param vp The vnode for which to page out data. 1310 * @param pl UPL describing pages needed to be paged out. If UPL is NULL, then it means the filesystem 1311 * has opted into VFC_VFSVNOP_PAGEOUTV2 semantics, which means that it will create and operate on its own UPLs 1312 * as opposed to relying on the one passed down into the filesystem. This means that the filesystem must be 1313 * responsible for N cluster_pageout calls for N dirty ranges in the UPL. 1314 * @param pl_offset Offset in UPL from which to start paging out data. Under the new VFC_VFSVNOP_PAGEOUTV2 1315 * semantics, this is the offset in the range specified that must be paged out if the associated page is dirty. 1316 * @param f_offset Offset in file of data needing to be paged out. Under the new VFC_VFSVNOP_PAGEOUTV2 1317 * semantics, this represents the offset in the file where we should start looking for dirty pages. 1318 * @param size Amount of data to page out (in bytes). Under VFC_VFSVNOP_PAGEOUTV2, this represents 1319 * the size of the range to be considered. The fileystem is free to extend or shrink the specified range 1320 * to better fit its blocking model as long as the page at 'pl_offset' is included. 1321 * @param flags UPL-style flags: UPL_IOSYNC, UPL_NOCOMMIT, UPL_NORDAHEAD, UPL_VNODE_PAGER, UPL_MSYNC. 1322 * Filesystems should generally leave it to the cluster layer to handle these flags. See the 1323 * memory_object_types.h header in the kernel framework if interested. 1324 * @param ctx Context to authenticate for pageout request. 1325 * @return 0 for success, or an error code. 1326 */ 1327 #ifdef XNU_KERNEL_PRIVATE 1328 extern errno_t VNOP_PAGEOUT(vnode_t, upl_t, upl_offset_t, off_t, size_t, int, vfs_context_t); 1329 #endif /* XNU_KERNEL_PRIVATE */ 1330 1331 struct vnop_searchfs_args { 1332 struct vnodeop_desc *a_desc; 1333 vnode_t a_vp; 1334 void *a_searchparams1; 1335 void *a_searchparams2; 1336 struct attrlist *a_searchattrs; 1337 uint32_t a_maxmatches; 1338 struct timeval *a_timelimit; 1339 struct attrlist *a_returnattrs; 1340 uint32_t *a_nummatches; 1341 uint32_t a_scriptcode; 1342 uint32_t a_options; 1343 struct uio *a_uio; 1344 struct searchstate *a_searchstate; 1345 vfs_context_t a_context; 1346 }; 1347 1348 /* 1349 * @function VNOP_SEARCHFS 1350 * @abstract Search a filesystem quickly for files or directories that match the passed-in search criteria. 1351 * @discussion VNOP_SEARCHFS is a getattrlist-based system call which is implemented almost entirely inside 1352 * supported filesystems. Callers provide a set of criteria to match against, and the filesystem is responsible 1353 * for finding all files or directories that match the criteria. Once these files or directories are found, 1354 * the user-requested attributes of these files is provided as output. The set of searchable attributes is a 1355 * subset of the getattrlist attributes. For example, ATTR_CMN_UUID is not a valid searchable attribute as of 1356 * 10.6. A common usage scenario could be to request all files whose mod dates is greater than time X, less than 1357 * time Y, and provide the inode ID and filename of the matching objects as output. 1358 * @param vp The vnode representing the mountpoint of the filesystem to be searched. 1359 * @param a_searchparams1 If one-argument search criteria is requested, the search criteria would go here. However, 1360 * some search criteria, like ATTR_CMN_MODTIME, can be bounded. The user could request files modified between time X 1361 * and time Y. In this case, the lower bound goes in a_searchparams1. 1362 * @param a_searchparams2 If two-argument search criteria is requested, the upper bound goes in here. 1363 * @param a_searchattrs Contains the getattrlist-style attribute bits which are requested by the current search. 1364 * @param a_maxmatches The maximum number of matches to return in a single system call. 1365 * @param a_timelimit The suggested maximum amount of time we can spend in the kernel to service this system call. 1366 * Filesystems should use this as a guide only, and set their own internal maximum time to avoid denial of service. 1367 * @param a_returnattrs The getattrlist-style attributes to return for items in the filesystem that match the search 1368 * criteria above. 1369 * @param a_scriptcode Currently ignored. 1370 * @param a_uio The uio in which to write out the search matches. 1371 * @param a_searchstate Sometimes searches cannot be completed in a single system call. In this case, we provide 1372 * an identifier back to the user which indicates where to resume a previously-started search. This is an opaque structure 1373 * used by the filesystem to identify where to resume said search. 1374 * @param a_context The context in which to perform the filesystem search. 1375 * @return 0 on success, EAGAIN for searches which could not be completed in 1 call, and other ERRNOS as needed. 1376 */ 1377 1378 #ifdef XNU_KERNEL_PRIVATE 1379 extern errno_t VNOP_SEARCHFS(vnode_t, void *, void *, struct attrlist *, uint32_t, struct timeval *, struct attrlist *, uint32_t *, uint32_t, uint32_t, struct uio *, struct searchstate *, vfs_context_t); 1380 #endif /* XNU_KERNEL_PRIVATE */ 1381 1382 struct vnop_copyfile_args { 1383 struct vnodeop_desc *a_desc; 1384 vnode_t a_fvp; 1385 vnode_t a_tdvp; 1386 vnode_t a_tvp; 1387 struct componentname *a_tcnp; 1388 int a_mode; 1389 int a_flags; 1390 vfs_context_t a_context; 1391 }; 1392 1393 #ifdef XNU_KERNEL_PRIVATE 1394 extern errno_t VNOP_COPYFILE(vnode_t, vnode_t, vnode_t, struct componentname *, int, int, vfs_context_t); 1395 #endif /* XNU_KERNEL_PRIVATE */ 1396 1397 typedef enum dir_clone_authorizer_op { 1398 OP_AUTHORIZE = 0, /* request authorization of action */ 1399 OP_VATTR_SETUP = 1, /* query for attributes that are required for OP_AUTHORIZE */ 1400 OP_VATTR_CLEANUP = 2 /* request to cleanup any state or free any memory allocated in OP_AUTHORIZE */ 1401 } dir_clone_authorizer_op_t; 1402 1403 struct vnop_clonefile_args { 1404 struct vnodeop_desc *a_desc; 1405 vnode_t a_fvp; 1406 vnode_t a_dvp; 1407 vnode_t *a_vpp; 1408 struct componentname *a_cnp; 1409 struct vnode_attr *a_vap; 1410 uint32_t a_flags; 1411 vfs_context_t a_context; 1412 int (*a_dir_clone_authorizer)( /* Authorization callback */ 1413 struct vnode_attr *vap, /* attribute to be authorized */ 1414 kauth_action_t action, /* action for which attribute is to be authorized */ 1415 struct vnode_attr *dvap, /* target directory attributes */ 1416 vnode_t sdvp, /* source directory vnode pointer (optional) */ 1417 mount_t mp, /* mount point of filesystem */ 1418 dir_clone_authorizer_op_t vattr_op, /* specific operation requested : setup, authorization or cleanup */ 1419 uint32_t flags, /* needs to have the value passed to a_flags */ 1420 vfs_context_t ctx, /* As passed to VNOP */ 1421 void *reserved); /* Always NULL */ 1422 void *a_reserved; /* Currently unused */ 1423 }; 1424 1425 /*! 1426 * @function VNOP_CLONEFILE 1427 * @abstract Call down to a filesystem to clone a filesystem object (regular file, directory or symbolic link.) 1428 * @discussion If file creation succeeds, "vpp" should be returned with an iocount to be dropped by the caller. 1429 * @param dvp Directory in which to clone object. 1430 * @param vpp Destination for vnode for newly cloned object. 1431 * @param cnp Description of name of object to clone. 1432 * @param vap File creation properties, as seen in vnode_getattr(). Manipulated with VATTR_ISACTIVE, VATTR_RETURN, 1433 * VATTR_SET_SUPPORTED, and so forth. All attributes not set here should either be copied 1434 * from the source object 1435 * or set to values which are used for creating new filesystem objects 1436 * @param ctx Context against which to authenticate file creation. 1437 * @return 0 for success or a filesystem-specific error. 1438 */ 1439 #ifdef XNU_KERNEL_PRIVATE 1440 extern errno_t VNOP_CLONEFILE(vnode_t, vnode_t, vnode_t *, struct componentname *, struct vnode_attr *, uint32_t, vfs_context_t); 1441 #endif /* XNU_KERNEL_PRIVATE */ 1442 1443 struct vnop_getxattr_args { 1444 struct vnodeop_desc *a_desc; 1445 vnode_t a_vp; 1446 const char * a_name; 1447 uio_t a_uio; 1448 size_t *a_size; 1449 int a_options; 1450 vfs_context_t a_context; 1451 }; 1452 extern struct vnodeop_desc vnop_getxattr_desc; 1453 1454 /*! 1455 * @function VNOP_GETXATTR 1456 * @abstract Get extended file attributes. 1457 * @param vp The vnode to get extended attributes for. 1458 * @param name Which property to extract. 1459 * @param uio Destination information for attribute value. 1460 * @param size Should be set to the amount of data written. 1461 * @param options XATTR_NOSECURITY: bypass security-checking. 1462 * @param ctx Context to authenticate for getxattr request. 1463 * @return 0 for success, or an error code. 1464 */ 1465 extern errno_t VNOP_GETXATTR(vnode_t vp, const char *name, uio_t uio, size_t *size, int options, vfs_context_t ctx); 1466 1467 struct vnop_setxattr_args { 1468 struct vnodeop_desc *a_desc; 1469 vnode_t a_vp; 1470 const char * a_name; 1471 uio_t a_uio; 1472 int a_options; 1473 vfs_context_t a_context; 1474 }; 1475 extern struct vnodeop_desc vnop_setxattr_desc; 1476 1477 /*! 1478 * @function VNOP_SETXATTR 1479 * @abstract Set extended file attributes. 1480 * @param vp The vnode to set extended attributes for. 1481 * @param name Which property to extract. 1482 * @param uio Source information for attribute value. 1483 * @param options XATTR_NOSECURITY: bypass security-checking. XATTR_CREATE: set value, fail if exists. 1484 * XATTR_REPLACE: set value, fail if does not exist. 1485 * @param ctx Context to authenticate for setxattr request. 1486 * @return 0 for success, or an error code. 1487 */ 1488 extern errno_t VNOP_SETXATTR(vnode_t vp, const char *name, uio_t uio, int options, vfs_context_t ctx); 1489 1490 struct vnop_removexattr_args { 1491 struct vnodeop_desc *a_desc; 1492 vnode_t a_vp; 1493 const char * a_name; 1494 int a_options; 1495 vfs_context_t a_context; 1496 }; 1497 extern struct vnodeop_desc vnop_removexattr_desc; 1498 1499 /*! 1500 * @function VNOP_REMOVEXATTR 1501 * @abstract Remove extended file attributes. 1502 * @param vp The vnode from which to remove extended attributes. 1503 * @param name Which attribute to delete. 1504 * @param options XATTR_NOSECURITY: bypass security-checking. 1505 * @param ctx Context to authenticate for attribute delete request. 1506 * @return 0 for success, or an error code. 1507 */ 1508 #ifdef XNU_KERNEL_PRIVATE 1509 extern errno_t VNOP_REMOVEXATTR(vnode_t, const char *, int, vfs_context_t); 1510 #endif /* XNU_KERNEL_PRIVATE */ 1511 1512 struct vnop_listxattr_args { 1513 struct vnodeop_desc *a_desc; 1514 vnode_t a_vp; 1515 uio_t a_uio; 1516 size_t *a_size; 1517 int a_options; 1518 vfs_context_t a_context; 1519 }; 1520 extern struct vnodeop_desc vnop_listxattr_desc; 1521 1522 /*! 1523 * @function VNOP_LISTXATTR 1524 * @abstract List extended attribute keys. 1525 * @discussion Should write a sequence of unseparated, null-terminated extended-attribute 1526 * names into the space described by the provided uio. These keys can then be passed to 1527 * getxattr() (and VNOP_GETXATTR()). 1528 * @param vp The vnode for which to get extended attribute keys. 1529 * @param uio Description of target memory for attribute keys. 1530 * @param size Should be set to amount of data written to buffer. 1531 * @param options XATTR_NOSECURITY: bypass security checking. 1532 * @param ctx Context to authenticate for attribute name request. 1533 */ 1534 #ifdef XNU_KERNEL_PRIVATE 1535 extern errno_t VNOP_LISTXATTR(vnode_t, uio_t, size_t *, int, vfs_context_t); 1536 #endif /* XNU_KERNEL_PRIVATE */ 1537 1538 struct vnop_blktooff_args { 1539 struct vnodeop_desc *a_desc; 1540 vnode_t a_vp; 1541 daddr64_t a_lblkno; 1542 off_t *a_offset; 1543 }; 1544 1545 /*! 1546 * @function VNOP_BLKTOOFF 1547 * @abstract Call down to a filesystem to convert a logical block number to a file offset. 1548 * @discussion VNOP_BLKTOOFF() converts a logical block to a file offset in bytes. That offset 1549 * can be passed to VNOP_BLOCKMAP(), then, to get a physical block number--buf_strategy() does this. 1550 * @param vp The vnode for which to convert a logical block to an offset. 1551 * @param lblkno Logical block number to turn into offset. 1552 * @param offset Destination for file offset. 1553 * @return 0 for success, else an error code. 1554 */ 1555 #ifdef XNU_KERNEL_PRIVATE 1556 extern errno_t VNOP_BLKTOOFF(vnode_t, daddr64_t, off_t *); 1557 #endif /* XNU_KERNEL_PRIVATE */ 1558 1559 struct vnop_offtoblk_args { 1560 struct vnodeop_desc *a_desc; 1561 vnode_t a_vp; 1562 off_t a_offset; 1563 daddr64_t *a_lblkno; 1564 }; 1565 1566 /*! 1567 * @function VNOP_OFFTOBLK 1568 * @abstract Call down to a filesystem to convert a file offset to a logical block number. 1569 * @param vp The vnode for which to convert an offset to a logical block number. 1570 * @param offset File offset to convert. 1571 * @param lblkno Destination for corresponding logical block number. 1572 * @return 0 for success, else an error code. 1573 */ 1574 #ifdef XNU_KERNEL_PRIVATE 1575 extern errno_t VNOP_OFFTOBLK(vnode_t, off_t, daddr64_t *); 1576 #endif /* XNU_KERNEL_PRIVATE */ 1577 1578 struct vnop_blockmap_args { 1579 struct vnodeop_desc *a_desc; 1580 vnode_t a_vp; 1581 off_t a_foffset; 1582 size_t a_size; 1583 daddr64_t *a_bpn; 1584 size_t *a_run; 1585 void *a_poff; 1586 int a_flags; 1587 vfs_context_t a_context; 1588 }; 1589 1590 /*! 1591 * @function VNOP_BLOCKMAP 1592 * @abstract Call down to a filesystem to get information about the on-disk layout of a file region. 1593 * @discussion VNOP_BLOCKMAP() returns the information required to pass a request for a contiguous region 1594 * down to a device's strategy routine. 1595 * @param vp The vnode for which to get on-disk information. 1596 * @param foffset Offset (in bytes) at which region starts. 1597 * @param size Size of region. 1598 * @param bpn Destination for physical block number at which region begins on disk. 1599 * @param run Destination for number of bytes which can be found contiguously on-disk before 1600 * first discontinuity. 1601 * @param poff Currently unused. 1602 * @param flags VNODE_READ: request is for a read. VNODE_WRITE: request is for a write. 1603 * @param ctx Context to authenticate for blockmap request; currently often set to NULL. 1604 * @return 0 for success, else an error code. 1605 */ 1606 #ifdef XNU_KERNEL_PRIVATE 1607 extern errno_t VNOP_BLOCKMAP(vnode_t, off_t, size_t, daddr64_t *, size_t *, void *, 1608 int, vfs_context_t); 1609 #endif /* XNU_KERNEL_PRIVATE */ 1610 1611 struct vnop_strategy_args { 1612 struct vnodeop_desc *a_desc; 1613 struct buf *a_bp; 1614 }; 1615 1616 /*! 1617 * @function VNOP_STRATEGY 1618 * @abstract Initiate I/O on a file (both read and write). 1619 * @discussion A filesystem strategy routine takes a buffer, performs whatever manipulations are necessary for passing 1620 * the I/O request down to the device layer, and calls the appropriate device's strategy routine. Most filesystems should 1621 * just call buf_strategy() with "bp" as the argument. 1622 * @param bp Complete specificiation of requested I/O: region of data involved, whether request is for read or write, and so on. 1623 * @return 0 for success, else an error code. 1624 */ 1625 extern errno_t VNOP_STRATEGY(struct buf *bp); 1626 1627 struct vnop_bwrite_args { 1628 struct vnodeop_desc *a_desc; 1629 buf_t a_bp; 1630 }; 1631 1632 /*! 1633 * @function VNOP_BWRITE 1634 * @abstract Write a buffer to backing store. 1635 * @discussion VNOP_BWRITE() is called by buf_bawrite() (asynchronous write) and potentially by buf_bdwrite() (delayed write) 1636 * but not by buf_bwrite(). A filesystem may choose to perform some kind of manipulation of the buffer in this routine; it 1637 * generally will end up calling VFS's default implementation, vn_bwrite() (which calls buf_bwrite() without further ado). 1638 * @param bp The buffer to write. 1639 * @return 0 for success, else an error code. 1640 */ 1641 extern errno_t VNOP_BWRITE(buf_t bp); 1642 1643 struct vnop_kqfilt_add_args { 1644 struct vnodeop_desc *a_desc; 1645 struct vnode *a_vp; 1646 struct knote *a_kn; 1647 vfs_context_t a_context; 1648 }; 1649 extern struct vnodeop_desc vnop_kqfilt_add_desc; 1650 1651 #ifdef XNU_KERNEL_PRIVATE 1652 extern errno_t VNOP_KQFILT_ADD(vnode_t, struct knote *, vfs_context_t); 1653 #endif /* XNU_KERNEL_PRIVATE */ 1654 1655 struct vnop_kqfilt_remove_args { 1656 struct vnodeop_desc *a_desc; 1657 struct vnode *a_vp; 1658 uintptr_t a_ident; 1659 vfs_context_t a_context; 1660 }; 1661 extern struct vnodeop_desc vnop_kqfilt_remove_desc; 1662 1663 #ifdef XNU_KERNEL_PRIVATE 1664 errno_t VNOP_KQFILT_REMOVE(vnode_t, uintptr_t, vfs_context_t); 1665 #endif /* XNU_KERNEL_PRIVATE */ 1666 1667 #define VNODE_MONITOR_BEGIN 0x01 1668 #define VNODE_MONITOR_END 0x02 1669 #define VNODE_MONITOR_UPDATE 0x04 1670 1671 struct vnop_monitor_args { 1672 struct vnodeop_desc *a_desc; 1673 vnode_t a_vp; 1674 uint32_t a_events; 1675 uint32_t a_flags; 1676 void *a_handle; 1677 vfs_context_t a_context; 1678 }; 1679 1680 /*! 1681 * @function VNOP_MONITOR 1682 * @abstract Indicate to a filesystem that the number of watchers of a file has changed. 1683 * @param vp The vnode whose watch state has changed. 1684 * @param events Unused. Filesystems can ignore this parameter. 1685 * @param flags Type of change to the watch state. VNODE_MONITOR_BEGIN is passed when the kernel 1686 * begins tracking a new watcher of a file. VNODE_MONITOR_END is passed when a watcher stops watching a file. 1687 * VNODE_MONITOR_UPDATE is currently unused. A filesystem is guaranteed that each VNODE_MONITOR_BEGIN 1688 * will be matched by a VNODE_MONITOR_END with the same "handle" argument. 1689 * @param handle Unique identifier for a given watcher. A VNODE_MONITOR_BEGIN for a given handle will be matched with a 1690 * VNODE_MONITOR_END for the same handle; a filesystem need not consider this parameter unless 1691 * it for some reason wants be able to match specific VNOP_MONITOR calls rather than just keeping 1692 * a count. 1693 * @param ctx The context which is starting to monitor a file or ending a watch on a file. A matching 1694 * pair of VNODE_MONITOR_BEGIN and VNODE_MONITOR_END need not have the same context. 1695 * @discussion VNOP_MONITOR() is intended to let networked filesystems know when they should bother 1696 * listening for changes to files which occur remotely, so that they can post notifications using 1697 * vnode_notify(). Local filesystems should not implement a monitor vnop. 1698 * It is called when there is a new watcher for a file or when a watcher for a file goes away. 1699 * Each BEGIN will be matched with an END with the same handle. Note that vnode_ismonitored() can 1700 * be used to see if there are currently watchers for a file. 1701 */ 1702 #ifdef XNU_KERNEL_PRIVATE 1703 errno_t VNOP_MONITOR(vnode_t vp, uint32_t events, uint32_t flags, void *handle, vfs_context_t ctx); 1704 #endif /* XNU_KERNEL_PRIVATE */ 1705 1706 struct label; 1707 struct vnop_setlabel_args { 1708 struct vnodeop_desc *a_desc; 1709 struct vnode *a_vp; 1710 struct label *a_vl; 1711 vfs_context_t a_context; 1712 }; 1713 extern struct vnodeop_desc vnop_setlabel_desc; 1714 1715 /*! 1716 * @function VNOP_SETLABEL 1717 * @abstract Associate a MACF label with a file. 1718 * @param vp The vnode to label. 1719 * @param label The desired label. 1720 * @param ctx Context to authenticate for label change. 1721 * @return 0 for success, else an error code. 1722 */ 1723 #ifdef XNU_KERNEL_PRIVATE 1724 errno_t VNOP_SETLABEL(vnode_t, struct label *, vfs_context_t); 1725 #endif /* XNU_KERNEL_PRIVATE */ 1726 1727 #ifdef __APPLE_API_UNSTABLE 1728 1729 #if NAMEDSTREAMS 1730 1731 enum nsoperation { NS_OPEN, NS_CREATE, NS_DELETE }; 1732 1733 /* a_flags for vnop_getnamedstream_args: */ 1734 #define NS_GETRAWENCRYPTED 0x00000001 1735 1736 struct vnop_getnamedstream_args { 1737 struct vnodeop_desc *a_desc; 1738 vnode_t a_vp; 1739 vnode_t *a_svpp; 1740 const char *a_name; 1741 enum nsoperation a_operation; 1742 int a_flags; 1743 vfs_context_t a_context; 1744 }; 1745 1746 /*! 1747 * @function VNOP_GETNAMEDSTREAM 1748 * @abstract Get a named stream associated with a file. 1749 * @discussion If this call sucecss, svpp should be returned with an iocount which the caller 1750 * will drop. VFS provides a facility for simulating named streams when interacting with filesystems 1751 * which do not support them. 1752 * @param vp The vnode for which to get a named stream. 1753 * @param svpp Destination for pointer to named stream's vnode. 1754 * @param name The name of the named stream, e.g. "com.apple.ResourceFork". 1755 * @param operation Operation to perform. In HFS and AFP, this parameter is only considered as follows: 1756 * if the resource fork has not been opened and the operation is not NS_OPEN, fail with ENOATTR. Currently 1757 * only passed as NS_OPEN by VFS. 1758 * @param flags Flags used to control getnamedstream behavior. Currently only used for raw-encrypted-requests. 1759 * @param ctx Context to authenticate for getting named stream. 1760 * @return 0 for success, else an error code. 1761 */ 1762 #ifdef XNU_KERNEL_PRIVATE 1763 extern errno_t VNOP_GETNAMEDSTREAM(vnode_t, vnode_t *, const char *, enum nsoperation, int flags, vfs_context_t); 1764 #endif /* XNU_KERNEL_PRIVATE */ 1765 1766 struct vnop_makenamedstream_args { 1767 struct vnodeop_desc *a_desc; 1768 vnode_t *a_svpp; 1769 vnode_t a_vp; 1770 const char *a_name; 1771 int a_flags; 1772 vfs_context_t a_context; 1773 }; 1774 1775 /*! 1776 * @function VNOP_MAKENAMEDSTREAM 1777 * @abstract Create a named stream associated with a file. 1778 * @discussion If this call succeeds, svpp should be returned with an iocount which the caller will drop. 1779 * VFS provides a facility for simulating named streams when interacting with filesystems 1780 * which do not support them. 1781 * @param vp The vnode for which to get a named stream. 1782 * @param svpp Destination for pointer to named stream's vnode. 1783 * @param name The name of the named stream, e.g. "com.apple.ResourceFork". 1784 * @param flags Currently unused. 1785 * @param ctx Context to authenticate creating named stream. 1786 * @return 0 for success, else an error code. 1787 */ 1788 #ifdef XNU_KERNEL_PRIVATE 1789 extern errno_t VNOP_MAKENAMEDSTREAM(vnode_t, vnode_t *, const char *, int flags, vfs_context_t); 1790 #endif /* XNU_KERNEL_PRIVATE */ 1791 1792 struct vnop_removenamedstream_args { 1793 struct vnodeop_desc *a_desc; 1794 vnode_t a_vp; 1795 vnode_t a_svp; 1796 const char *a_name; 1797 int a_flags; 1798 vfs_context_t a_context; 1799 }; 1800 1801 /*! 1802 * @function VNOP_REMOVENAMEDSTREAM 1803 * @abstract Delete a named stream associated with a file. 1804 * @discussion VFS provides a facility for simulating named streams when interacting with filesystems 1805 * which do not support them. 1806 * @param vp The vnode to which the named stream belongs. 1807 * @param svp The named stream's vnode. 1808 * @param name The name of the named stream, e.g. "com.apple.ResourceFork". 1809 * @param flags Currently unused. 1810 * @param ctx Context to authenticate deleting named stream. 1811 * @return 0 for success, else an error code. 1812 */ 1813 #ifdef XNU_KERNEL_PRIVATE 1814 extern errno_t VNOP_REMOVENAMEDSTREAM(vnode_t, vnode_t, const char *, int flags, vfs_context_t); 1815 #endif /* XNU_KERNEL_PRIVATE */ 1816 1817 #endif // NAMEDSTREAMS 1818 1819 __options_decl(vnode_verify_flags_t, uint32_t, { 1820 VNODE_VERIFY_DEFAULT = 0, 1821 VNODE_VERIFY_CONTEXT_ALLOC = 1, 1822 VNODE_VERIFY_WITH_CONTEXT = 2, 1823 VNODE_VERIFY_CONTEXT_FREE = 4, 1824 }); 1825 1826 #define VNODE_VERIFY_DEFAULT VNODE_VERIFY_DEFAULT 1827 #define VNODE_VERIFY_WITH_CONTEXT VNODE_VERIFY_WITH_CONTEXT 1828 1829 struct vnop_verify_args { 1830 struct vnodeop_desc *a_desc; 1831 vnode_t a_vp; 1832 off_t a_foffset; 1833 uint8_t *a_buf; 1834 size_t a_bufsize; 1835 size_t *a_verifyblksize; 1836 void **a_verify_ctxp; 1837 vnode_verify_flags_t a_flags; 1838 vfs_context_t a_context; 1839 }; 1840 1841 /*! 1842 * @function VNOP_VERIFY 1843 * @abstract Call down to a filesystem to verify file data for integrity. 1844 * @discussion VNOP_VERIFY() returns whether file data being read has been verified to be what was written. 1845 * This does not impose a specific mechanism for ensuring integrity beyond requiring that this be done in 1846 * multiples of a verify block size (analogous to a filesystem block size but it can be per file) 1847 * @param vp The vnode for which data is to be verified. 1848 * @param foffset Offset (in bytes) at which region to be verified starts. 1849 * @param buf buffer containing file data at foffset. If this is NULL, then only the verification block size is 1850 * being requested. 1851 * @param bufsize size of data buffer to be verified. 1852 * @param verifyblksize pointer to size of verification block size in use for this file. If the verification block size is 0, 1853 * no verification will be performed. The verification block size can be any value which is a power of two upto 128KiB. 1854 * @param verify_ctxp context for verification to allocated by the FS and used in verification. 1855 * @param flags modifier flags. 1856 * @param ctx Context to authenticate for verify request; currently often set to NULL. 1857 * @return 0 for success, else an error code. 1858 */ 1859 #ifdef XNU_KERNEL_PRIVATE 1860 extern errno_t VNOP_VERIFY(vnode_t, off_t, uint8_t *, size_t, size_t *, void **, vnode_verify_flags_t, vfs_context_t); 1861 #endif /* XNU_KERNEL_PRIVATE */ 1862 1863 #endif // defined(__APPLE_API_UNSTABLE) 1864 1865 __END_DECLS 1866 1867 #endif /* KERNEL */ 1868 1869 #pragma clang diagnostic pop /* #pragma clang diagnostic ignored "-Wdocumentation" */ 1870 #endif /* !_SYS_VNODE_IF_H_ */ 1871