3 * Copyright (c) 2000-2014 Apple Computer, Inc. All rights reserved.
5 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
7 * This file contains Original Code and/or Modifications of Original Code
8 * as defined in and that are subject to the Apple Public Source License
9 * Version 2.0 (the 'License'). You may not use this file except in
10 * compliance with the License. The rights granted to you under the License
11 * may not be used to create, or enable the creation or redistribution of,
12 * unlawful or unlicensed copies of an Apple operating system, or to
13 * circumvent, violate, or enable the circumvention or violation of, any
14 * terms of an Apple operating system software license agreement.
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this file.
19 * The Original Code and all software distributed under the License are
20 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
21 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
22 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
24 * Please see the License for the specific language governing rights and
25 * limitations under the License.
27 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
30 * Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved
31 * Copyright (c) 1992, 1993, 1994, 1995
32 * The Regents of the University of California. All rights reserved.
34 * Redistribution and use in source and binary forms, with or without
35 * modification, are permitted provided that the following conditions
37 * 1. Redistributions of source code must retain the above copyright
38 * notice, this list of conditions and the following disclaimer.
39 * 2. Redistributions in binary form must reproduce the above copyright
40 * notice, this list of conditions and the following disclaimer in the
41 * documentation and/or other materials provided with the distribution.
42 * 3. All advertising materials mentioning features or use of this software
43 * must display the following acknowledgement:
44 * This product includes software developed by the University of
45 * California, Berkeley and its contributors.
46 * 4. Neither the name of the University nor the names of its contributors
47 * may be used to endorse or promote products derived from this software
48 * without specific prior written permission.
50 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS AND
51 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
52 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
53 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
54 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
55 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
56 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63 * NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce
64 * support for mandatory and extensible security protections. This notice
65 * is included in support of clause 2.2 (b) of the Apple Public License,
70 * Warning: This file is generated automatically.
71 * (Modifications made here may easily be lost!)
73 * Created by the script:
74 * @(#)vnode_if.sh 8.7 (Berkeley) 5/11/95
78 #ifndef _SYS_VNODE_IF_H_
79 #define _SYS_VNODE_IF_H_
81 #include <sys/appleapiopts.h>
82 #include <sys/cdefs.h>
83 #include <sys/kernel_types.h>
85 #ifdef BSD_KERNEL_PRIVATE
88 #include <mach/memory_object_types.h>
93 extern struct vnodeop_desc vnop_default_desc
;
94 extern struct vnodeop_desc vnop_lookup_desc
;
96 extern struct vnodeop_desc vnop_compound_open_desc
;
97 extern struct vnodeop_desc vnop_compound_remove_desc
;
98 extern struct vnodeop_desc vnop_compound_rename_desc
;
99 extern struct vnodeop_desc vnop_compound_mkdir_desc
;
100 extern struct vnodeop_desc vnop_compound_rmdir_desc
;
101 #endif /* KERNEL_PRIVATE */
102 extern struct vnodeop_desc vnop_create_desc
;
103 extern struct vnodeop_desc vnop_whiteout_desc
; // obsolete
104 extern struct vnodeop_desc vnop_mknod_desc
;
105 extern struct vnodeop_desc vnop_open_desc
;
106 extern struct vnodeop_desc vnop_close_desc
;
107 extern struct vnodeop_desc vnop_access_desc
;
108 extern struct vnodeop_desc vnop_getattr_desc
;
109 extern struct vnodeop_desc vnop_setattr_desc
;
110 extern struct vnodeop_desc vnop_read_desc
;
111 extern struct vnodeop_desc vnop_write_desc
;
112 extern struct vnodeop_desc vnop_ioctl_desc
;
113 extern struct vnodeop_desc vnop_select_desc
;
114 extern struct vnodeop_desc vnop_exchange_desc
;
115 extern struct vnodeop_desc vnop_revoke_desc
;
116 extern struct vnodeop_desc vnop_mmap_desc
;
117 extern struct vnodeop_desc vnop_mnomap_desc
;
118 extern struct vnodeop_desc vnop_fsync_desc
;
119 extern struct vnodeop_desc vnop_remove_desc
;
120 extern struct vnodeop_desc vnop_link_desc
;
121 extern struct vnodeop_desc vnop_rename_desc
;
122 extern struct vnodeop_desc vnop_mkdir_desc
;
123 extern struct vnodeop_desc vnop_rmdir_desc
;
124 extern struct vnodeop_desc vnop_symlink_desc
;
125 extern struct vnodeop_desc vnop_readdir_desc
;
126 extern struct vnodeop_desc vnop_readdirattr_desc
;
127 extern struct vnodeop_desc vnop_getattrlistbulk_desc
;
128 extern struct vnodeop_desc vnop_readlink_desc
;
129 extern struct vnodeop_desc vnop_inactive_desc
;
130 extern struct vnodeop_desc vnop_reclaim_desc
;
131 extern struct vnodeop_desc vnop_print_desc
;
132 extern struct vnodeop_desc vnop_pathconf_desc
;
133 extern struct vnodeop_desc vnop_advlock_desc
;
134 extern struct vnodeop_desc vnop_truncate_desc
;
135 extern struct vnodeop_desc vnop_allocate_desc
;
136 extern struct vnodeop_desc vnop_pagein_desc
;
137 extern struct vnodeop_desc vnop_pageout_desc
;
138 extern struct vnodeop_desc vnop_searchfs_desc
;
139 extern struct vnodeop_desc vnop_copyfile_desc
;
140 extern struct vnodeop_desc vnop_blktooff_desc
;
141 extern struct vnodeop_desc vnop_offtoblk_desc
;
142 extern struct vnodeop_desc vnop_blockmap_desc
;
143 extern struct vnodeop_desc vnop_strategy_desc
;
144 extern struct vnodeop_desc vnop_bwrite_desc
;
146 #ifdef __APPLE_API_UNSTABLE
149 extern struct vnodeop_desc vnop_getnamedstream_desc
;
150 extern struct vnodeop_desc vnop_makenamedstream_desc
;
151 extern struct vnodeop_desc vnop_removenamedstream_desc
;
158 struct vnop_lookup_args
{
159 struct vnodeop_desc
*a_desc
;
162 struct componentname
*a_cnp
;
163 vfs_context_t a_context
;
167 @function VNOP_LOOKUP
168 @abstract Call down to a filesystem to look for a directory entry by name.
169 @discussion VNOP_LOOKUP is the key pathway through which VFS asks a filesystem to find a file. The vnode
170 should be returned with an iocount to be dropped by the caller. A VNOP_LOOKUP() calldown can come without
171 a preceding VNOP_OPEN().
172 @param dvp Directory in which to look up file.
173 @param vpp Destination for found vnode.
174 @param cnp Structure describing filename to find, reason for lookup, and various other data.
175 @param ctx Context against which to authenticate lookup request.
176 @return 0 for success or a filesystem-specific error.
178 #ifdef XNU_KERNEL_PRIVATE
179 extern errno_t
VNOP_LOOKUP(vnode_t
, vnode_t
*, struct componentname
*, vfs_context_t
);
180 #endif /* XNU_KERNEL_PRIVATE */
182 struct vnop_create_args
{
183 struct vnodeop_desc
*a_desc
;
186 struct componentname
*a_cnp
;
187 struct vnode_attr
*a_vap
;
188 vfs_context_t a_context
;
192 @function VNOP_CREATE
193 @abstract Call down to a filesystem to create a regular file (VREG).
194 @discussion If file creation succeeds, "vpp" should be returned with an iocount to be dropped by the caller.
195 A VNOP_CREATE() calldown can come without a preceding VNOP_OPEN().
196 @param dvp Directory in which to create file.
197 @param vpp Destination for vnode for newly created file.
198 @param cnp Description of filename to create.
199 @param vap File creation properties, as seen in vnode_getattr(). Manipulated with VATTR_ISACTIVE, VATTR_RETURN,
200 VATTR_SET_SUPPORTED, and so forth.
201 @param ctx Context against which to authenticate file creation.
202 @return 0 for success or a filesystem-specific error.
204 #ifdef XNU_KERNEL_PRIVATE
205 extern errno_t
VNOP_CREATE(vnode_t
, vnode_t
*, struct componentname
*, struct vnode_attr
*, vfs_context_t
);
206 #endif /* XNU_KERNEL_PRIVATE */
208 struct vnop_whiteout_args
{
209 struct vnodeop_desc
*a_desc
;
211 struct componentname
*a_cnp
;
213 vfs_context_t a_context
;
217 @function VNOP_WHITEOUT
218 @abstract Obsolete - no longer supported.
219 @discussion Whiteouts are used to support the union filesystem, whereby one filesystem is mounted "transparently"
220 on top of another. A whiteout in the upper layer of a union mount is a "deletion" of a file in the lower layer;
221 lookups will catch the whiteout and fail, setting ISWHITEOUT in the componentname structure, even if an underlying
222 file of the same name exists. The whiteout vnop is used for creation, deletion, and checking whether a directory
223 supports whiteouts (see flags).
224 also support the LOOKUP flag, which is used to test whether a directory supports whiteouts.
225 @param dvp Directory in which to create.
226 @param cnp Name information for whiteout.
227 @param flags CREATE: create a whiteout. LOOKUP: check whether a directory supports whiteouts, DELETE: remove a whiteout.
228 @param ctx Context against which to authenticate whiteout creation.
229 @return 0 for success or a filesystem-specific error. Returning 0 for LOOKUP indicates that a directory does support whiteouts.
231 #ifdef XNU_KERNEL_PRIVATE
232 extern errno_t
VNOP_WHITEOUT(vnode_t
, struct componentname
*, int, vfs_context_t
);
233 #endif /* XNU_KERNEL_PRIVATE */
235 struct vnop_mknod_args
{
236 struct vnodeop_desc
*a_desc
;
239 struct componentname
*a_cnp
;
240 struct vnode_attr
*a_vap
;
241 vfs_context_t a_context
;
246 @abstract Call down to a filesystem to create a special file.
247 @discussion The mknod vnop is used to create character and block device files, named pipe (FIFO) files, and named sockets.
248 The newly created file should be returned with an iocount which will be dropped by the caller. A VNOP_MKNOD() call
249 can come down without a preceding VNOP_OPEN().
250 @param dvp Directory in which to create the special file.
251 @param vpp Destination for newly created vnode.
252 @param cnp Name information for new file.
253 @param vap Attributes for new file, including type.
254 @param ctx Context against which to authenticate node creation.
255 @return 0 for success or a filesystem-specific error.
257 #ifdef XNU_KERNEL_PRIVATE
258 extern errno_t
VNOP_MKNOD(vnode_t
, vnode_t
*, struct componentname
*, struct vnode_attr
*, vfs_context_t
);
259 #endif /* XNU_KERNEL_PRIVATE */
261 struct vnop_open_args
{
262 struct vnodeop_desc
*a_desc
;
265 vfs_context_t a_context
;
268 #ifdef KERNEL_PRIVATE
269 struct vnop_compound_open_args
{
270 struct vnodeop_desc
*a_desc
;
272 vnode_t a_dvp
; /* Directory in which to open/create */
273 vnode_t
*a_vpp
; /* Resulting vnode */
274 int a_fmode
; /* Open mode */
275 struct componentname
*a_cnp
; /* Path to look up */
276 struct vnode_attr
*a_vap
; /* Attributes with which to create, if appropriate */
277 uint32_t a_flags
; /* VNOP-control flags */
278 uint32_t *a_status
; /* Information about results */
280 vfs_context_t a_context
; /* Authorization context */
282 int (*a_open_create_authorizer
)( /* Authorizer for create case */
283 vnode_t dvp
, /* Directory in which to create */
284 struct componentname
*cnp
, /* As passed to VNOP */
285 struct vnode_attr
*vap
, /* As passed to VNOP */
286 vfs_context_t ctx
, /* Context */
287 void *reserved
); /* Who knows */
289 int (*a_open_existing_authorizer
)( /* Authorizer for preexisting case */
290 vnode_t vp
, /* vp to open */
291 struct componentname
*cnp
, /* Lookup state */
292 int fmode
, /* As passed to VNOP */
293 vfs_context_t ctx
, /* Context */
294 void *reserved
); /* Who knows */
300 #define COMPOUND_OPEN_STATUS_DID_CREATE 0x00000001
301 #endif /* KERNEL_PRIVATE */
305 @abstract Call down to a filesystem to open a file.
306 @discussion The open vnop gives a filesystem a chance to initialize a file for
307 operations like reading, writing, and ioctls. VFS promises to send down exactly one VNOP_CLOSE()
308 for each VNOP_OPEN().
309 @param vp File to open.
310 @param mode FREAD and/or FWRITE.
311 @param ctx Context against which to authenticate open.
312 @return 0 for success or a filesystem-specific error.
314 #ifdef XNU_KERNEL_PRIVATE
315 extern errno_t
VNOP_OPEN(vnode_t
, int, vfs_context_t
);
316 #endif /* XNU_KERNEL_PRIVATE */
318 #ifdef BSD_KERNEL_PRIVATE
320 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
);
323 struct vnop_close_args
{
324 struct vnodeop_desc
*a_desc
;
327 vfs_context_t a_context
;
332 @abstract Call down to a filesystem to close a file.
333 @discussion The close vnop gives a filesystem a chance to release state set up
334 by a VNOP_OPEN(). VFS promises to send down exactly one VNOP_CLOSE() for each VNOP_OPEN().
335 @param vp File to close.
336 @param fflag FREAD and/or FWRITE; in the case of a file opened with open(2), fflag corresponds
337 to how the file was opened.
338 @param ctx Context against which to authenticate close.
339 @return 0 for success or a filesystem-specific error.
341 #ifdef XNU_KERNEL_PRIVATE
342 extern errno_t
VNOP_CLOSE(vnode_t
, int, vfs_context_t
);
343 #endif /* XNU_KERNEL_PRIVATE */
345 struct vnop_access_args
{
346 struct vnodeop_desc
*a_desc
;
349 vfs_context_t a_context
;
353 @function VNOP_ACCESS
354 @abstract Call down to a filesystem to see if a kauth-style operation is permitted.
355 @discussion VNOP_ACCESS is currently only called on filesystems which mark themselves
356 as doing their authentication remotely (vfs_setauthopaque(), vfs_authopaque()). A VNOP_ACCESS()
357 calldown may come without any preceding VNOP_OPEN().
358 @param vp File to authorize action for.
359 @param action kauth-style action to be checked for permissions, e.g. KAUTH_VNODE_DELETE.
360 @param ctx Context against which to authenticate action.
361 @return 0 for success or a filesystem-specific error.
363 #ifdef XNU_KERNEL_PRIVATE
364 extern errno_t
VNOP_ACCESS(vnode_t
, int, vfs_context_t
);
365 #endif /* XNU_KERNEL_PRIVATE */
367 struct vnop_getattr_args
{
368 struct vnodeop_desc
*a_desc
;
370 struct vnode_attr
*a_vap
;
371 vfs_context_t a_context
;
375 @function VNOP_GETATTR
376 @abstract Call down to a filesystem to get vnode attributes.
377 @discussion Supported attributes ("Yes, I am returning this information") are set with VATTR_SET_SUPPORTED.
378 Which attributes have been requested is checked with VATTR_IS_ACTIVE. Attributes
379 are returned with VATTR_RETURN. It is through VNOP_GETATTR that routines like stat() get their information.
380 A VNOP_GETATTR() calldown may come without any preceding VNOP_OPEN().
381 @param vp The vnode whose attributes to get.
382 @param vap Container for which attributes are requested, which attributes are supported by the filesystem, and attribute values.
383 @param ctx Context against which to authenticate request for attributes.
384 @return 0 for success or a filesystem-specific error. VNOP_GETATTR() can return success even if not
385 all requested attributes were returned; returning an error-value should indicate that something went wrong, rather than that
386 some attribute is not supported.
388 #ifdef XNU_KERNEL_PRIVATE
389 extern errno_t
VNOP_GETATTR(vnode_t
, struct vnode_attr
*, vfs_context_t
);
390 #endif /* XNU_KERNEL_PRIVATE */
392 struct vnop_setattr_args
{
393 struct vnodeop_desc
*a_desc
;
395 struct vnode_attr
*a_vap
;
396 vfs_context_t a_context
;
400 @function VNOP_SETATTR
401 @abstract Call down to a filesystem to set vnode attributes.
402 @discussion Supported attributes ("Yes, I am setting this attribute.") are set with VATTR_SET_SUPPORTED.
403 Requested attributes are checked with VATTR_IS_ACTIVE. Attribute values are accessed directly through
404 structure fields. VNOP_SETATTR() is the core of the KPI function vnode_setattr(), which is used by chmod(),
405 chown(), truncate(), and many others. A VNOP_SETATTR() call may come without any preceding VNOP_OPEN().
406 @param vp The vnode whose attributes to set.
407 @param vap Container for which attributes are to be set and their desired values, as well as for the filesystem to
408 return information about which attributes were successfully set.
409 @param ctx Context against which to authenticate request for attribute change.
410 @return 0 for success or a filesystem-specific error. VNOP_SETATTR() can return success even if not
411 all requested attributes were set; returning an error-value should indicate that something went wrong, rather than that
412 some attribute is not supported.
414 #ifdef XNU_KERNEL_PRIVATE
415 extern errno_t
VNOP_SETATTR(vnode_t
, struct vnode_attr
*, vfs_context_t
);
416 #endif /* XNU_KERNEL_PRIVATE */
418 struct vnop_read_args
{
419 struct vnodeop_desc
*a_desc
;
423 vfs_context_t a_context
;
428 @abstract Call down to a filesystem to read file data.
429 @discussion VNOP_READ() is where the hard work of of the read() system call happens. The filesystem may use
430 the buffer cache, the cluster layer, or an alternative method to get its data; uio routines will be used to see that data
431 is copied to the correct virtual address in the correct address space and will update its uio argument
432 to indicate how much data has been moved.
433 @param vp The vnode to read from.
434 @param uio Description of request, including file offset, amount of data requested, destination address for data,
435 and whether that destination is in kernel or user space.
436 @param ctx Context against which to authenticate read request.
437 @return 0 for success or a filesystem-specific error. VNOP_READ() can return success even if less data was
438 read than originally requested; returning an error value should indicate that something actually went wrong.
440 extern errno_t
VNOP_READ(vnode_t
, struct uio
*, int, vfs_context_t
);
442 struct vnop_write_args
{
443 struct vnodeop_desc
*a_desc
;
447 vfs_context_t a_context
;
452 @abstract Call down to the filesystem to write file data.
453 @discussion VNOP_WRITE() is to write() as VNOP_READ() is to read(). The filesystem may use
454 the buffer cache, the cluster layer, or an alternative method to write its data; uio routines will be used to see that data
455 is copied to the correct virtual address in the correct address space and will update its uio argument
456 to indicate how much data has been moved.
457 @param vp The vnode to write to.
458 @param uio Description of request, including file offset, amount of data to write, source address for data,
459 and whether that destination is in kernel or user space.
460 @param ctx Context against which to authenticate write request.
461 @return 0 for success or a filesystem-specific error. VNOP_WRITE() can return success even if less data was
462 written than originally requested; returning an error value should indicate that something actually went wrong.
464 extern errno_t
VNOP_WRITE(vnode_t
, struct uio
*, int, vfs_context_t
);
466 struct vnop_ioctl_args
{
467 struct vnodeop_desc
*a_desc
;
472 vfs_context_t a_context
;
477 @abstract Call down to a filesystem or device driver to execute various control operations on or request data about a file.
478 @discussion Ioctl controls are typically associated with devices, but they can in fact be passed
479 down for any file; they are used to implement any of a wide range of controls and information requests.
480 fcntl() calls VNOP_IOCTL for several commands, and will attempt a VNOP_IOCTL if it is passed an unknown command,
481 though no copyin or copyout of arguments can occur in this case--the "arg" must be an integer value.
482 Filesystems can define their own fcntls using this mechanism. How ioctl commands are structured
483 is slightly complicated; see the manual page for ioctl(2).
484 @param vp The vnode to execute the command on.
485 @param command Identifier for action to take.
486 @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,
487 depending on "command." If it is an address, it is valid and resides in the kernel; callers of VNOP_IOCTL() are
488 responsible for copying to and from userland.
489 @param ctx Context against which to authenticate ioctl request.
490 @return 0 for success or a filesystem-specific error.
492 extern errno_t
VNOP_IOCTL(vnode_t
, u_long
, caddr_t
, int, vfs_context_t
);
494 struct vnop_select_args
{
495 struct vnodeop_desc
*a_desc
;
500 vfs_context_t a_context
;
504 @function VNOP_SELECT
505 @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.
506 @discussion In general, regular are always "ready for I/O" and their select vnops simply return "1."
507 Devices, though, may or may not be read; they keep track of who is selecting on them and send notifications
508 when they become ready. xnu provides structures and routines for tracking threads waiting for I/O and waking up
509 those threads: see selrecord(), selthreadclear(), seltrue(), selwait(), selwakeup(), and the selinfo structure (sys/select.h).
510 @param vp The vnode to check for I/O readiness.
511 @param which What kind of I/O is desired: FREAD, FWRITE.
512 @param fflags Flags from fileglob as seen in fcntl.h, e.g. O_NONBLOCK, O_APPEND.
513 @param wql Opaque object to pass to selrecord().
514 @param ctx Context to authenticate for select request.
515 @return Nonzero indicates that a file is ready for I/O. 0 indicates that the file is not ready for I/O;
516 there is no way to return an error. 0 should be returned if the device (or file) is not ready for I/O
517 and the driver (or filesystem) is going to track the request and provide subsequent wakeups.
518 the device (or filesystem) will provide a wakeup.
520 #ifdef XNU_KERNEL_PRIVATE
521 extern errno_t
VNOP_SELECT(vnode_t
, int, int, void *, vfs_context_t
);
522 #endif /* XNU_KERNEL_PRIVATE */
524 struct vnop_exchange_args
{
525 struct vnodeop_desc
*a_desc
;
529 vfs_context_t a_context
;
533 @function VNOP_EXCHANGE
534 @abstract Call down to a filesystem to atomically exchange the data of two files.
535 @discussion VNOP_EXCHANGE() is currently only called by the exchangedata() system call. It will only
536 be applied to files on the same volume.
537 @param fvp First vnode.
538 @param tvp Second vnode.
539 @param options Unused.
540 @param ctx Context to authenticate for exchangedata request.
541 @return 0 for success, else an error code.
543 #ifdef XNU_KERNEL_PRIVATE
544 extern errno_t
VNOP_EXCHANGE(vnode_t
, vnode_t
, int, vfs_context_t
);
545 #endif /* XNU_KERNEL_PRIVATE */
547 struct vnop_revoke_args
{
548 struct vnodeop_desc
*a_desc
;
551 vfs_context_t a_context
;
555 @function VNOP_REVOKE
556 @abstract Call down to a filesystem to invalidate all open file descriptors for a vnode.
557 @discussion This function is typically called as part of a TTY revoke, but can also be
558 used on regular files. Most filesystems simply use nop_revoke(), which calls vn_revoke(),
559 as their revoke vnop implementation.
560 @param vp The vnode to revoke.
562 @param ctx Context to authenticate for revoke request.
563 @return 0 for success, else an error code.
565 #ifdef XNU_KERNEL_PRIVATE
566 extern errno_t
VNOP_REVOKE(vnode_t
, int, vfs_context_t
);
567 #endif /* XNU_KERNEL_PRIVATE */
569 struct vnop_mmap_args
{
570 struct vnodeop_desc
*a_desc
;
573 vfs_context_t a_context
;
578 @abstract Notify a filesystem that a file is being mmap-ed.
579 @discussion VNOP_MMAP is an advisory calldown to say that the system is mmap-ing a file.
580 @param vp The vnode being mmapped.
581 @param flags Memory protection: PROT_READ, PROT_WRITE, PROT_EXEC.
582 @param ctx Context to authenticate for mmap request.
583 @return 0 for success; all errors except EPERM are ignored.
585 #ifdef XNU_KERNEL_PRIVATE
586 extern errno_t
VNOP_MMAP(vnode_t
, int, vfs_context_t
);
587 #endif /* XNU_KERNEL_PRIVATE */
589 struct vnop_mnomap_args
{
590 struct vnodeop_desc
*a_desc
;
592 vfs_context_t a_context
;
596 @function VNOP_MNOMAP
597 @abstract Inform a filesystem that a file is no longer mapped.
598 @discussion In general, no action is required of a filesystem for VNOP_MNOMAP.
599 @param vp The vnode which is no longer mapped.
600 @param ctx Context to authenticate for mnomap request.
601 @return Return value is ignored.
603 #ifdef XNU_KERNEL_PRIVATE
604 extern errno_t
VNOP_MNOMAP(vnode_t
, vfs_context_t
);
605 #endif /* XNU_KERNEL_PRIVATE */
607 struct vnop_fsync_args
{
608 struct vnodeop_desc
*a_desc
;
611 vfs_context_t a_context
;
616 @abstract Call down to a filesystem to synchronize a file with on-disk state.
617 @discussion VNOP_FSYNC is called whenever we need to make sure that a file's data has been
618 pushed to backing store, for example when recycling; it is also the heart of the fsync() system call.
619 @param vp The vnode whose data to flush to backing store.
620 @param ctx Context to authenticate for fsync request.
621 @return 0 for success, else an error code.
623 extern errno_t
VNOP_FSYNC(vnode_t
, int, vfs_context_t
);
625 struct vnop_remove_args
{
626 struct vnodeop_desc
*a_desc
;
629 struct componentname
*a_cnp
;
631 vfs_context_t a_context
;
635 @function VNOP_REMOVE
636 @abstract Call down to a filesystem to delete a file.
637 @discussion VNOP_REMOVE is called to remove a file from a filesystem's namespace, for example by unlink().
638 It can operate on regular files, named pipes, special files, and in some cases on directories.
639 @param dvp Directory in which to delete a file.
640 @param vp The file to delete.
641 @param cnp Filename information.
642 @param ctx Context to authenticate for fsync request.
643 @return 0 for success, else an error code.
645 #ifdef XNU_KERNEL_PRIVATE
646 extern errno_t
VNOP_REMOVE(vnode_t
, vnode_t
, struct componentname
*, int, vfs_context_t
);
647 #endif /* XNU_KERNEL_PRIVATE */
649 #ifdef KERNEL_PRIVATE
650 struct vnop_compound_remove_args
{
651 struct vnodeop_desc
*a_desc
;
652 vnode_t a_dvp
; /* Directory in which to lookup and remove */
653 vnode_t
*a_vpp
; /* File to remove; may or may not point to NULL pointer */
654 struct componentname
*a_cnp
; /* Name of file to remove */
655 struct vnode_attr
*a_vap
; /* Destination for file attributes on successful delete */
656 uint32_t a_flags
; /* Control flags (unused) */
657 vfs_context_t a_context
; /* Authorization context */
658 int (*a_remove_authorizer
)( /* Authorizer callback */
659 vnode_t dvp
, /* Directory in which to delete */
660 vnode_t vp
, /* File to delete */
661 struct componentname
*cnp
, /* As passed to VNOP */
662 vfs_context_t ctx
, /* As passed to VNOP */
663 void *reserved
); /* Always NULL */
664 void *a_reserved
; /* Unused */
666 #endif /* KERNEL_PRIVATE */
668 #ifdef BSD_KERNEL_PRIVATE
669 extern errno_t
VNOP_COMPOUND_REMOVE(vnode_t
, vnode_t
*, struct nameidata
*, int32_t flags
, struct vnode_attr
*vap
, vfs_context_t
);
671 struct vnop_link_args
{
672 struct vnodeop_desc
*a_desc
;
675 struct componentname
*a_cnp
;
676 vfs_context_t a_context
;
681 @abstract Call down to a filesystem to create a hardlink to a file.
682 @discussion See "man 2 link".
683 @param vp File to link to.
684 @param dvp Directory in which to create the link.
685 @param cnp Filename information for new link.
686 @param ctx Context to authenticate for link request.
687 @return 0 for success, else an error code.
689 #ifdef XNU_KERNEL_PRIVATE
690 extern errno_t
VNOP_LINK(vnode_t
, vnode_t
, struct componentname
*, vfs_context_t
);
691 #endif /* XNU_KERNEL_PRIVATE */
693 struct vnop_rename_args
{
694 struct vnodeop_desc
*a_desc
;
697 struct componentname
*a_fcnp
;
700 struct componentname
*a_tcnp
;
701 vfs_context_t a_context
;
705 @function VNOP_RENAME
706 @abstract Call down to a filesystem to rename a file.
707 @discussion VNOP_RENAME() will only be called with a source and target on the same volume.
708 @param fdvp Directory in which source file resides.
709 @param fvp File being renamed.
710 @param fcnp Name information for source file.
711 @param tdvp Directory file is being moved to.
712 @param tvp Existing file with same name as target, should one exist.
713 @param tcnp Name information for target path.
714 @param ctx Context to authenticate for rename request.
715 @return 0 for success, else an error code.
717 #ifdef XNU_KERNEL_PRIVATE
718 extern errno_t
VNOP_RENAME(vnode_t
, vnode_t
, struct componentname
*, vnode_t
, vnode_t
, struct componentname
*, vfs_context_t
);
719 #endif /* XNU_KERNEL_PRIVATE */
721 #ifdef KERNEL_PRIVATE
722 struct vnop_compound_rename_args
{
723 struct vnodeop_desc
*a_desc
;
725 vnode_t a_fdvp
; /* Directory from which to rename */
726 vnode_t
*a_fvpp
; /* Vnode to rename (can point to a NULL pointer) */
727 struct componentname
*a_fcnp
; /* Source name */
728 struct vnode_attr
*a_fvap
;
730 vnode_t a_tdvp
; /* Directory to which to rename */
731 vnode_t
*a_tvpp
; /* Vnode to rename over (can point to a NULL pointer) */
732 struct componentname
*a_tcnp
; /* Destination name */
733 struct vnode_attr
*a_tvap
;
735 uint32_t a_flags
; /* Control flags: currently unused */
736 vfs_context_t a_context
; /* Authorization context */
737 int (*a_rename_authorizer
)( /* Authorization callback */
738 vnode_t fdvp
, /* As passed to VNOP */
739 vnode_t fvp
, /* Vnode to rename */
740 struct componentname
*fcnp
, /* As passed to VNOP */
741 vnode_t tdvp
, /* As passed to VNOP */
742 vnode_t tvp
, /* Vnode to rename over (can be NULL) */
743 struct componentname
*tcnp
, /* As passed to VNOP */
744 vfs_context_t ctx
, /* As passed to VNOP */
745 void *reserved
); /* Always NULL */
746 void *a_reserved
; /* Currently unused */
748 #endif /* KERNEL_PRIVATE */
750 #ifdef XNU_KERNEL_PRIVATE
752 VNOP_COMPOUND_RENAME(
753 struct vnode
*fdvp
, struct vnode
**fvpp
, struct componentname
*fcnp
, struct vnode_attr
*fvap
,
754 struct vnode
*tdvp
, struct vnode
**tvpp
, struct componentname
*tcnp
, struct vnode_attr
*tvap
,
755 uint32_t flags
,vfs_context_t ctx
);
756 #endif /* XNU_KERNEL_PRIVATE */
758 struct vnop_mkdir_args
{
759 struct vnodeop_desc
*a_desc
;
762 struct componentname
*a_cnp
;
763 struct vnode_attr
*a_vap
;
764 vfs_context_t a_context
;
769 @abstract Call down to a filesystem to create a directory.
770 @discussion The newly created directory should be returned with an iocount which will be dropped by the caller.
771 @param dvp Directory in which to create new directory.
772 @param vpp Destination for pointer to new directory's vnode.
773 @param cnp Name information for new directory.
774 @param vap Attributes for new directory.
775 @param ctx Context to authenticate for mkdir request.
776 @return 0 for success, else an error code.
778 #ifdef XNU_KERNEL_PRIVATE
779 extern errno_t
VNOP_MKDIR(vnode_t
, vnode_t
*, struct componentname
*, struct vnode_attr
*, vfs_context_t
);
780 #endif /* XNU_KERNEL_PRIVATE */
783 #ifdef KERNEL_PRIVATE
784 struct vnop_compound_mkdir_args
{
785 struct vnodeop_desc
*a_desc
;
786 vnode_t a_dvp
; /* Directory in which to create */
787 vnode_t
*a_vpp
; /* Destination for found or created vnode */
788 struct componentname
*a_cnp
; /* Name of directory to create */
789 struct vnode_attr
*a_vap
; /* Creation attributes */
790 uint32_t a_flags
; /* Control flags (unused) */
791 vfs_context_t a_context
; /* Authorization context */
793 int (*a_mkdir_authorizer
)(vnode_t dvp
, struct componentname
*cnp
, struct vnode_attr
*vap
, vfs_context_t ctx
, void *reserved
);
795 void *a_reserved
; /* Unused */
797 #endif /* KERNEL_PRIVATE */
799 #ifdef XNU_KERNEL_PRIVATE
800 extern errno_t
VNOP_COMPOUND_MKDIR(vnode_t
, vnode_t
*, struct nameidata
*, struct vnode_attr
*, vfs_context_t
);
801 #endif /* XNU_KERNEL_PRIVATE */
803 struct vnop_rmdir_args
{
804 struct vnodeop_desc
*a_desc
;
807 struct componentname
*a_cnp
;
808 vfs_context_t a_context
;
813 @abstract Call down to a filesystem to delete a directory.
814 @param dvp Parent of directory to be removed.
815 @param vp Directory to remove.
816 @param cnp Name information for directory to be deleted.
817 @param ctx Context to authenticate for rmdir request.
818 @return 0 for success, else an error code.
820 #ifdef XNU_KERNEL_PRIVATE
821 extern errno_t
VNOP_RMDIR(vnode_t
, vnode_t
, struct componentname
*, vfs_context_t
);
822 #endif /* XNU_KERNEL_PRIVATE */
824 #ifdef KERNEL_PRIVATE
825 struct vnop_compound_rmdir_args
{
826 struct vnodeop_desc
*a_desc
;
827 vnode_t a_dvp
; /* Directory in which to look up and delete */
828 vnode_t
*a_vpp
; /* Destination for found vnode */
829 struct componentname
*a_cnp
; /* Name to delete */
830 struct vnode_attr
*a_vap
; /* Location in which to store attributes if delete succeeds (can be NULL) */
831 uint32_t a_flags
; /* Control flags (currently unused) */
832 vfs_context_t a_context
; /* Context for authorization */
833 int (*a_rmdir_authorizer
)( /* Authorization callback */
834 vnode_t dvp
, /* As passed to VNOP */
835 vnode_t vp
, /* Directory to delete */
836 struct componentname
*cnp
, /* As passed to VNOP */
837 vfs_context_t ctx
, /* As passed to VNOP */
838 void *reserved
); /* Always NULL */
839 void *a_reserved
; /* Unused */
841 #endif /* KERNEL_PRIVATE */
843 #ifdef XNU_KERNEL_PRIVATE
844 extern errno_t
VNOP_COMPOUND_RMDIR(vnode_t
, vnode_t
*, struct nameidata
*, struct vnode_attr
*vap
, vfs_context_t
);
845 #endif /* XNU_KERNEL_PRIVATE */
848 struct vnop_symlink_args
{
849 struct vnodeop_desc
*a_desc
;
852 struct componentname
*a_cnp
;
853 struct vnode_attr
*a_vap
;
855 vfs_context_t a_context
;
859 @function VNOP_SYMLINK
860 @abstract Call down to a filesystem to create a symbolic link.
861 @param If VNOP_SYMLINK() is successful, the new file should be returned with an iocount which will
862 be dropped by the caller. VFS does not ensure that the target path will have a length shorter
863 than the max symlink length for the filesystem.
864 @param dvp Parent directory for new symlink file.
866 @param cnp Name information for new symlink.
867 @param vap Attributes for symlink.
868 @param target Path for symlink to store; for "ln -s /var/vardir linktovardir", "target" would be "/var/vardir"
869 @param ctx Context to authenticate for symlink request.
870 @return 0 for success, else an error code.
872 #ifdef XNU_KERNEL_PRIVATE
873 extern errno_t
VNOP_SYMLINK(vnode_t
, vnode_t
*, struct componentname
*, struct vnode_attr
*, char *, vfs_context_t
);
874 #endif /* XNU_KERNEL_PRIVATE */
878 * When VNOP_READDIR is called from the NFS Server, the nfs_data
879 * argument is non-NULL.
881 * The value of nfs_eofflag should be set to TRUE if the end of
882 * the directory was reached while reading.
884 * The directory seek offset (cookies) are returned to the NFS client and
885 * may be used later to restart a directory read part way through
886 * the directory. There is one cookie returned for each directory
887 * entry returned and its size is determince from nfs_sizeofcookie.
888 * The value of the cookie should be the logical offset within the
889 * directory where the on-disc version of the appropriate directory
890 * entry starts. Memory for the cookies is allocated from M_TEMP
891 * and it is freed by the caller of VNOP_READDIR.
895 struct vnop_readdir_args
{
896 struct vnodeop_desc
*a_desc
;
902 vfs_context_t a_context
;
906 @function VNOP_READDIR
907 @abstract Call down to a filesystem to enumerate directory entries.
908 @discussion VNOP_READDIR() packs a buffer with "struct dirent" directory entry representations as described
909 by the "getdirentries" manual page.
910 @param vp Directory to enumerate.
911 @param uio Destination information for resulting direntries.
912 @param flags VNODE_READDIR_EXTENDED, VNODE_READDIR_REQSEEKOFF, VNODE_READDIR_SEEKOFF32: Apple-internal flags.
913 @param eofflag Should be set to 1 if the end of the directory has been reached.
914 @param numdirent Should be set to number of entries written into buffer.
915 @param ctx Context to authenticate for readdir request.
916 @return 0 for success, else an error code.
918 #ifdef XNU_KERNEL_PRIVATE
919 extern errno_t
VNOP_READDIR(vnode_t
, struct uio
*, int, int *, int *, vfs_context_t
);
920 #endif /* XNU_KERNEL_PRIVATE */
922 struct vnop_readdirattr_args
{
923 struct vnodeop_desc
*a_desc
;
925 struct attrlist
*a_alist
;
929 uint32_t *a_newstate
;
931 uint32_t *a_actualcount
;
932 vfs_context_t a_context
;
936 @function VNOP_READDIRATTR
937 @abstract Call down to get file attributes for many files in a directory at once.
938 @discussion VNOP_READDIRATTR() packs a buffer with file attributes, as if the results of many "getattrlist" calls.
939 @param vp Directory in which to enumerate entries' attributes.
940 @param alist Which attributes are wanted for each directory entry.
941 @param uio Destination information for resulting attributes.
942 @param maxcount Maximum count of files to get attributes for.
943 @param options FSOPT_NOFOLLOW: do not follow symbolic links. FSOPT_NOINMEMUPDATE: do not use data which have been
944 updated since an inode was loaded into memory.
945 @param newstate The "newstate" should be set to a value which changes if the contents of a directory change
946 through an addition or deletion but stays the same otherwise.
947 @param eofflag Should be set to 1 if the end of the directory has been reached.
948 @param actualcount Should be set to number of files whose attributes were written into buffer.
949 @param ctx Context to authenticate for readdirattr request.
950 @return 0 for success, else an error code.
952 #ifdef XNU_KERNEL_PRIVATE
953 extern errno_t
VNOP_READDIRATTR(vnode_t
, struct attrlist
*, struct uio
*, uint32_t, uint32_t, uint32_t *, int *, uint32_t *, vfs_context_t
);
954 #endif /* XNU_KERNEL_PRIVATE */
956 struct vnop_getattrlistbulk_args
{
957 struct vnodeop_desc
*a_desc
;
959 struct attrlist
*a_alist
;
960 struct vnode_attr
*a_vap
;
965 int32_t *a_actualcount
;
966 vfs_context_t a_context
;
970 @function VNOP_GETATTRLISTBULK
971 @abstract Call down to get file attributes for many files in a directory at once.
972 @discussion VNOP_GETATTRLISTBULK() packs a buffer with file attributes, as if the results of many "getattrlist" calls.
973 @param vp Directory in which to enumerate entries' attributes.
974 @param alist Which attributes are wanted for each directory entry.
975 @param uio Destination information for resulting attributes.
976 @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.
977 @param private reserved for future use.
979 @param eofflag Should be set to 1 if the end of the directory has been reached.
980 @param actualcount Should be set to number of files whose attributes were written into buffer.
981 @param ctx Context to authenticate for getattrlistbulk request.
982 @return 0 for success, else an error code.
984 #ifdef XNU_KERNEL_PRIVATE
985 extern errno_t
VNOP_GETATTRLISTBULK(vnode_t
, struct attrlist
*, struct vnode_attr
*, uio_t
, void *, uint64_t, int32_t *, int32_t *, vfs_context_t
);
986 #endif /* XNU_KERNEL_PRIVATE */
988 struct vnop_readlink_args
{
989 struct vnodeop_desc
*a_desc
;
992 vfs_context_t a_context
;
996 @function VNOP_READLINK
997 @abstract Call down to a filesystem to get the pathname represented by a symbolic link.
998 @discussion VNOP_READLINK() gets the path stored in a symbolic link; it is called by namei() and the readlink() system call.
999 @param vp Symbolic link to read from.
1000 @param uio Destination information for link path.
1001 @param ctx Context to authenticate for readlink request.
1002 @return 0 for success, else an error code.
1004 #ifdef XNU_KERNEL_PRIVATE
1005 extern errno_t
VNOP_READLINK(vnode_t
, struct uio
*, vfs_context_t
);
1006 #endif /* XNU_KERNEL_PRIVATE */
1008 struct vnop_inactive_args
{
1009 struct vnodeop_desc
*a_desc
;
1011 vfs_context_t a_context
;
1015 @function VNOP_INACTIVE
1016 @abstract Notify a filesystem that the last usecount (persistent reference) on a vnode has been dropped.
1017 @discussion VNOP_INACTVE() gives a filesystem a chance to aggressively release resources assocated with a vnode, perhaps
1018 even to call vnode_recycle(), but no action is prescribed; it is acceptable for VNOP_INACTIVE to be a no-op and
1019 to defer all reclamation until VNOP_RECLAIM().
1020 VNOP_INACTVE() will not be called on a vnode if no persistent reference is ever taken; an
1021 important example is a stat(), which takes an iocount, reads its data, and drops that iocount.
1022 @param vp The vnode which is now inactive.
1023 @param ctx Context to authenticate for inactive message.
1024 @return 0 for success, else an error code, but return value is currently ignored.
1026 #ifdef XNU_KERNEL_PRIVATE
1027 extern errno_t
VNOP_INACTIVE(vnode_t
, vfs_context_t
);
1028 #endif /* XNU_KERNEL_PRIVATE */
1030 struct vnop_reclaim_args
{
1031 struct vnodeop_desc
*a_desc
;
1033 vfs_context_t a_context
;
1037 @function VNOP_RECLAIM
1038 @abstract Release filesystem-internal resources for a vnode.
1039 @discussion VNOP_RECLAIM() is called as part of the process of recycling a vnode. During
1040 a reclaim routine, a filesystem should remove a vnode from its hash and deallocate any resources
1041 allocated to that vnode. VFS guarantees that when VNOP_RECLAIM() is called, there are no more
1042 iocount references on a vnode (though there may still be usecount references--these are invalidated
1043 by the reclaim) and that no more will be granted. This means in practice that there will be no
1044 filesystem calls on the vnode being reclaimed until the reclaim has finished and the vnode has
1046 @param vp The vnode to reclaim.
1047 @param ctx Context to authenticate for reclaim.
1048 @return 0 for success, or an error code. A nonzero return value results in a panic.
1050 #ifdef XNU_KERNEL_PRIVATE
1051 extern errno_t
VNOP_RECLAIM(vnode_t
, vfs_context_t
);
1052 #endif /* XNU_KERNEL_PRIVATE */
1054 struct vnop_pathconf_args
{
1055 struct vnodeop_desc
*a_desc
;
1059 vfs_context_t a_context
;
1063 @function VNOP_PATHCONF
1064 @abstract Query a filesystem for path properties.
1065 @param vp The vnode whose filesystem to query.
1066 @param name Which property to request: see unistd.h. For example: _PC_CASE_SENSITIVE (is
1067 a filesystem case-sensitive?). Only one property can be requested at a time.
1068 @param retval Destination for value of property.
1069 @param ctx Context to authenticate for pathconf request.
1070 @return 0 for success, or an error code.
1072 #ifdef XNU_KERNEL_PRIVATE
1073 extern errno_t
VNOP_PATHCONF(vnode_t
, int, int32_t *, vfs_context_t
);
1074 #endif /* XNU_KERNEL_PRIVATE */
1076 struct vnop_advlock_args
{
1077 struct vnodeop_desc
*a_desc
;
1083 vfs_context_t a_context
;
1084 struct timespec
*a_timeout
;
1088 @function VNOP_ADVLOCK
1089 @abstract Aquire or release and advisory lock on a vnode.
1090 @discussion Advisory locking is somewhat complicated. VNOP_ADVLOCK is overloaded for
1091 both flock() and POSIX advisory locking usage, though not all filesystems support both (or any). VFS
1092 provides an advisory locking mechanism for filesystems which can take advantage of it; vfs_setlocklocal()
1093 marks a filesystem as using VFS advisory locking support.
1094 @param vp The vnode to lock or unlock.
1095 @param id Identifier for lock holder: ignored by most filesystems.
1096 @param op Which locking operation: F_SETLK: set locking information about a region.
1097 F_GETLK: get locking information about the specified region. F_UNLCK: Unlock a region.
1098 @param fl Description of file region to lock. l_whence is as with "lseek."
1099 Includes a type: F_RDLCK (shared lock), F_UNLCK (unlock) , and F_WRLCK (exclusive lock).
1100 @param flags F_FLOCK: use flock() semantics. F_POSIX: use POSIX semantics. F_WAIT: sleep if necessary.
1101 F_PROV: Non-coelesced provisional lock (unused in xnu).
1102 @param ctx Context to authenticate for advisory locking request.
1103 @param timeout Timespec for timeout in case of F_SETLKWTIMEOUT.
1104 @return 0 for success, or an error code.
1106 #ifdef XNU_KERNEL_PRIVATE
1107 extern errno_t
VNOP_ADVLOCK(vnode_t
, caddr_t
, int, struct flock
*, int, vfs_context_t
, struct timespec
*);
1108 #endif /* XNU_KERNEL_PRIVATE */
1110 struct vnop_allocate_args
{
1111 struct vnodeop_desc
*a_desc
;
1115 off_t
*a_bytesallocated
;
1117 vfs_context_t a_context
;
1121 @function VNOP_ALLOCATE
1122 @abstract Pre-allocate space for a file.
1123 @discussion VNOP_ALLOCATE() changes the amount of backing store set aside to
1124 a file. It can be used to either shrink or grow a file. If the file shrinks,
1125 its ubc size will be modified accordingly, but if it grows, then the ubc size is unchanged;
1126 space is set aside without being actively used by the file. VNOP_ALLOCATE() is currently only
1127 called as part of the F_PREALLOCATE fcntl.
1128 @param vp The vnode for which to preallocate space.
1129 @param length Desired preallocated file length.
1131 PREALLOCATE: preallocate allocation blocks.
1132 ALLOCATECONTIG: allocate contigious space.
1133 ALLOCATEALL: allocate all requested space or no space at all.
1134 FREEREMAINDER: deallocate allocated but unfilled blocks.
1135 ALLOCATEFROMPEOF: allocate from the physical eof.
1136 ALLOCATEFROMVOL: allocate from the volume offset.
1137 @param bytesallocated Additional bytes set aside for file. Set to 0 if none are allocated
1138 OR if the file is contracted.
1139 @param offset Hint for where to find free blocks.
1140 @param ctx Context to authenticate for allocation request.
1141 @return 0 for success, or an error code.
1143 #ifdef XNU_KERNEL_PRIVATE
1144 extern errno_t
VNOP_ALLOCATE(vnode_t
, off_t
, u_int32_t
, off_t
*, off_t
, vfs_context_t
);
1145 #endif /* XNU_KERNEL_PRIVATE */
1147 struct vnop_pagein_args
{
1148 struct vnodeop_desc
*a_desc
;
1151 upl_offset_t a_pl_offset
;
1155 vfs_context_t a_context
;
1159 @function VNOP_PAGEIN
1160 @abstract Pull file data into memory.
1161 @discussion VNOP_PAGEIN() is called by when a process faults on data mapped from a file or
1162 when madvise() demands pre-fetching. It is conceptually somewhat similar to VNOP_READ(). Filesystems
1163 are typically expected to call cluster_pagein() to handle the labor of mapping and committing the UPL.
1164 @param vp The vnode for which to page in data.
1165 @param pl UPL describing pages needing to be paged in.
1166 @param pl_offset Offset in UPL at which to start placing data.
1167 @param f_offset Offset in file of data needing to be paged in.
1168 @param size Amount of data to page in (in bytes).
1169 @param flags UPL-style flags: UPL_IOSYNC, UPL_NOCOMMIT, UPL_NORDAHEAD, UPL_VNODE_PAGER, UPL_MSYNC.
1170 Filesystems should generally leave it to the cluster layer to handle these flags. See the
1171 memory_object_types.h header in the kernel framework if interested.
1172 @param ctx Context to authenticate for pagein request.
1173 @return 0 for success, or an error code.
1175 #ifdef XNU_KERNEL_PRIVATE
1176 extern errno_t
VNOP_PAGEIN(vnode_t
, upl_t
, upl_offset_t
, off_t
, size_t, int, vfs_context_t
);
1177 #endif /* XNU_KERNEL_PRIVATE */
1179 struct vnop_pageout_args
{
1180 struct vnodeop_desc
*a_desc
;
1183 upl_offset_t a_pl_offset
;
1187 vfs_context_t a_context
;
1191 @function VNOP_PAGEOUT
1192 @abstract Write data from a mapped file back to disk.
1193 @discussion VNOP_PAGEOUT() is called when data from a mapped file needs to be flushed to disk, either
1194 because of an msync() call or due to memory pressure. Filesystems are for the most part expected to
1195 just call cluster_pageout(). However, if they opt into the VFC_VFSVNOP_PAGEOUTV2 flag, then
1196 they will be responsible for creating their own UPLs.
1197 @param vp The vnode for which to page out data.
1198 @param pl UPL describing pages needed to be paged out. If UPL is NULL, then it means the filesystem
1199 has opted into VFC_VFSVNOP_PAGEOUTV2 semantics, which means that it will create and operate on its own UPLs
1200 as opposed to relying on the one passed down into the filesystem. This means that the filesystem must be
1201 responsible for N cluster_pageout calls for N dirty ranges in the UPL.
1202 @param pl_offset Offset in UPL from which to start paging out data. Under the new VFC_VFSVNOP_PAGEOUTV2
1203 semantics, this is the offset in the range specified that must be paged out if the associated page is dirty.
1204 @param f_offset Offset in file of data needing to be paged out. Under the new VFC_VFSVNOP_PAGEOUTV2
1205 semantics, this represents the offset in the file where we should start looking for dirty pages.
1206 @param size Amount of data to page out (in bytes). Under VFC_VFSVNOP_PAGEOUTV2, this represents
1207 the size of the range to be considered. The fileystem is free to extend or shrink the specified range
1208 to better fit its blocking model as long as the page at 'pl_offset' is included.
1209 @param flags UPL-style flags: UPL_IOSYNC, UPL_NOCOMMIT, UPL_NORDAHEAD, UPL_VNODE_PAGER, UPL_MSYNC.
1210 Filesystems should generally leave it to the cluster layer to handle these flags. See the
1211 memory_object_types.h header in the kernel framework if interested.
1212 @param ctx Context to authenticate for pageout request.
1213 @return 0 for success, or an error code.
1215 #ifdef XNU_KERNEL_PRIVATE
1216 extern errno_t
VNOP_PAGEOUT(vnode_t
, upl_t
, upl_offset_t
, off_t
, size_t, int, vfs_context_t
);
1217 #endif /* XNU_KERNEL_PRIVATE */
1219 struct vnop_searchfs_args
{
1220 struct vnodeop_desc
*a_desc
;
1222 void *a_searchparams1
;
1223 void *a_searchparams2
;
1224 struct attrlist
*a_searchattrs
;
1225 uint32_t a_maxmatches
;
1226 struct timeval
*a_timelimit
;
1227 struct attrlist
*a_returnattrs
;
1228 uint32_t *a_nummatches
;
1229 uint32_t a_scriptcode
;
1232 struct searchstate
*a_searchstate
;
1233 vfs_context_t a_context
;
1237 @function VNOP_SEARCHFS
1238 @abstract Search a filesystem quickly for files or directories that match the passed-in search criteria.
1239 @discussion VNOP_SEARCHFS is a getattrlist-based system call which is implemented almost entirely inside
1240 supported filesystems. Callers provide a set of criteria to match against, and the filesystem is responsible
1241 for finding all files or directories that match the criteria. Once these files or directories are found,
1242 the user-requested attributes of these files is provided as output. The set of searchable attributes is a
1243 subset of the getattrlist attributes. For example, ATTR_CMN_UUID is not a valid searchable attribute as of
1244 10.6. A common usage scenario could be to request all files whose mod dates is greater than time X, less than
1245 time Y, and provide the inode ID and filename of the matching objects as output.
1246 @param vp The vnode representing the mountpoint of the filesystem to be searched.
1247 @param a_searchparams1 If one-argument search criteria is requested, the search criteria would go here. However,
1248 some search criteria, like ATTR_CMN_MODTIME, can be bounded. The user could request files modified between time X
1249 and time Y. In this case, the lower bound goes in a_searchparams1.
1250 @param a_searchparams2 If two-argument search criteria is requested, the upper bound goes in here.
1251 @param a_searchattrs Contains the getattrlist-style attribute bits which are requested by the current search.
1252 @param a_maxmatches The maximum number of matches to return in a single system call.
1253 @param a_timelimit The suggested maximum amount of time we can spend in the kernel to service this system call.
1254 Filesystems should use this as a guide only, and set their own internal maximum time to avoid denial of service.
1255 @param a_returnattrs The getattrlist-style attributes to return for items in the filesystem that match the search
1257 @param a_scriptcode Currently ignored.
1258 @param a_uio The uio in which to write out the search matches.
1259 @param a_searchstate Sometimes searches cannot be completed in a single system call. In this case, we provide
1260 an identifier back to the user which indicates where to resume a previously-started search. This is an opaque structure
1261 used by the filesystem to identify where to resume said search.
1262 @param a_context The context in which to perform the filesystem search.
1263 @return 0 on success, EAGAIN for searches which could not be completed in 1 call, and other ERRNOS as needed.
1266 #ifdef XNU_KERNEL_PRIVATE
1267 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
);
1268 #endif /* XNU_KERNEL_PRIVATE */
1270 struct vnop_copyfile_args
{
1271 struct vnodeop_desc
*a_desc
;
1275 struct componentname
*a_tcnp
;
1278 vfs_context_t a_context
;
1281 #ifdef XNU_KERNEL_PRIVATE
1282 extern errno_t
VNOP_COPYFILE(vnode_t
, vnode_t
, vnode_t
, struct componentname
*, int, int, vfs_context_t
);
1283 #endif /* XNU_KERNEL_PRIVATE */
1285 struct vnop_getxattr_args
{
1286 struct vnodeop_desc
*a_desc
;
1288 const char * a_name
;
1292 vfs_context_t a_context
;
1294 extern struct vnodeop_desc vnop_getxattr_desc
;
1297 @function VNOP_GETXATTR
1298 @abstract Get extended file attributes.
1299 @param vp The vnode to get extended attributes for.
1300 @param name Which property to extract.
1301 @param uio Destination information for attribute value.
1302 @param size Should be set to the amount of data written.
1303 @param options XATTR_NOSECURITY: bypass security-checking.
1304 @param ctx Context to authenticate for getxattr request.
1305 @return 0 for success, or an error code.
1307 extern errno_t
VNOP_GETXATTR(vnode_t
, const char *, uio_t
, size_t *, int, vfs_context_t
);
1309 struct vnop_setxattr_args
{
1310 struct vnodeop_desc
*a_desc
;
1312 const char * a_name
;
1315 vfs_context_t a_context
;
1317 extern struct vnodeop_desc vnop_setxattr_desc
;
1320 @function VNOP_SETXATTR
1321 @abstract Set extended file attributes.
1322 @param vp The vnode to set extended attributes for.
1323 @param name Which property to extract.
1324 @param uio Source information for attribute value.
1325 @param options XATTR_NOSECURITY: bypass security-checking. XATTR_CREATE: set value, fail if exists.
1326 XATTR_REPLACE: set value, fail if does not exist.
1327 @param ctx Context to authenticate for setxattr request.
1328 @return 0 for success, or an error code.
1330 extern errno_t
VNOP_SETXATTR(vnode_t
, const char *, uio_t
, int, vfs_context_t
);
1332 struct vnop_removexattr_args
{
1333 struct vnodeop_desc
*a_desc
;
1335 const char * a_name
;
1337 vfs_context_t a_context
;
1339 extern struct vnodeop_desc vnop_removexattr_desc
;
1342 @function VNOP_REMOVEXATTR
1343 @abstract Remove extended file attributes.
1344 @param vp The vnode from which to remove extended attributes.
1345 @param name Which attribute to delete.
1346 @param options XATTR_NOSECURITY: bypass security-checking.
1347 @param ctx Context to authenticate for attribute delete request.
1348 @return 0 for success, or an error code.
1350 #ifdef XNU_KERNEL_PRIVATE
1351 extern errno_t
VNOP_REMOVEXATTR(vnode_t
, const char *, int, vfs_context_t
);
1352 #endif /* XNU_KERNEL_PRIVATE */
1354 struct vnop_listxattr_args
{
1355 struct vnodeop_desc
*a_desc
;
1360 vfs_context_t a_context
;
1362 extern struct vnodeop_desc vnop_listxattr_desc
;
1365 @function VNOP_LISTXATTR
1366 @abstract List extended attribute keys.
1367 @discussion Should write a sequence of unseparated, null-terminated extended-attribute
1368 names into the space described by the provided uio. These keys can then be passed to
1369 getxattr() (and VNOP_GETXATTR()).
1370 @param vp The vnode for which to get extended attribute keys.
1371 @param uio Description of target memory for attribute keys.
1372 @param size Should be set to amount of data written to buffer.
1373 @param options XATTR_NOSECURITY: bypass security checking.
1374 @param ctx Context to authenticate for attribute name request.
1376 #ifdef XNU_KERNEL_PRIVATE
1377 extern errno_t
VNOP_LISTXATTR(vnode_t
, uio_t
, size_t *, int, vfs_context_t
);
1378 #endif /* XNU_KERNEL_PRIVATE */
1380 struct vnop_blktooff_args
{
1381 struct vnodeop_desc
*a_desc
;
1388 @function VNOP_BLKTOOFF
1389 @abstract Call down to a filesystem to convert a logical block number to a file offset.
1390 @discussion VNOP_BLKTOOFF() converts a logical block to a file offset in bytes. That offset
1391 can be passed to VNOP_BLOCKMAP(), then, to get a physical block number--buf_strategy() does this.
1392 @param vp The vnode for which to convert a logical block to an offset.
1393 @param lblkno Logical block number to turn into offset.
1394 @param offset Destination for file offset.
1395 @return 0 for success, else an error code.
1397 #ifdef XNU_KERNEL_PRIVATE
1398 extern errno_t
VNOP_BLKTOOFF(vnode_t
, daddr64_t
, off_t
*);
1399 #endif /* XNU_KERNEL_PRIVATE */
1401 struct vnop_offtoblk_args
{
1402 struct vnodeop_desc
*a_desc
;
1405 daddr64_t
*a_lblkno
;
1409 @function VNOP_OFFTOBLK
1410 @abstract Call down to a filesystem to convert a file offset to a logical block number.
1411 @param vp The vnode for which to convert an offset to a logical block number.
1412 @param offset File offset to convert.
1413 @param lblkno Destination for corresponding logical block number.
1414 @return 0 for success, else an error code.
1416 #ifdef XNU_KERNEL_PRIVATE
1417 extern errno_t
VNOP_OFFTOBLK(vnode_t
, off_t
, daddr64_t
*);
1418 #endif /* XNU_KERNEL_PRIVATE */
1420 struct vnop_blockmap_args
{
1421 struct vnodeop_desc
*a_desc
;
1429 vfs_context_t a_context
;
1433 @function VNOP_BLOCKMAP
1434 @abstract Call down to a filesystem to get information about the on-disk layout of a file region.
1435 @discussion VNOP_BLOCKMAP() returns the information required to pass a request for a contiguous region
1436 down to a device's strategy routine.
1437 @param vp The vnode for which to get on-disk information.
1438 @param foffset Offset (in bytes) at which region starts.
1439 @param size Size of region.
1440 @param bpn Destination for physical block number at which region begins on disk.
1441 @param run Destination for number of bytes which can be found contiguously on-disk before
1442 first discontinuity.
1443 @param poff Currently unused.
1444 @param flags VNODE_READ: request is for a read. VNODE_WRITE: request is for a write.
1445 @param ctx Context to authenticate for blockmap request; currently often set to NULL.
1446 @return 0 for success, else an error code.
1448 #ifdef XNU_KERNEL_PRIVATE
1449 extern errno_t
VNOP_BLOCKMAP(vnode_t
, off_t
, size_t, daddr64_t
*, size_t *, void *,
1450 int, vfs_context_t
);
1451 #endif /* XNU_KERNEL_PRIVATE */
1453 struct vnop_strategy_args
{
1454 struct vnodeop_desc
*a_desc
;
1459 @function VNOP_STRATEGY
1460 @abstract Initiate I/O on a file (both read and write).
1461 @discussion A filesystem strategy routine takes a buffer, performs whatever manipulations are necessary for passing
1462 the I/O request down to the device layer, and calls the appropriate device's strategy routine. Most filesystems should
1463 just call buf_strategy() with "bp" as the argument.
1464 @param bp Complete specificiation of requested I/O: region of data involved, whether request is for read or write, and so on.
1465 @return 0 for success, else an error code.
1467 extern errno_t
VNOP_STRATEGY(struct buf
*bp
);
1469 struct vnop_bwrite_args
{
1470 struct vnodeop_desc
*a_desc
;
1475 @function VNOP_BWRITE
1476 @abstract Write a buffer to backing store.
1477 @discussion VNOP_BWRITE() is called by buf_bawrite() (asynchronous write) and potentially by buf_bdwrite() (delayed write)
1478 but not by buf_bwrite(). A filesystem may choose to perform some kind of manipulation of the buffer in this routine; it
1479 generally will end up calling VFS's default implementation, vn_bwrite() (which calls buf_bwrite() without further ado).
1480 @param bp The buffer to write.
1481 @return 0 for success, else an error code.
1483 extern errno_t
VNOP_BWRITE(buf_t
);
1485 struct vnop_kqfilt_add_args
{
1486 struct vnodeop_desc
*a_desc
;
1489 vfs_context_t a_context
;
1491 extern struct vnodeop_desc vnop_kqfilt_add_desc
;
1493 #ifdef XNU_KERNEL_PRIVATE
1494 extern errno_t
VNOP_KQFILT_ADD(vnode_t
, struct knote
*, vfs_context_t
);
1495 #endif /* XNU_KERNEL_PRIVATE */
1497 struct vnop_kqfilt_remove_args
{
1498 struct vnodeop_desc
*a_desc
;
1501 vfs_context_t a_context
;
1503 extern struct vnodeop_desc vnop_kqfilt_remove_desc
;
1505 #ifdef XNU_KERNEL_PRIVATE
1506 errno_t
VNOP_KQFILT_REMOVE(vnode_t
, uintptr_t , vfs_context_t
);
1507 #endif /* XNU_KERNEL_PRIVATE */
1510 #ifdef KERNEL_PRIVATE
1511 #define VNODE_MONITOR_BEGIN 0x01
1512 #define VNODE_MONITOR_END 0x02
1513 #define VNODE_MONITOR_UPDATE 0x04
1514 struct vnop_monitor_args
{
1515 struct vnodeop_desc
*a_desc
;
1520 vfs_context_t a_context
;
1522 extern struct vnodeop_desc vnop_monitor_desc
;
1523 #endif /* KERNEL_PRIVATE */
1525 #ifdef XNU_KERNEL_PRIVATE
1527 @function VNOP_MONITOR
1528 @abstract Indicate to a filesystem that the number of watchers of a file has changed.
1529 @param vp The vnode whose watch state has changed.
1530 @param events Unused. Filesystems can ignore this parameter.
1531 @param flags Type of change to the watch state. VNODE_MONITOR_BEGIN is passed when the kernel
1532 begins tracking a new watcher of a file. VNODE_MONITOR_END is passed when a watcher stops watching a file.
1533 VNODE_MONITOR_UPDATE is currently unused. A filesystem is guaranteed that each VNODE_MONITOR_BEGIN
1534 will be matched by a VNODE_MONITOR_END with the same "handle" argument.
1535 @param handle Unique identifier for a given watcher. A VNODE_MONITOR_BEGIN for a given handle will be matched with a
1536 VNODE_MONITOR_END for the same handle; a filesystem need not consider this parameter unless
1537 it for some reason wants be able to match specific VNOP_MONITOR calls rather than just keeping
1539 @param ctx The context which is starting to monitor a file or ending a watch on a file. A matching
1540 pair of VNODE_MONITOR_BEGIN and VNODE_MONITOR_END need not have the same context.
1541 @discussion VNOP_MONITOR() is intended to let networked filesystems know when they should bother
1542 listening for changes to files which occur remotely, so that they can post notifications using
1543 vnode_notify(). Local filesystems should not implement a monitor vnop.
1544 It is called when there is a new watcher for a file or when a watcher for a file goes away.
1545 Each BEGIN will be matched with an END with the same handle. Note that vnode_ismonitored() can
1546 be used to see if there are currently watchers for a file.
1548 errno_t
VNOP_MONITOR(vnode_t
, uint32_t, uint32_t, void*, vfs_context_t
);
1549 #endif /* XNU_KERNEL_PRIVATE */
1552 struct vnop_setlabel_args
{
1553 struct vnodeop_desc
*a_desc
;
1556 vfs_context_t a_context
;
1558 extern struct vnodeop_desc vnop_setlabel_desc
;
1561 @function VNOP_SETLABEL
1562 @abstract Associate a MACF label with a file.
1563 @param vp The vnode to label.
1564 @param label The desired label.
1565 @param ctx Context to authenticate for label change.
1566 @return 0 for success, else an error code.
1568 #ifdef XNU_KERNEL_PRIVATE
1569 errno_t
VNOP_SETLABEL(vnode_t
, struct label
*, vfs_context_t
);
1570 #endif /* XNU_KERNEL_PRIVATE */
1572 #ifdef __APPLE_API_UNSTABLE
1576 enum nsoperation
{ NS_OPEN
, NS_CREATE
, NS_DELETE
};
1578 struct vnop_getnamedstream_args
{
1579 struct vnodeop_desc
*a_desc
;
1583 enum nsoperation a_operation
;
1585 vfs_context_t a_context
;
1589 @function VNOP_GETNAMEDSTREAM
1590 @abstract Get a named stream associated with a file.
1591 @discussion If this call sucecss, svpp should be returned with an iocount which the caller
1592 will drop. VFS provides a facility for simulating named streams when interacting with filesystems
1593 which do not support them.
1594 @param vp The vnode for which to get a named stream.
1595 @param svpp Destination for pointer to named stream's vnode.
1596 @param name The name of the named stream, e.g. "com.apple.ResourceFork".
1597 @param operation Operation to perform. In HFS and AFP, this parameter is only considered as follows:
1598 if the resource fork has not been opened and the operation is not NS_OPEN, fail with ENOATTR. Currently
1599 only passed as NS_OPEN by VFS.
1600 @param flags Currently unused.
1601 @param ctx Context to authenticate for getting named stream.
1602 @return 0 for success, else an error code.
1604 #ifdef XNU_KERNEL_PRIVATE
1605 extern errno_t
VNOP_GETNAMEDSTREAM(vnode_t
, vnode_t
*, const char *, enum nsoperation
, int flags
, vfs_context_t
);
1606 #endif /* XNU_KERNEL_PRIVATE */
1608 struct vnop_makenamedstream_args
{
1609 struct vnodeop_desc
*a_desc
;
1614 vfs_context_t a_context
;
1618 @function VNOP_MAKENAMEDSTREAM
1619 @abstract Create a named stream associated with a file.
1620 @discussion If this call succeeds, svpp should be returned with an iocount which the caller will drop.
1621 VFS provides a facility for simulating named streams when interacting with filesystems
1622 which do not support them.
1623 @param vp The vnode for which to get a named stream.
1624 @param svpp Destination for pointer to named stream's vnode.
1625 @param name The name of the named stream, e.g. "com.apple.ResourceFork".
1626 @param flags Currently unused.
1627 @param ctx Context to authenticate creating named stream.
1628 @return 0 for success, else an error code.
1630 #ifdef XNU_KERNEL_PRIVATE
1631 extern errno_t
VNOP_MAKENAMEDSTREAM(vnode_t
, vnode_t
*, const char *, int flags
, vfs_context_t
);
1632 #endif /* XNU_KERNEL_PRIVATE */
1634 struct vnop_removenamedstream_args
{
1635 struct vnodeop_desc
*a_desc
;
1640 vfs_context_t a_context
;
1644 @function VNOP_REMOVENAMEDSTREAM
1645 @abstract Delete a named stream associated with a file.
1646 @discussion VFS provides a facility for simulating named streams when interacting with filesystems
1647 which do not support them.
1648 @param vp The vnode to which the named stream belongs.
1649 @param svp The named stream's vnode.
1650 @param name The name of the named stream, e.g. "com.apple.ResourceFork".
1651 @param flags Currently unused.
1652 @param ctx Context to authenticate deleting named stream.
1653 @return 0 for success, else an error code.
1655 #ifdef XNU_KERNEL_PRIVATE
1656 extern errno_t
VNOP_REMOVENAMEDSTREAM(vnode_t
, vnode_t
, const char *, int flags
, vfs_context_t
);
1657 #endif /* XNU_KERNEL_PRIVATE */
1666 #endif /* !_SYS_VNODE_IF_H_ */