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