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