/ duct-tape / xnu / bsd / sys / vnode_if.h
vnode_if.h
   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  
 795  	VFS_RENAME_FLAGS_MASK   = (VFS_RENAME_SECLUDE | VFS_RENAME_SWAP
 796  	    | VFS_RENAME_EXCL),
 797  };
 798  
 799  struct vnop_renamex_args {
 800  	struct vnodeop_desc *a_desc;
 801  	vnode_t a_fdvp;
 802  	vnode_t a_fvp;
 803  	struct componentname *a_fcnp;
 804  	vnode_t a_tdvp;
 805  	vnode_t a_tvp;
 806  	struct componentname *a_tcnp;
 807  	struct vnode_attr *a_vap;               // Reserved for future use
 808  	vfs_rename_flags_t a_flags;
 809  	vfs_context_t a_context;
 810  };
 811  
 812  /*!
 813   *  @function VNOP_RENAMEX
 814   *  @abstract Call down to a filesystem to rename a file.
 815   *  @discussion VNOP_RENAMEX() will only be called with a source and target on the same volume.
 816   *  @param fdvp Directory in which source file resides.
 817   *  @param fvp File being renamed.
 818   *  @param fcnp Name information for source file.
 819   *  @param tdvp Directory file is being moved to.
 820   *  @param tvp Existing file with same name as target, should one exist.
 821   *  @param tcnp Name information for target path.
 822   *  @param flags Control certain rename semantics.
 823   *  @param ctx Context to authenticate for rename request.
 824   *  @return 0 for success, else an error code.
 825   */
 826  #ifdef XNU_KERNEL_PRIVATE
 827  extern errno_t VNOP_RENAMEX(vnode_t, vnode_t, struct componentname *, vnode_t, vnode_t, struct componentname *, vfs_rename_flags_t, vfs_context_t);
 828  #endif /* XNU_KERNEL_PRIVATE */
 829  
 830  #ifdef KERNEL_PRIVATE
 831  struct vnop_compound_rename_args {
 832  	struct vnodeop_desc *a_desc;
 833  
 834  	vnode_t a_fdvp;                 /* Directory from which to rename */
 835  	vnode_t *a_fvpp;                /* Vnode to rename (can point to a NULL pointer) */
 836  	struct componentname *a_fcnp;   /* Source name */
 837  	struct vnode_attr *a_fvap;
 838  
 839  	vnode_t a_tdvp;                 /* Directory to which to rename */
 840  	vnode_t *a_tvpp;                /* Vnode to rename over (can point to a NULL pointer) */
 841  	struct componentname *a_tcnp;   /* Destination name */
 842  	struct vnode_attr *a_tvap;
 843  
 844  	uint32_t a_flags;               /* Control flags: currently unused */
 845  	vfs_context_t a_context;        /* Authorization context */
 846  	int (*a_rename_authorizer)(                     /* Authorization callback */
 847  		vnode_t fdvp,                           /* As passed to VNOP */
 848  		vnode_t fvp,                            /* Vnode to rename */
 849  		struct componentname *fcnp,             /* As passed to VNOP */
 850  		vnode_t tdvp,                           /* As passed to VNOP */
 851  		vnode_t tvp,                            /* Vnode to rename over (can be NULL) */
 852  		struct componentname *tcnp,             /* As passed to VNOP */
 853  		vfs_context_t ctx,                      /* As passed to VNOP */
 854  		void *reserved);                        /* Always NULL */
 855  	void *a_reserved;               /* Currently unused */
 856  };
 857  #endif /* KERNEL_PRIVATE */
 858  
 859  #ifdef XNU_KERNEL_PRIVATE
 860  errno_t
 861  VNOP_COMPOUND_RENAME(
 862  	struct vnode *fdvp, struct vnode **fvpp, struct componentname *fcnp, struct vnode_attr *fvap,
 863  	struct vnode *tdvp, struct vnode **tvpp, struct componentname *tcnp, struct vnode_attr *tvap,
 864  	uint32_t flags, vfs_context_t ctx);
 865  #endif /* XNU_KERNEL_PRIVATE */
 866  
 867  struct vnop_mkdir_args {
 868  	struct vnodeop_desc *a_desc;
 869  	vnode_t a_dvp;
 870  	vnode_t *a_vpp;
 871  	struct componentname *a_cnp;
 872  	struct vnode_attr *a_vap;
 873  	vfs_context_t a_context;
 874  };
 875  
 876  /*!
 877   *  @function VNOP_MKDIR
 878   *  @abstract Call down to a filesystem to create a directory.
 879   *  @discussion The newly created directory should be returned with an iocount which will be dropped by the caller.
 880   *  @param dvp Directory in which to create new directory.
 881   *  @param vpp Destination for pointer to new directory's vnode.
 882   *  @param cnp Name information for new directory.
 883   *  @param vap Attributes for new directory.
 884   *  @param ctx Context to authenticate for mkdir request.
 885   *  @return 0 for success, else an error code.
 886   */
 887  #ifdef XNU_KERNEL_PRIVATE
 888  extern errno_t VNOP_MKDIR(vnode_t, vnode_t *, struct componentname *, struct vnode_attr *, vfs_context_t);
 889  #endif /* XNU_KERNEL_PRIVATE */
 890  
 891  
 892  #ifdef KERNEL_PRIVATE
 893  struct vnop_compound_mkdir_args {
 894  	struct vnodeop_desc *a_desc;
 895  	vnode_t a_dvp;                  /* Directory in which to create */
 896  	vnode_t *a_vpp;                 /* Destination for found or created vnode */
 897  	struct componentname *a_cnp;    /* Name of directory to create */
 898  	struct vnode_attr *a_vap;       /* Creation attributes */
 899  	uint32_t a_flags;               /* Control flags (unused) */
 900  	vfs_context_t a_context;        /* Authorization context */
 901  #if 0
 902  	int (*a_mkdir_authorizer)(vnode_t dvp, struct componentname *cnp, struct vnode_attr *vap, vfs_context_t ctx, void *reserved);
 903  #endif /* 0 */
 904  	void *a_reserved;               /* Unused */
 905  };
 906  #endif /* KERNEL_PRIVATE */
 907  
 908  #ifdef XNU_KERNEL_PRIVATE
 909  extern errno_t VNOP_COMPOUND_MKDIR(vnode_t, vnode_t *, struct nameidata *, struct vnode_attr *, vfs_context_t);
 910  #endif /* XNU_KERNEL_PRIVATE */
 911  
 912  struct vnop_rmdir_args {
 913  	struct vnodeop_desc *a_desc;
 914  	vnode_t a_dvp;
 915  	vnode_t a_vp;
 916  	struct componentname *a_cnp;
 917  	vfs_context_t a_context;
 918  };
 919  
 920  /*!
 921   *  @function VNOP_RMDIR
 922   *  @abstract Call down to a filesystem to delete a directory.
 923   *  @param dvp Parent of directory to be removed.
 924   *  @param vp Directory to remove.
 925   *  @param cnp Name information for directory to be deleted.
 926   *  @param ctx Context to authenticate for rmdir request.
 927   *  @return 0 for success, else an error code.
 928   */
 929  #ifdef XNU_KERNEL_PRIVATE
 930  extern errno_t VNOP_RMDIR(vnode_t, vnode_t, struct componentname *, vfs_context_t);
 931  #endif /* XNU_KERNEL_PRIVATE */
 932  
 933  #ifdef KERNEL_PRIVATE
 934  struct vnop_compound_rmdir_args {
 935  	struct vnodeop_desc *a_desc;
 936  	vnode_t a_dvp;                          /* Directory in which to look up and delete */
 937  	vnode_t *a_vpp;                         /* Destination for found vnode */
 938  	struct componentname *a_cnp;            /* Name to delete */
 939  	struct vnode_attr *a_vap;               /* Location in which to store attributes if delete succeeds (can be NULL) */
 940  	uint32_t a_flags;                       /* Control flags (currently unused) */
 941  	vfs_context_t a_context;                /* Context for authorization */
 942  	int (*a_rmdir_authorizer)(              /* Authorization callback */
 943  		vnode_t dvp,                            /* As passed to VNOP */
 944  		vnode_t vp,                             /* Directory to delete */
 945  		struct componentname *cnp,              /* As passed to VNOP */
 946  		vfs_context_t ctx,                      /* As passed to VNOP */
 947  		void *reserved);                        /* Always NULL */
 948  	void *a_reserved;                       /* Unused */
 949  };
 950  #endif /* KERNEL_PRIVATE */
 951  
 952  #ifdef XNU_KERNEL_PRIVATE
 953  extern errno_t VNOP_COMPOUND_RMDIR(vnode_t, vnode_t*, struct nameidata *, struct vnode_attr *vap, vfs_context_t);
 954  #endif /* XNU_KERNEL_PRIVATE */
 955  
 956  
 957  struct vnop_symlink_args {
 958  	struct vnodeop_desc *a_desc;
 959  	vnode_t a_dvp;
 960  	vnode_t *a_vpp;
 961  	struct componentname *a_cnp;
 962  	struct vnode_attr *a_vap;
 963  	char *a_target;
 964  	vfs_context_t a_context;
 965  };
 966  
 967  /*!
 968   *  @function VNOP_SYMLINK
 969   *  @abstract Call down to a filesystem to create a symbolic link.
 970   *  @param If VNOP_SYMLINK() is successful, the new file should be returned with an iocount which will
 971   *  be dropped by the caller.  VFS does not ensure that the target path will have a length shorter
 972   *  than the max symlink length for the filesystem.
 973   *  @param dvp Parent directory for new symlink file.
 974   *  @param vpp
 975   *  @param cnp Name information for new symlink.
 976   *  @param vap Attributes for symlink.
 977   *  @param target Path for symlink to store; for "ln -s /var/vardir linktovardir", "target" would be "/var/vardir"
 978   *  @param ctx Context to authenticate for symlink request.
 979   *  @return 0 for success, else an error code.
 980   */
 981  #ifdef XNU_KERNEL_PRIVATE
 982  extern errno_t VNOP_SYMLINK(vnode_t, vnode_t *, struct componentname *, struct vnode_attr *, char *, vfs_context_t);
 983  #endif /* XNU_KERNEL_PRIVATE */
 984  
 985  /*
 986   *
 987   *  When VNOP_READDIR is called from the NFS Server, the nfs_data
 988   *  argument is non-NULL.
 989   *
 990   *  The value of nfs_eofflag should be set to TRUE if the end of
 991   *  the directory was reached while reading.
 992   *
 993   *  The directory seek offset (cookies) are returned to the NFS client and
 994   *  may be used later to restart a directory read part way through
 995   *  the directory. There is one cookie returned for each directory
 996   *  entry returned and its size is determince from nfs_sizeofcookie.
 997   *  The value of the cookie should be the logical offset within the
 998   *  directory where the on-disc version of the appropriate directory
 999   *  entry starts. Memory for the cookies is allocated from M_TEMP
1000   *  and it is freed by the caller of VNOP_READDIR.
1001   *
1002   */
1003  
1004  struct vnop_readdir_args {
1005  	struct vnodeop_desc *a_desc;
1006  	vnode_t a_vp;
1007  	struct uio *a_uio;
1008  	int a_flags;
1009  	int *a_eofflag;
1010  	int *a_numdirent;
1011  	vfs_context_t a_context;
1012  };
1013  
1014  /*!
1015   *  @function VNOP_READDIR
1016   *  @abstract Call down to a filesystem to enumerate directory entries.
1017   *  @discussion VNOP_READDIR() packs a buffer with "struct dirent" directory entry representations as described
1018   *  by the "getdirentries" manual page.
1019   *  @param vp Directory to enumerate.
1020   *  @param uio Destination information for resulting direntries.
1021   *  @param flags VNODE_READDIR_EXTENDED, VNODE_READDIR_REQSEEKOFF, VNODE_READDIR_SEEKOFF32: Apple-internal flags.
1022   *  @param eofflag Should be set to 1 if the end of the directory has been reached.
1023   *  @param numdirent Should be set to number of entries written into buffer.
1024   *  @param ctx Context to authenticate for readdir request.
1025   *  @return 0 for success, else an error code.
1026   */
1027  #ifdef XNU_KERNEL_PRIVATE
1028  extern errno_t VNOP_READDIR(vnode_t, struct uio *, int, int *, int *, vfs_context_t);
1029  #endif /* XNU_KERNEL_PRIVATE */
1030  
1031  struct vnop_readdirattr_args {
1032  	struct vnodeop_desc *a_desc;
1033  	vnode_t a_vp;
1034  	struct attrlist *a_alist;
1035  	struct uio *a_uio;
1036  	uint32_t a_maxcount;
1037  	uint32_t a_options;
1038  	uint32_t *a_newstate;
1039  	int *a_eofflag;
1040  	uint32_t *a_actualcount;
1041  	vfs_context_t a_context;
1042  };
1043  
1044  /*!
1045   *  @function VNOP_READDIRATTR
1046   *  @abstract Call down to get file attributes for many files in a directory at once.
1047   *  @discussion VNOP_READDIRATTR() packs a buffer  with file attributes, as if the results of many "getattrlist" calls.
1048   *  @param vp Directory in which to enumerate entries' attributes.
1049   *  @param alist Which attributes are wanted for each directory entry.
1050   *  @param uio Destination information for resulting attributes.
1051   *  @param maxcount Maximum count of files to get attributes for.
1052   *  @param options FSOPT_NOFOLLOW: do not follow symbolic links. FSOPT_NOINMEMUPDATE: do not use data which have been
1053   *  updated since an inode was loaded into memory.
1054   *  @param newstate The "newstate" should be set to a value which changes if the contents of a directory change
1055   *  through an addition or deletion but stays the same otherwise.
1056   *  @param eofflag Should be set to 1 if the end of the directory has been reached.
1057   *  @param actualcount Should be set to number of files whose attributes were  written into buffer.
1058   *  @param ctx Context to authenticate for readdirattr request.
1059   *  @return 0 for success, else an error code.
1060   */
1061  #ifdef XNU_KERNEL_PRIVATE
1062  extern errno_t VNOP_READDIRATTR(vnode_t, struct attrlist *, struct uio *, uint32_t, uint32_t, uint32_t *, int *, uint32_t *, vfs_context_t);
1063  #endif /* XNU_KERNEL_PRIVATE */
1064  
1065  struct vnop_getattrlistbulk_args {
1066  	struct vnodeop_desc *a_desc;
1067  	vnode_t a_vp;
1068  	struct attrlist *a_alist;
1069  	struct vnode_attr *a_vap;
1070  	struct uio *a_uio;
1071  	void *a_private;
1072  	uint64_t a_options;
1073  	int32_t *a_eofflag;
1074  	int32_t *a_actualcount;
1075  	vfs_context_t a_context;
1076  };
1077  
1078  /*!
1079   *  @function VNOP_GETATTRLISTBULK
1080   *  @abstract Call down to get file attributes for many files in a directory at once.
1081   *  @discussion VNOP_GETATTRLISTBULK() packs a buffer  with file attributes, as if the results of many "getattrlist" calls.
1082   *  @param vp Directory in which to enumerate entries' attributes.
1083   *  @param alist Which attributes are wanted for each directory entry.
1084   *  @param uio Destination information for resulting attributes.
1085   *  @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.
1086   *  @param private reserved for future use.
1087   *  @param options
1088   *  @param eofflag Should be set to 1 if the end of the directory has been reached.
1089   *  @param actualcount Should be set to number of files whose attributes were  written into buffer.
1090   *  @param ctx Context to authenticate for getattrlistbulk request.
1091   *  @return 0 for success, else an error code.
1092   */
1093  #ifdef XNU_KERNEL_PRIVATE
1094  extern errno_t VNOP_GETATTRLISTBULK(vnode_t, struct attrlist *, struct vnode_attr *, uio_t, void *, uint64_t, int32_t *, int32_t *, vfs_context_t);
1095  #endif /* XNU_KERNEL_PRIVATE */
1096  
1097  struct vnop_readlink_args {
1098  	struct vnodeop_desc *a_desc;
1099  	vnode_t a_vp;
1100  	struct uio *a_uio;
1101  	vfs_context_t a_context;
1102  };
1103  
1104  /*!
1105   *  @function VNOP_READLINK
1106   *  @abstract Call down to a filesystem to get the pathname represented by a symbolic link.
1107   *  @discussion VNOP_READLINK() gets the path stored in a symbolic link; it is called by namei() and the readlink() system call.
1108   *  @param vp Symbolic link to read from.
1109   *  @param uio Destination information for link path.
1110   *  @param ctx Context to authenticate for readlink request.
1111   *  @return 0 for success, else an error code.
1112   */
1113  #ifdef XNU_KERNEL_PRIVATE
1114  extern errno_t VNOP_READLINK(vnode_t, struct uio *, vfs_context_t);
1115  #endif /* XNU_KERNEL_PRIVATE */
1116  
1117  struct vnop_inactive_args {
1118  	struct vnodeop_desc *a_desc;
1119  	vnode_t a_vp;
1120  	vfs_context_t a_context;
1121  };
1122  
1123  /*!
1124   *  @function VNOP_INACTIVE
1125   *  @abstract Notify a filesystem that the last usecount (persistent reference) on a vnode has been dropped.
1126   *  @discussion VNOP_INACTVE() gives a filesystem a chance to aggressively release resources assocated with a vnode, perhaps
1127   *  even to call vnode_recycle(), but no action is prescribed; it is acceptable for VNOP_INACTIVE to be a no-op and
1128   *  to defer all reclamation until VNOP_RECLAIM().
1129   *  VNOP_INACTVE() will not be called on a vnode if no persistent reference is ever taken; an
1130   *  important example is a stat(), which takes an iocount, reads its data, and drops that iocount.
1131   *  @param vp The vnode which is now inactive.
1132   *  @param ctx Context to authenticate for inactive message.
1133   *  @return 0 for success, else an error code, but return value is currently ignored.
1134   */
1135  #ifdef XNU_KERNEL_PRIVATE
1136  extern errno_t VNOP_INACTIVE(vnode_t, vfs_context_t);
1137  #endif /* XNU_KERNEL_PRIVATE */
1138  
1139  struct vnop_reclaim_args {
1140  	struct vnodeop_desc *a_desc;
1141  	vnode_t a_vp;
1142  	vfs_context_t a_context;
1143  };
1144  
1145  /*!
1146   *  @function VNOP_RECLAIM
1147   *  @abstract Release filesystem-internal resources for a vnode.
1148   *  @discussion VNOP_RECLAIM() is called as part of the process of recycling a vnode.  During
1149   *  a reclaim routine, a filesystem should remove a vnode from its hash and deallocate any resources
1150   *  allocated to that vnode.  VFS guarantees that when VNOP_RECLAIM() is called, there are no more
1151   *  iocount references on a vnode (though there may still be usecount references--these are invalidated
1152   *  by the reclaim) and that no more will be granted.  This means in practice that there will be no
1153   *  filesystem calls on the vnode being reclaimed until the reclaim has finished and the vnode has
1154   *  been reused.
1155   *  @param vp The vnode to reclaim.
1156   *  @param ctx Context to authenticate for reclaim.
1157   *  @return 0 for success, or an error code.  A nonzero return value results in a panic.
1158   */
1159  #ifdef XNU_KERNEL_PRIVATE
1160  extern errno_t VNOP_RECLAIM(vnode_t, vfs_context_t);
1161  #endif /* XNU_KERNEL_PRIVATE */
1162  
1163  struct vnop_pathconf_args {
1164  	struct vnodeop_desc *a_desc;
1165  	vnode_t a_vp;
1166  	int a_name;
1167  	int32_t *a_retval;
1168  	vfs_context_t a_context;
1169  };
1170  
1171  /*!
1172   *  @function VNOP_PATHCONF
1173   *  @abstract Query a filesystem for path properties.
1174   *  @param vp The vnode whose filesystem to query.
1175   *  @param name Which property to request: see unistd.h.  For example: _PC_CASE_SENSITIVE (is
1176   *  a filesystem case-sensitive?).  Only one property can be requested at a time.
1177   *  @param retval Destination for value of property.
1178   *  @param ctx Context to authenticate for pathconf request.
1179   *  @return 0 for success, or an error code.
1180   */
1181  #ifdef XNU_KERNEL_PRIVATE
1182  extern errno_t VNOP_PATHCONF(vnode_t, int, int32_t *, vfs_context_t);
1183  #endif /* XNU_KERNEL_PRIVATE */
1184  
1185  struct vnop_advlock_args {
1186  	struct vnodeop_desc *a_desc;
1187  	vnode_t a_vp;
1188  	caddr_t a_id;
1189  	int a_op;
1190  	struct flock *a_fl;
1191  	int a_flags;
1192  	vfs_context_t a_context;
1193  	struct timespec *a_timeout;
1194  };
1195  
1196  /*!
1197   *  @function VNOP_ADVLOCK
1198   *  @abstract Aquire or release and advisory lock on a vnode.
1199   *  @discussion Advisory locking is somewhat complicated.  VNOP_ADVLOCK is overloaded for
1200   *  both flock() and POSIX advisory locking usage, though not all filesystems support both (or any).  VFS
1201   *  provides an advisory locking mechanism for filesystems which can take advantage of it; vfs_setlocklocal()
1202   *  marks a filesystem as using VFS advisory locking support.
1203   *  @param vp The vnode to lock or unlock.
1204   *  @param id Identifier for lock holder: ignored by most filesystems.
1205   *  @param op Which locking operation: F_SETLK: set locking information about a region.
1206   *  F_GETLK: get locking information about the specified region.  F_UNLCK: Unlock a region.
1207   *  @param fl Description of file region to lock. l_whence is as with "lseek."
1208   *  Includes a type: F_RDLCK (shared lock), F_UNLCK (unlock) , and F_WRLCK (exclusive lock).
1209   *  @param flags F_FLOCK: use flock() semantics. F_POSIX: use POSIX semantics.  F_WAIT: sleep if necessary.
1210   *  F_PROV: Non-coelesced provisional lock (unused in xnu).
1211   *  @param ctx Context to authenticate for advisory locking request.
1212   *  @param timeout Timespec for timeout in case of F_SETLKWTIMEOUT.
1213   *  @return 0 for success, or an error code.
1214   */
1215  #ifdef XNU_KERNEL_PRIVATE
1216  extern errno_t VNOP_ADVLOCK(vnode_t, caddr_t, int, struct flock *, int, vfs_context_t, struct timespec *);
1217  #endif /* XNU_KERNEL_PRIVATE */
1218  
1219  struct vnop_allocate_args {
1220  	struct vnodeop_desc *a_desc;
1221  	vnode_t a_vp;
1222  	off_t a_length;
1223  	u_int32_t a_flags;
1224  	off_t *a_bytesallocated;
1225  	off_t a_offset;
1226  	vfs_context_t a_context;
1227  };
1228  
1229  /*!
1230   *  @function VNOP_ALLOCATE
1231   *  @abstract Pre-allocate space for a file.
1232   *  @discussion VNOP_ALLOCATE() changes the amount of backing store set aside to
1233   *  a file.  It can be used to either shrink or grow a file.  If the file shrinks,
1234   *  its ubc size will be modified accordingly, but if it grows, then the ubc size is unchanged;
1235   *  space is set aside without being actively used by the file.  VNOP_ALLOCATE() is currently only
1236   *  called as part of the F_PREALLOCATE fcntl.
1237   *  @param vp The vnode for which to preallocate space.
1238   *  @param length Desired preallocated file length.
1239   *  @param flags
1240   *  PREALLOCATE:     preallocate allocation blocks.
1241   *  ALLOCATECONTIG:  allocate contigious space.
1242   *  ALLOCATEALL:     allocate all requested space or no space at all.
1243   *  FREEREMAINDER:   deallocate allocated but unfilled blocks.
1244   *  ALLOCATEFROMPEOF: allocate from the physical eof.
1245   *  ALLOCATEFROMVOL:  allocate from the volume offset.
1246   *  @param bytesallocated  Additional bytes set aside for file. Set to 0 if none are allocated
1247   *  OR if the file is contracted.
1248   *  @param offset Hint for where to find free blocks.
1249   *  @param ctx Context to authenticate for allocation request.
1250   *  @return 0 for success, or an error code.
1251   */
1252  #ifdef XNU_KERNEL_PRIVATE
1253  extern errno_t VNOP_ALLOCATE(vnode_t, off_t, u_int32_t, off_t *, off_t, vfs_context_t);
1254  #endif /* XNU_KERNEL_PRIVATE */
1255  
1256  struct vnop_pagein_args {
1257  	struct vnodeop_desc *a_desc;
1258  	vnode_t a_vp;
1259  	upl_t a_pl;
1260  	upl_offset_t a_pl_offset;
1261  	off_t a_f_offset;
1262  	size_t a_size;
1263  	int a_flags;
1264  	vfs_context_t a_context;
1265  };
1266  
1267  /*!
1268   *  @function VNOP_PAGEIN
1269   *  @abstract Pull file data into memory.
1270   *  @discussion VNOP_PAGEIN() is called by when a process faults on data mapped from a file or
1271   *  when madvise() demands pre-fetching.  It is conceptually somewhat similar to VNOP_READ().  Filesystems
1272   *  are typically expected to call cluster_pagein() to handle the labor of mapping and committing the UPL.
1273   *  @param vp The vnode for which to page in data.
1274   *  @param pl UPL describing pages needing to be paged in.
1275   *  @param pl_offset Offset in UPL at which to start placing data.
1276   *  @param f_offset Offset in file of data needing to be paged in.
1277   *  @param size Amount of data to page in (in bytes).
1278   *  @param flags UPL-style flags: UPL_IOSYNC, UPL_NOCOMMIT, UPL_NORDAHEAD, UPL_VNODE_PAGER, UPL_MSYNC.
1279   *  Filesystems should generally leave it to the cluster layer to handle these flags. See the
1280   *  memory_object_types.h header in the kernel framework if interested.
1281   *  @param ctx Context to authenticate for pagein request.
1282   *  @return 0 for success, or an error code.
1283   */
1284  #ifdef XNU_KERNEL_PRIVATE
1285  extern errno_t VNOP_PAGEIN(vnode_t, upl_t, upl_offset_t, off_t, size_t, int, vfs_context_t);
1286  #endif /* XNU_KERNEL_PRIVATE */
1287  
1288  struct vnop_pageout_args {
1289  	struct vnodeop_desc *a_desc;
1290  	vnode_t a_vp;
1291  	upl_t a_pl;
1292  	upl_offset_t a_pl_offset;
1293  	off_t a_f_offset;
1294  	size_t a_size;
1295  	int a_flags;
1296  	vfs_context_t a_context;
1297  };
1298  
1299  /*!
1300   *  @function VNOP_PAGEOUT
1301   *  @abstract Write data from a mapped file back to disk.
1302   *  @discussion VNOP_PAGEOUT() is called when data from a mapped file needs to be flushed to disk, either
1303   *  because of an msync() call or due to memory pressure.  Filesystems are for the most part expected to
1304   *  just call cluster_pageout().   However, if they opt into the VFC_VFSVNOP_PAGEOUTV2 flag, then
1305   *  they will be responsible for creating their own UPLs.
1306   *  @param vp The vnode for which to page out data.
1307   *  @param pl UPL describing pages needed to be paged out.  If UPL is NULL, then it means the filesystem
1308   *  has opted into VFC_VFSVNOP_PAGEOUTV2 semantics, which means that it will create and operate on its own UPLs
1309   *  as opposed to relying on the one passed down into the filesystem.  This means that the filesystem must be
1310   *  responsible for N cluster_pageout calls for N dirty ranges in the UPL.
1311   *  @param pl_offset Offset in UPL from which to start paging out data.  Under the new VFC_VFSVNOP_PAGEOUTV2
1312   *  semantics, this is the offset in the range specified that must be paged out if the associated page is dirty.
1313   *  @param f_offset Offset in file of data needing to be paged out.    Under the new VFC_VFSVNOP_PAGEOUTV2
1314   *  semantics, this represents the offset in the file where we should start looking for dirty pages.
1315   *  @param size Amount of data to page out (in bytes).   Under VFC_VFSVNOP_PAGEOUTV2, this represents
1316   *  the size of the range to be considered.  The fileystem is free to extend or shrink the specified range
1317   *  to better fit its blocking model as long as the page at 'pl_offset' is included.
1318   *  @param flags UPL-style flags: UPL_IOSYNC, UPL_NOCOMMIT, UPL_NORDAHEAD, UPL_VNODE_PAGER, UPL_MSYNC.
1319   *  Filesystems should generally leave it to the cluster layer to handle these flags. See the
1320   *  memory_object_types.h header in the kernel framework if interested.
1321   *  @param ctx Context to authenticate for pageout request.
1322   *  @return 0 for success, or an error code.
1323   */
1324  #ifdef XNU_KERNEL_PRIVATE
1325  extern errno_t VNOP_PAGEOUT(vnode_t, upl_t, upl_offset_t, off_t, size_t, int, vfs_context_t);
1326  #endif /* XNU_KERNEL_PRIVATE */
1327  
1328  struct vnop_searchfs_args {
1329  	struct vnodeop_desc *a_desc;
1330  	vnode_t a_vp;
1331  	void *a_searchparams1;
1332  	void *a_searchparams2;
1333  	struct attrlist *a_searchattrs;
1334  	uint32_t a_maxmatches;
1335  	struct timeval *a_timelimit;
1336  	struct attrlist *a_returnattrs;
1337  	uint32_t *a_nummatches;
1338  	uint32_t a_scriptcode;
1339  	uint32_t a_options;
1340  	struct uio *a_uio;
1341  	struct searchstate *a_searchstate;
1342  	vfs_context_t a_context;
1343  };
1344  
1345  /*
1346   *  @function VNOP_SEARCHFS
1347   *  @abstract Search a filesystem quickly for files or directories that match the passed-in search criteria.
1348   *  @discussion VNOP_SEARCHFS is a getattrlist-based system call which is implemented almost entirely inside
1349   *  supported filesystems.  Callers provide a set of criteria to match against, and the filesystem is responsible
1350   *  for finding all files or directories that match the criteria.  Once these files or directories are found,
1351   *  the user-requested attributes of these files is provided as output.  The set of searchable attributes is a
1352   *  subset of the getattrlist  attributes.  For example, ATTR_CMN_UUID is not a valid searchable attribute as of
1353   *  10.6.  A common usage scenario could be to request all files whose mod dates is greater than time X, less than
1354   *  time Y, and provide the inode ID and filename of the matching objects as output.
1355   *  @param vp The vnode representing the mountpoint of the filesystem to be searched.
1356   *  @param a_searchparams1 If one-argument search criteria is requested, the search criteria would go here. However,
1357   *  some search criteria, like ATTR_CMN_MODTIME, can be bounded.  The user could request files modified between time X
1358   *  and time Y.  In this case, the lower bound goes in a_searchparams1.
1359   *  @param a_searchparams2 If two-argument search criteria is requested, the upper bound goes in here.
1360   *  @param a_searchattrs Contains the getattrlist-style attribute bits which are requested by the current search.
1361   *  @param a_maxmatches The maximum number of matches to return in a single system call.
1362   *  @param a_timelimit The suggested maximum amount of time we can spend in the kernel to service this system call.
1363   *  Filesystems should use this as a guide only, and set their own internal maximum time to avoid denial of service.
1364   *  @param a_returnattrs The getattrlist-style attributes to return for items in the filesystem that match the search
1365   *  criteria above.
1366   *  @param a_scriptcode Currently ignored.
1367   *  @param a_uio The uio in which to write out the search matches.
1368   *  @param a_searchstate Sometimes searches cannot be completed in a single system call.  In this case, we provide
1369   *  an identifier back to the user which indicates where to resume a previously-started search.  This is an opaque structure
1370   *  used by the filesystem to identify where to resume said search.
1371   *  @param a_context The context in which to perform the filesystem search.
1372   *  @return 0 on success, EAGAIN for searches which could not be completed in 1 call, and other ERRNOS as needed.
1373   */
1374  
1375  #ifdef XNU_KERNEL_PRIVATE
1376  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);
1377  #endif /* XNU_KERNEL_PRIVATE */
1378  
1379  struct vnop_copyfile_args {
1380  	struct vnodeop_desc *a_desc;
1381  	vnode_t a_fvp;
1382  	vnode_t a_tdvp;
1383  	vnode_t a_tvp;
1384  	struct componentname *a_tcnp;
1385  	int a_mode;
1386  	int a_flags;
1387  	vfs_context_t a_context;
1388  };
1389  
1390  #ifdef XNU_KERNEL_PRIVATE
1391  extern errno_t VNOP_COPYFILE(vnode_t, vnode_t, vnode_t, struct componentname *, int, int, vfs_context_t);
1392  #endif /* XNU_KERNEL_PRIVATE */
1393  
1394  typedef enum dir_clone_authorizer_op {
1395  	OP_AUTHORIZE = 0,           /* request authorization of action */
1396  	OP_VATTR_SETUP = 1,         /* query for attributes that are required for OP_AUTHORIZE */
1397  	OP_VATTR_CLEANUP = 2        /* request to cleanup any state or free any memory allocated in OP_AUTHORIZE */
1398  } dir_clone_authorizer_op_t;
1399  
1400  struct vnop_clonefile_args {
1401  	struct vnodeop_desc *a_desc;
1402  	vnode_t a_fvp;
1403  	vnode_t a_dvp;
1404  	vnode_t *a_vpp;
1405  	struct componentname *a_cnp;
1406  	struct vnode_attr *a_vap;
1407  	uint32_t a_flags;
1408  	vfs_context_t a_context;
1409  	int (*a_dir_clone_authorizer)(  /* Authorization callback */
1410  		struct vnode_attr *vap,         /* attribute to be authorized */
1411  		kauth_action_t action,         /* action for which attribute is to be authorized */
1412  		struct vnode_attr *dvap,         /* target directory attributes */
1413  		vnode_t sdvp,         /* source directory vnode pointer (optional) */
1414  		mount_t mp,         /* mount point of filesystem */
1415  		dir_clone_authorizer_op_t vattr_op,         /* specific operation requested : setup, authorization or cleanup  */
1416  		uint32_t flags,         /* needs to have the value passed to a_flags */
1417  		vfs_context_t ctx,                      /* As passed to VNOP */
1418  		void *reserved);                        /* Always NULL */
1419  	void *a_reserved;               /* Currently unused */
1420  };
1421  
1422  /*!
1423   *  @function VNOP_CLONEFILE
1424   *  @abstract Call down to a filesystem to clone a filesystem object (regular file, directory or symbolic link.)
1425   *  @discussion If file creation succeeds, "vpp" should be returned with an iocount to be dropped by the caller.
1426   *  @param dvp Directory in which to clone object.
1427   *  @param vpp Destination for vnode for newly cloned object.
1428   *  @param cnp Description of name of object to clone.
1429   *  @param vap File creation properties, as seen in vnode_getattr().  Manipulated with VATTR_ISACTIVE, VATTR_RETURN,
1430   *  VATTR_SET_SUPPORTED, and so forth. All attributes not set here should either be copied
1431   *  from the source object
1432   *  or set to values which are used for creating new filesystem objects
1433   *  @param ctx Context against which to authenticate file creation.
1434   *  @return 0 for success or a filesystem-specific error.
1435   */
1436  #ifdef XNU_KERNEL_PRIVATE
1437  extern errno_t VNOP_CLONEFILE(vnode_t, vnode_t, vnode_t *, struct componentname *, struct vnode_attr *, uint32_t, vfs_context_t);
1438  #endif /* XNU_KERNEL_PRIVATE */
1439  
1440  struct vnop_getxattr_args {
1441  	struct vnodeop_desc *a_desc;
1442  	vnode_t a_vp;
1443  	const char * a_name;
1444  	uio_t a_uio;
1445  	size_t *a_size;
1446  	int a_options;
1447  	vfs_context_t a_context;
1448  };
1449  extern struct vnodeop_desc vnop_getxattr_desc;
1450  
1451  /*!
1452   *  @function VNOP_GETXATTR
1453   *  @abstract Get extended file attributes.
1454   *  @param vp The vnode to get extended attributes for.
1455   *  @param name Which property to extract.
1456   *  @param uio Destination information for attribute value.
1457   *  @param size Should be set to the amount of data written.
1458   *  @param options XATTR_NOSECURITY: bypass security-checking.
1459   *  @param ctx Context to authenticate for getxattr request.
1460   *  @return 0 for success, or an error code.
1461   */
1462  extern errno_t VNOP_GETXATTR(vnode_t vp, const char *name, uio_t uio, size_t *size, int options, vfs_context_t ctx);
1463  
1464  struct vnop_setxattr_args {
1465  	struct vnodeop_desc *a_desc;
1466  	vnode_t a_vp;
1467  	const char * a_name;
1468  	uio_t a_uio;
1469  	int a_options;
1470  	vfs_context_t a_context;
1471  };
1472  extern struct vnodeop_desc vnop_setxattr_desc;
1473  
1474  /*!
1475   *  @function VNOP_SETXATTR
1476   *  @abstract Set extended file attributes.
1477   *  @param vp The vnode to set extended attributes for.
1478   *  @param name Which property to extract.
1479   *  @param uio Source information for attribute value.
1480   *  @param options XATTR_NOSECURITY: bypass security-checking. XATTR_CREATE: set value, fail if exists.
1481   *  XATTR_REPLACE: set value, fail if does not exist.
1482   *  @param ctx Context to authenticate for setxattr request.
1483   *  @return 0 for success, or an error code.
1484   */
1485  extern errno_t VNOP_SETXATTR(vnode_t vp, const char *name, uio_t uio, int options, vfs_context_t ctx);
1486  
1487  struct vnop_removexattr_args {
1488  	struct vnodeop_desc *a_desc;
1489  	vnode_t a_vp;
1490  	const char * a_name;
1491  	int a_options;
1492  	vfs_context_t a_context;
1493  };
1494  extern struct vnodeop_desc vnop_removexattr_desc;
1495  
1496  /*!
1497   *  @function VNOP_REMOVEXATTR
1498   *  @abstract Remove extended file attributes.
1499   *  @param vp The vnode from which to remove extended attributes.
1500   *  @param name Which attribute to delete.
1501   *  @param options XATTR_NOSECURITY: bypass security-checking.
1502   *  @param ctx Context to authenticate for attribute delete request.
1503   *  @return 0 for success, or an error code.
1504   */
1505  #ifdef XNU_KERNEL_PRIVATE
1506  extern errno_t VNOP_REMOVEXATTR(vnode_t, const char *, int, vfs_context_t);
1507  #endif /* XNU_KERNEL_PRIVATE */
1508  
1509  struct vnop_listxattr_args {
1510  	struct vnodeop_desc *a_desc;
1511  	vnode_t a_vp;
1512  	uio_t a_uio;
1513  	size_t *a_size;
1514  	int a_options;
1515  	vfs_context_t a_context;
1516  };
1517  extern struct vnodeop_desc vnop_listxattr_desc;
1518  
1519  /*!
1520   *  @function VNOP_LISTXATTR
1521   *  @abstract List extended attribute keys.
1522   *  @discussion Should write a sequence of unseparated, null-terminated extended-attribute
1523   *  names into the space described by the provided uio.  These keys can then be passed to
1524   *  getxattr() (and VNOP_GETXATTR()).
1525   *  @param vp The vnode for which to get extended attribute keys.
1526   *  @param uio Description of target memory for attribute keys.
1527   *  @param size Should be set to amount of data written to buffer.
1528   *  @param options XATTR_NOSECURITY: bypass security checking.
1529   *  @param ctx Context to authenticate for attribute name request.
1530   */
1531  #ifdef XNU_KERNEL_PRIVATE
1532  extern errno_t VNOP_LISTXATTR(vnode_t, uio_t, size_t *, int, vfs_context_t);
1533  #endif /* XNU_KERNEL_PRIVATE */
1534  
1535  struct vnop_blktooff_args {
1536  	struct vnodeop_desc *a_desc;
1537  	vnode_t a_vp;
1538  	daddr64_t a_lblkno;
1539  	off_t *a_offset;
1540  };
1541  
1542  /*!
1543   *  @function VNOP_BLKTOOFF
1544   *  @abstract Call down to a filesystem to convert a logical block number to a file offset.
1545   *  @discussion VNOP_BLKTOOFF() converts a logical block to a file offset in bytes.  That offset
1546   *  can be passed to VNOP_BLOCKMAP(), then, to get a physical block number--buf_strategy() does this.
1547   *  @param vp The vnode for which to convert a logical block to an offset.
1548   *  @param lblkno Logical block number to turn into offset.
1549   *  @param offset Destination for file offset.
1550   *  @return 0 for success, else an error code.
1551   */
1552  #ifdef XNU_KERNEL_PRIVATE
1553  extern errno_t VNOP_BLKTOOFF(vnode_t, daddr64_t, off_t *);
1554  #endif /* XNU_KERNEL_PRIVATE */
1555  
1556  struct vnop_offtoblk_args {
1557  	struct vnodeop_desc *a_desc;
1558  	vnode_t a_vp;
1559  	off_t a_offset;
1560  	daddr64_t *a_lblkno;
1561  };
1562  
1563  /*!
1564   *  @function VNOP_OFFTOBLK
1565   *  @abstract Call down to a filesystem to convert a file offset to a logical block number.
1566   *  @param vp The vnode for which to convert an offset to a logical block number.
1567   *  @param offset File offset to convert.
1568   *  @param lblkno Destination for corresponding logical block number.
1569   *  @return 0 for success, else an error code.
1570   */
1571  #ifdef XNU_KERNEL_PRIVATE
1572  extern errno_t VNOP_OFFTOBLK(vnode_t, off_t, daddr64_t *);
1573  #endif /* XNU_KERNEL_PRIVATE */
1574  
1575  struct vnop_blockmap_args {
1576  	struct vnodeop_desc *a_desc;
1577  	vnode_t a_vp;
1578  	off_t a_foffset;
1579  	size_t a_size;
1580  	daddr64_t *a_bpn;
1581  	size_t *a_run;
1582  	void *a_poff;
1583  	int a_flags;
1584  	vfs_context_t a_context;
1585  };
1586  
1587  /*!
1588   *  @function VNOP_BLOCKMAP
1589   *  @abstract Call down to a filesystem to get information about the on-disk layout of a file region.
1590   *  @discussion VNOP_BLOCKMAP() returns the information required to pass a request for a contiguous region
1591   *  down to a device's strategy routine.
1592   *  @param vp The vnode for which to get on-disk information.
1593   *  @param foffset Offset (in bytes) at which region starts.
1594   *  @param size Size of region.
1595   *  @param bpn Destination for physical block number at which region begins on disk.
1596   *  @param run Destination for number of bytes which can be found contiguously on-disk before
1597   *  first discontinuity.
1598   *  @param poff Currently unused.
1599   *  @param flags VNODE_READ: request is for a read. VNODE_WRITE: request is for a write.
1600   *  @param ctx Context to authenticate for blockmap request; currently often set to NULL.
1601   *  @return 0 for success, else an error code.
1602   */
1603  #ifdef XNU_KERNEL_PRIVATE
1604  extern errno_t VNOP_BLOCKMAP(vnode_t, off_t, size_t, daddr64_t *, size_t *, void *,
1605      int, vfs_context_t);
1606  #endif /* XNU_KERNEL_PRIVATE */
1607  
1608  struct vnop_strategy_args {
1609  	struct vnodeop_desc *a_desc;
1610  	struct buf *a_bp;
1611  };
1612  
1613  /*!
1614   *  @function VNOP_STRATEGY
1615   *  @abstract Initiate I/O on a file (both read and write).
1616   *  @discussion A filesystem strategy routine takes a buffer, performs whatever manipulations are necessary for passing
1617   *  the I/O request down to the device layer, and calls the appropriate device's strategy routine.  Most filesystems should
1618   *  just call buf_strategy() with "bp" as the argument.
1619   *  @param bp Complete specificiation of requested I/O: region of data involved, whether request is for read or write, and so on.
1620   *  @return 0 for success, else an error code.
1621   */
1622  extern errno_t VNOP_STRATEGY(struct buf *bp);
1623  
1624  struct vnop_bwrite_args {
1625  	struct vnodeop_desc *a_desc;
1626  	buf_t a_bp;
1627  };
1628  
1629  /*!
1630   *  @function VNOP_BWRITE
1631   *  @abstract Write a buffer to backing store.
1632   *  @discussion VNOP_BWRITE() is called by buf_bawrite() (asynchronous write) and potentially by buf_bdwrite() (delayed write)
1633   *  but not by buf_bwrite().  A filesystem may choose to perform some kind of manipulation of the buffer in this routine; it
1634   *  generally will end up calling VFS's default implementation, vn_bwrite() (which calls buf_bwrite() without further ado).
1635   *  @param bp The buffer to write.
1636   *  @return 0 for success, else an error code.
1637   */
1638  extern errno_t VNOP_BWRITE(buf_t bp);
1639  
1640  struct vnop_kqfilt_add_args {
1641  	struct vnodeop_desc *a_desc;
1642  	struct vnode *a_vp;
1643  	struct knote *a_kn;
1644  	vfs_context_t a_context;
1645  };
1646  extern struct vnodeop_desc vnop_kqfilt_add_desc;
1647  
1648  #ifdef XNU_KERNEL_PRIVATE
1649  extern errno_t VNOP_KQFILT_ADD(vnode_t, struct knote *, vfs_context_t);
1650  #endif /* XNU_KERNEL_PRIVATE */
1651  
1652  struct vnop_kqfilt_remove_args {
1653  	struct vnodeop_desc *a_desc;
1654  	struct vnode *a_vp;
1655  	uintptr_t a_ident;
1656  	vfs_context_t a_context;
1657  };
1658  extern struct vnodeop_desc vnop_kqfilt_remove_desc;
1659  
1660  #ifdef XNU_KERNEL_PRIVATE
1661  errno_t VNOP_KQFILT_REMOVE(vnode_t, uintptr_t, vfs_context_t);
1662  #endif /* XNU_KERNEL_PRIVATE */
1663  
1664  
1665  #ifdef KERNEL_PRIVATE
1666  #define VNODE_MONITOR_BEGIN     0x01
1667  #define VNODE_MONITOR_END       0x02
1668  #define VNODE_MONITOR_UPDATE    0x04
1669  struct vnop_monitor_args {
1670  	struct vnodeop_desc *a_desc;
1671  	vnode_t a_vp;
1672  	uint32_t a_events;
1673  	uint32_t a_flags;
1674  	void *a_handle;
1675  	vfs_context_t a_context;
1676  };
1677  extern struct vnodeop_desc vnop_monitor_desc;
1678  #endif /* KERNEL_PRIVATE */
1679  
1680  #ifdef XNU_KERNEL_PRIVATE
1681  /*!
1682   *  @function VNOP_MONITOR
1683   *  @abstract Indicate to a filesystem that the number of watchers of a file has changed.
1684   *  @param vp The vnode whose watch state has changed.
1685   *  @param events Unused.  Filesystems can ignore this parameter.
1686   *  @param flags Type of change to the watch state.  VNODE_MONITOR_BEGIN is passed when the kernel
1687   *  begins tracking a new watcher of a file.  VNODE_MONITOR_END is passed when a watcher stops watching a file.
1688   *  VNODE_MONITOR_UPDATE is currently unused.  A filesystem is guaranteed that each VNODE_MONITOR_BEGIN
1689   *  will be matched by a VNODE_MONITOR_END with the same "handle" argument.
1690   *  @param handle Unique identifier for a given watcher. A VNODE_MONITOR_BEGIN for a given handle will be matched with a
1691   *  VNODE_MONITOR_END for the same handle; a filesystem need not consider this parameter unless
1692   *  it for some reason wants be able to match specific VNOP_MONITOR calls rather than just keeping
1693   *  a count.
1694   *  @param ctx The context which is starting to monitor a file or ending a watch on a file.  A matching
1695   *  pair of VNODE_MONITOR_BEGIN and VNODE_MONITOR_END need not have the same context.
1696   *  @discussion VNOP_MONITOR() is intended to let networked filesystems know when they should bother
1697   *  listening for changes to files which occur remotely, so that they can post notifications using
1698   *  vnode_notify().  Local filesystems should not implement a monitor vnop.
1699   *  It is called when there is a new watcher for a file or when a watcher for a file goes away.
1700   *  Each BEGIN will be matched with an END with the same handle.  Note that vnode_ismonitored() can
1701   *  be used to see if there are currently watchers for a file.
1702   */
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  });
1822  
1823  #define VNODE_VERIFY_DEFAULT VNODE_VERIFY_DEFAULT
1824  
1825  struct vnop_verify_args {
1826  	struct vnodeop_desc *a_desc;
1827  	vnode_t a_vp;
1828  	off_t a_foffset;
1829  	uint8_t  *a_buf;
1830  	size_t a_bufsize;
1831  	size_t *a_verifyblksize;
1832  	vnode_verify_flags_t a_flags;
1833  	vfs_context_t a_context;
1834  };
1835  
1836  /*!
1837   *  @function VNOP_VERIFY
1838   *  @abstract Call down to a filesystem to verify file data for integrity.
1839   *  @discussion VNOP_VERIFY() returns whether file data being read has been verified to be what was written.
1840   *  This does not impose a specific mechanism for ensuring integrity beyond requiring that this be done in
1841   *  multiples of a verify block size (analogous to a filesystem block size but it can be per file)
1842   *  @param vp The vnode for which data is to be verified.
1843   *  @param foffset Offset (in bytes) at which region to be verified starts.
1844   *  @param buf buffer containing file data at foffset. If this is NULL, then only the verification block size is
1845   *  being requested.
1846   *  @param bufsize size of data buffer to be verified.
1847   *  @param verifyblksize pointer to size of verification block size in use for this file. If the verification block size is 0,
1848   *  no verification will be performed. The verification block size can be any value which is a power of two upto 128KiB.
1849   *  @param flags modifier flags.
1850   *  @param ctx Context to authenticate for verify request; currently often set to NULL.
1851   *  @return 0 for success, else an error code.
1852   */
1853  #ifdef XNU_KERNEL_PRIVATE
1854  extern errno_t VNOP_VERIFY(vnode_t, off_t, uint8_t *, size_t, size_t *, vnode_verify_flags_t, vfs_context_t);
1855  #endif /* XNU_KERNEL_PRIVATE */
1856  
1857  #endif // defined(__APPLE_API_UNSTABLE)
1858  
1859  __END_DECLS
1860  
1861  #endif /* KERNEL */
1862  
1863  #pragma clang diagnostic pop /* #pragma clang diagnostic ignored "-Wdocumentation" */
1864  #endif /* !_SYS_VNODE_IF_H_ */