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