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