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