]> git.saurik.com Git - apple/xnu.git/blame_incremental - bsd/sys/vnode.h
xnu-1504.15.3.tar.gz
[apple/xnu.git] / bsd / sys / vnode.h
... / ...
CommitLineData
1/*
2 * Copyright (c) 2000-2007 Apple 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/* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
29/*
30 * Copyright (c) 1989, 1993
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 * @(#)vnode.h 8.17 (Berkeley) 5/20/95
62 */
63
64#ifndef _VNODE_H_
65#define _VNODE_H_
66
67#include <sys/appleapiopts.h>
68#include <sys/cdefs.h>
69#ifdef KERNEL
70#include <sys/kernel_types.h>
71#include <sys/signal.h>
72#endif
73
74/*
75 * The vnode is the focus of all file activity in UNIX. There is a
76 * unique vnode allocated for each active file, each current directory,
77 * each mounted-on file, text file, and the root.
78 */
79
80/*
81 * Vnode types. VNON means no type.
82 */
83enum vtype { VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK, VFIFO, VBAD, VSTR,
84 VCPLX };
85
86/*
87 * Vnode tag types.
88 * These are for the benefit of external programs only (e.g., pstat)
89 * and should NEVER be inspected by the kernel.
90 */
91enum vtagtype {
92 VT_NON, VT_UFS, VT_NFS, VT_MFS, VT_MSDOSFS, VT_LFS, VT_LOFS, VT_FDESC,
93 VT_PORTAL, VT_NULL, VT_UMAP, VT_KERNFS, VT_PROCFS, VT_AFS, VT_ISOFS,
94 VT_UNION, VT_HFS, VT_ZFS, VT_DEVFS, VT_WEBDAV, VT_UDF, VT_AFP,
95 VT_CDDA, VT_CIFS, VT_OTHER};
96
97
98/*
99 * flags for VNOP_BLOCKMAP
100 */
101#define VNODE_READ 0x01
102#define VNODE_WRITE 0x02
103
104
105
106/* flags for VNOP_ALLOCATE */
107#define PREALLOCATE 0x00000001 /* preallocate allocation blocks */
108#define ALLOCATECONTIG 0x00000002 /* allocate contigious space */
109#define ALLOCATEALL 0x00000004 /* allocate all requested space */
110 /* or no space at all */
111#define FREEREMAINDER 0x00000008 /* deallocate allocated but */
112 /* unfilled blocks */
113#define ALLOCATEFROMPEOF 0x00000010 /* allocate from the physical eof */
114#define ALLOCATEFROMVOL 0x00000020 /* allocate from the volume offset */
115
116/*
117 * Token indicating no attribute value yet assigned. some user source uses this
118 */
119#define VNOVAL (-1)
120
121
122#ifdef KERNEL
123
124/*
125 * Flags for ioflag.
126 */
127#define IO_UNIT 0x0001 /* do I/O as atomic unit */
128#define IO_APPEND 0x0002 /* append write to end */
129#define IO_SYNC 0x0004 /* do I/O synchronously */
130#define IO_NODELOCKED 0x0008 /* underlying node already locked */
131#define IO_NDELAY 0x0010 /* FNDELAY flag set in file table */
132#define IO_NOZEROFILL 0x0020 /* F_SETSIZE fcntl uses to prevent zero filling */
133#ifdef XNU_KERNEL_PRIVATE
134#define IO_REVOKE IO_NOZEROFILL /* revoked close for tty, will Not be used in conjunction */
135#endif /* XNU_KERNEL_PRIVATE */
136#define IO_TAILZEROFILL 0x0040 /* zero fills at the tail of write */
137#define IO_HEADZEROFILL 0x0080 /* zero fills at the head of write */
138#define IO_NOZEROVALID 0x0100 /* do not zero fill if valid page */
139#define IO_NOZERODIRTY 0x0200 /* do not zero fill if page is dirty */
140#define IO_CLOSE 0x0400 /* I/O issued from close path */
141#define IO_NOCACHE 0x0800 /* same effect as VNOCACHE_DATA, but only for this 1 I/O */
142#define IO_RAOFF 0x1000 /* same effect as VRAOFF, but only for this 1 I/O */
143#define IO_DEFWRITE 0x2000 /* defer write if vfs.defwrite is set */
144#define IO_PASSIVE 0x4000 /* this I/O is marked as background I/O so it won't throttle Throttleable I/O */
145#define IO_BACKGROUND IO_PASSIVE /* used for backward compatibility. to be removed after IO_BACKGROUND is no longer
146 * used by DiskImages in-kernel mode */
147#define IO_NOAUTH 0x8000 /* No authorization checks. */
148
149
150/*
151 * Component Name: this structure describes the pathname
152 * information that is passed through the VNOP interface.
153 */
154struct componentname {
155 /*
156 * Arguments to lookup.
157 */
158 uint32_t cn_nameiop; /* lookup operation */
159 uint32_t cn_flags; /* flags (see below) */
160#ifdef BSD_KERNEL_PRIVATE
161 vfs_context_t cn_context;
162 void * pad_obsolete2;
163
164/* XXX use of these defines are deprecated */
165#define cn_proc (cn_context->vc_proc + 0) /* non-lvalue */
166#define cn_cred (cn_context->vc_ucred + 0) /* non-lvalue */
167
168#else
169 void * obsolete1; /* use vfs_context_t */
170 void * obsolete2; /* use vfs_context_t */
171#endif
172 /*
173 * Shared between lookup and commit routines.
174 */
175 char *cn_pnbuf; /* pathname buffer */
176 int cn_pnlen; /* length of allocated buffer */
177 char *cn_nameptr; /* pointer to looked up name */
178 int cn_namelen; /* length of looked up component */
179 uint32_t cn_hash; /* hash value of looked up name */
180 uint32_t cn_consume; /* chars to consume in lookup() */
181};
182
183/*
184 * component name operations (for VNOP_LOOKUP)
185 */
186#define LOOKUP 0 /* perform name lookup only */
187#define CREATE 1 /* setup for file creation */
188#define DELETE 2 /* setup for file deletion */
189#define RENAME 3 /* setup for file renaming */
190#define OPMASK 3 /* mask for operation */
191
192/*
193 * component name operational modifier flags
194 */
195#define FOLLOW 0x00000040 /* follow symbolic links */
196#define NOTRIGGER 0x10000000 /* don't trigger automounts */
197
198/*
199 * component name parameter descriptors.
200 */
201#define ISDOTDOT 0x00002000 /* current component name is .. */
202#define MAKEENTRY 0x00004000 /* entry is to be added to name cache */
203#define ISLASTCN 0x00008000 /* this is last component of pathname */
204#define ISWHITEOUT 0x00020000 /* found whiteout */
205#define DOWHITEOUT 0x00040000 /* do whiteouts */
206
207
208/* The following structure specifies a vnode for creation */
209struct vnode_fsparam {
210 struct mount * vnfs_mp; /* mount point to which this vnode_t is part of */
211 enum vtype vnfs_vtype; /* vnode type */
212 const char * vnfs_str; /* File system Debug aid */
213 struct vnode * vnfs_dvp; /* The parent vnode */
214 void * vnfs_fsnode; /* inode */
215 int (**vnfs_vops)(void *); /* vnode dispatch table */
216 int vnfs_markroot; /* is this a root vnode in FS (not a system wide one) */
217 int vnfs_marksystem; /* is a system vnode */
218 dev_t vnfs_rdev; /* dev_t for block or char vnodes */
219 off_t vnfs_filesize; /* that way no need for getattr in UBC */
220 struct componentname * vnfs_cnp; /* component name to add to namecache */
221 uint32_t vnfs_flags; /* flags */
222};
223
224#define VNFS_NOCACHE 0x01 /* do not add to name cache at this time */
225#define VNFS_CANTCACHE 0x02 /* never add this instance to the name cache */
226#define VNFS_ADDFSREF 0x04 /* take fs (named) reference */
227
228#define VNCREATE_FLAVOR 0
229#define VCREATESIZE sizeof(struct vnode_fsparam)
230
231/*
232 * Vnode attributes, new-style.
233 *
234 * The vnode_attr structure is used to transact attribute changes and queries
235 * with the filesystem.
236 *
237 * Note that this structure may be extended, but existing fields must not move.
238 */
239
240#define VATTR_INIT(v) do {(v)->va_supported = (v)->va_active = 0ll; (v)->va_vaflags = 0;} while(0)
241#define VATTR_SET_ACTIVE(v, a) ((v)->va_active |= VNODE_ATTR_ ## a)
242#define VATTR_SET_SUPPORTED(v, a) ((v)->va_supported |= VNODE_ATTR_ ## a)
243#define VATTR_IS_SUPPORTED(v, a) ((v)->va_supported & VNODE_ATTR_ ## a)
244#define VATTR_CLEAR_ACTIVE(v, a) ((v)->va_active &= ~VNODE_ATTR_ ## a)
245#define VATTR_CLEAR_SUPPORTED(v, a) ((v)->va_supported &= ~VNODE_ATTR_ ## a)
246#define VATTR_IS_ACTIVE(v, a) ((v)->va_active & VNODE_ATTR_ ## a)
247#define VATTR_ALL_SUPPORTED(v) (((v)->va_active & (v)->va_supported) == (v)->va_active)
248#define VATTR_INACTIVE_SUPPORTED(v) do {(v)->va_active &= ~(v)->va_supported; (v)->va_supported = 0;} while(0)
249#define VATTR_SET(v, a, x) do { (v)-> a = (x); VATTR_SET_ACTIVE(v, a);} while(0)
250#define VATTR_WANTED(v, a) VATTR_SET_ACTIVE(v, a)
251#define VATTR_RETURN(v, a, x) do { (v)-> a = (x); VATTR_SET_SUPPORTED(v, a);} while(0)
252#define VATTR_NOT_RETURNED(v, a) (VATTR_IS_ACTIVE(v, a) && !VATTR_IS_SUPPORTED(v, a))
253
254/*
255 * Two macros to simplify conditional checking in kernel code.
256 */
257#define VATTR_IS(v, a, x) (VATTR_IS_SUPPORTED(v, a) && (v)-> a == (x))
258#define VATTR_IS_NOT(v, a, x) (VATTR_IS_SUPPORTED(v, a) && (v)-> a != (x))
259
260#define VNODE_ATTR_va_rdev (1LL<< 0) /* 00000001 */
261#define VNODE_ATTR_va_nlink (1LL<< 1) /* 00000002 */
262#define VNODE_ATTR_va_total_size (1LL<< 2) /* 00000004 */
263#define VNODE_ATTR_va_total_alloc (1LL<< 3) /* 00000008 */
264#define VNODE_ATTR_va_data_size (1LL<< 4) /* 00000010 */
265#define VNODE_ATTR_va_data_alloc (1LL<< 5) /* 00000020 */
266#define VNODE_ATTR_va_iosize (1LL<< 6) /* 00000040 */
267#define VNODE_ATTR_va_uid (1LL<< 7) /* 00000080 */
268#define VNODE_ATTR_va_gid (1LL<< 8) /* 00000100 */
269#define VNODE_ATTR_va_mode (1LL<< 9) /* 00000200 */
270#define VNODE_ATTR_va_flags (1LL<<10) /* 00000400 */
271#define VNODE_ATTR_va_acl (1LL<<11) /* 00000800 */
272#define VNODE_ATTR_va_create_time (1LL<<12) /* 00001000 */
273#define VNODE_ATTR_va_access_time (1LL<<13) /* 00002000 */
274#define VNODE_ATTR_va_modify_time (1LL<<14) /* 00004000 */
275#define VNODE_ATTR_va_change_time (1LL<<15) /* 00008000 */
276#define VNODE_ATTR_va_backup_time (1LL<<16) /* 00010000 */
277#define VNODE_ATTR_va_fileid (1LL<<17) /* 00020000 */
278#define VNODE_ATTR_va_linkid (1LL<<18) /* 00040000 */
279#define VNODE_ATTR_va_parentid (1LL<<19) /* 00080000 */
280#define VNODE_ATTR_va_fsid (1LL<<20) /* 00100000 */
281#define VNODE_ATTR_va_filerev (1LL<<21) /* 00200000 */
282#define VNODE_ATTR_va_gen (1LL<<22) /* 00400000 */
283#define VNODE_ATTR_va_encoding (1LL<<23) /* 00800000 */
284#define VNODE_ATTR_va_type (1LL<<24) /* 01000000 */
285#define VNODE_ATTR_va_name (1LL<<25) /* 02000000 */
286#define VNODE_ATTR_va_uuuid (1LL<<26) /* 04000000 */
287#define VNODE_ATTR_va_guuid (1LL<<27) /* 08000000 */
288#define VNODE_ATTR_va_nchildren (1LL<<28) /* 10000000 */
289#define VNODE_ATTR_va_dirlinkcount (1LL<<29) /* 20000000 */
290
291#define VNODE_ATTR_BIT(n) (VNODE_ATTR_ ## n)
292/*
293 * Read-only attributes.
294 */
295#define VNODE_ATTR_RDONLY (VNODE_ATTR_BIT(va_rdev) | \
296 VNODE_ATTR_BIT(va_nlink) | \
297 VNODE_ATTR_BIT(va_total_size) | \
298 VNODE_ATTR_BIT(va_total_alloc) | \
299 VNODE_ATTR_BIT(va_data_alloc) | \
300 VNODE_ATTR_BIT(va_iosize) | \
301 VNODE_ATTR_BIT(va_fileid) | \
302 VNODE_ATTR_BIT(va_linkid) | \
303 VNODE_ATTR_BIT(va_parentid) | \
304 VNODE_ATTR_BIT(va_fsid) | \
305 VNODE_ATTR_BIT(va_filerev) | \
306 VNODE_ATTR_BIT(va_gen) | \
307 VNODE_ATTR_BIT(va_name) | \
308 VNODE_ATTR_BIT(va_type) | \
309 VNODE_ATTR_BIT(va_nchildren) | \
310 VNODE_ATTR_BIT(va_dirlinkcount))
311/*
312 * Attributes that can be applied to a new file object.
313 */
314#define VNODE_ATTR_NEWOBJ (VNODE_ATTR_BIT(va_rdev) | \
315 VNODE_ATTR_BIT(va_uid) | \
316 VNODE_ATTR_BIT(va_gid) | \
317 VNODE_ATTR_BIT(va_mode) | \
318 VNODE_ATTR_BIT(va_flags) | \
319 VNODE_ATTR_BIT(va_acl) | \
320 VNODE_ATTR_BIT(va_create_time) | \
321 VNODE_ATTR_BIT(va_modify_time) | \
322 VNODE_ATTR_BIT(va_change_time) | \
323 VNODE_ATTR_BIT(va_encoding) | \
324 VNODE_ATTR_BIT(va_type) | \
325 VNODE_ATTR_BIT(va_uuuid) | \
326 VNODE_ATTR_BIT(va_guuid))
327
328
329struct vnode_attr {
330 /* bitfields */
331 uint64_t va_supported;
332 uint64_t va_active;
333
334 /*
335 * Control flags. The low 16 bits are reserved for the
336 * ioflags being passed for truncation operations.
337 */
338 int va_vaflags;
339
340 /* traditional stat(2) parameter fields */
341 dev_t va_rdev; /* device id (device nodes only) */
342 uint64_t va_nlink; /* number of references to this file */
343 uint64_t va_total_size; /* size in bytes of all forks */
344 uint64_t va_total_alloc; /* disk space used by all forks */
345 uint64_t va_data_size; /* size in bytes of the fork managed by current vnode */
346 uint64_t va_data_alloc; /* disk space used by the fork managed by current vnode */
347 uint32_t va_iosize; /* optimal I/O blocksize */
348
349 /* file security information */
350 uid_t va_uid; /* owner UID */
351 gid_t va_gid; /* owner GID */
352 mode_t va_mode; /* posix permissions */
353 uint32_t va_flags; /* file flags */
354 struct kauth_acl *va_acl; /* access control list */
355
356 /* timestamps */
357 struct timespec va_create_time; /* time of creation */
358 struct timespec va_access_time; /* time of last access */
359 struct timespec va_modify_time; /* time of last data modification */
360 struct timespec va_change_time; /* time of last metadata change */
361 struct timespec va_backup_time; /* time of last backup */
362
363 /* file parameters */
364 uint64_t va_fileid; /* file unique ID in filesystem */
365 uint64_t va_linkid; /* file link unique ID */
366 uint64_t va_parentid; /* parent ID */
367 uint32_t va_fsid; /* filesystem ID */
368 uint64_t va_filerev; /* file revision counter */ /* XXX */
369 uint32_t va_gen; /* file generation count */ /* XXX - relationship of
370 * these two? */
371 /* misc parameters */
372 uint32_t va_encoding; /* filename encoding script */
373
374 enum vtype va_type; /* file type (create only) */
375 char * va_name; /* Name for ATTR_CMN_NAME; MAXPATHLEN bytes */
376 guid_t va_uuuid; /* file owner UUID */
377 guid_t va_guuid; /* file group UUID */
378
379 /* Meaningful for directories only */
380 uint64_t va_nchildren; /* Number of items in a directory */
381 uint64_t va_dirlinkcount; /* Real references to dir (i.e. excluding "." and ".." refs) */
382
383 /* add new fields here only */
384
385};
386
387/*
388 * Flags for va_vaflags.
389 */
390#define VA_UTIMES_NULL 0x010000 /* utimes argument was NULL */
391#define VA_EXCLUSIVE 0x020000 /* exclusive create request */
392
393/*
394 * Modes. Some values same as Ixxx entries from inode.h for now.
395 */
396#define VSUID 0x800 /*04000*/ /* set user id on execution */
397#define VSGID 0x400 /*02000*/ /* set group id on execution */
398#define VSVTX 0x200 /*01000*/ /* save swapped text even after use */
399#define VREAD 0x100 /*00400*/ /* read, write, execute permissions */
400#define VWRITE 0x080 /*00200*/
401#define VEXEC 0x040 /*00100*/
402
403/*
404 * Convert between vnode types and inode formats (since POSIX.1
405 * defines mode word of stat structure in terms of inode formats).
406 */
407extern enum vtype iftovt_tab[];
408extern int vttoif_tab[];
409#define IFTOVT(mode) (iftovt_tab[((mode) & S_IFMT) >> 12])
410#define VTTOIF(indx) (vttoif_tab[(int)(indx)])
411#define MAKEIMODE(indx, mode) (int)(VTTOIF(indx) | (mode))
412
413/*
414 * Flags to various vnode functions.
415 */
416#define SKIPSYSTEM 0x0001 /* vflush: skip vnodes marked VSYSTEM */
417#define FORCECLOSE 0x0002 /* vflush: force file closeure */
418#define WRITECLOSE 0x0004 /* vflush: only close writeable files */
419#define SKIPSWAP 0x0008 /* vflush: skip vnodes marked VSWAP */
420#define SKIPROOT 0x0010 /* vflush: skip root vnodes marked VROOT */
421
422#define DOCLOSE 0x0008 /* vclean: close active files */
423
424#define V_SAVE 0x0001 /* vinvalbuf: sync file first */
425#define V_SAVEMETA 0x0002 /* vinvalbuf: leave indirect blocks */
426
427#define REVOKEALL 0x0001 /* vnop_revoke: revoke all aliases */
428
429/* VNOP_REMOVE: do not delete busy files (Carbon remove file semantics) */
430#define VNODE_REMOVE_NODELETEBUSY 0x0001
431
432/* VNOP_READDIR flags: */
433#define VNODE_READDIR_EXTENDED 0x0001 /* use extended directory entries */
434#define VNODE_READDIR_REQSEEKOFF 0x0002 /* requires seek offset (cookies) */
435#define VNODE_READDIR_SEEKOFF32 0x0004 /* seek offset values should fit in 32 bits */
436
437
438#define NULLVP ((struct vnode *)NULL)
439
440#ifndef BSD_KERNEL_PRIVATE
441struct vnodeop_desc;
442#endif
443
444extern int desiredvnodes; /* number of vnodes desired */
445
446
447/*
448 * This structure is used to configure the new vnodeops vector.
449 */
450struct vnodeopv_entry_desc {
451 struct vnodeop_desc *opve_op; /* which operation this is */
452 int (*opve_impl)(void *); /* code implementing this operation */
453};
454struct vnodeopv_desc {
455 /* ptr to the ptr to the vector where op should go */
456 int (***opv_desc_vector_p)(void *);
457 struct vnodeopv_entry_desc *opv_desc_ops; /* null terminated list */
458};
459
460/*!
461 @function vn_default_error
462 @abstract Default vnode operation to fill unsupported slots in vnode operation vectors.
463 @return ENOTSUP
464 */
465int vn_default_error(void);
466
467/*
468 * A generic structure.
469 * This can be used by bypass routines to identify generic arguments.
470 */
471struct vnop_generic_args {
472 struct vnodeop_desc *a_desc;
473 /* other random data follows, presumably */
474};
475
476#ifndef _KAUTH_ACTION_T
477typedef int kauth_action_t;
478# define _KAUTH_ACTION_T
479#endif
480
481#include <sys/vnode_if.h>
482
483__BEGIN_DECLS
484
485/*!
486 @function vnode_create
487 @abstract Create and initialize a vnode.
488 @discussion Returns wth an iocount held on the vnode which must eventually be dropped with vnode_put().
489 @param flavor Should be VNCREATE_FLAVOR.
490 @param size Size of the struct vnode_fsparam in "data".
491 @param data Pointer to a struct vnode_fsparam containing initialization information.
492 @param vpp Pointer to a vnode pointer, to be filled in with newly created vnode.
493 @return 0 for success, error code otherwise.
494 */
495errno_t vnode_create(uint32_t, uint32_t, void *, vnode_t *);
496
497/*!
498 @function vnode_addfsref
499 @abstract Mark a vnode as being stored in a filesystem hash.
500 @discussion Should only be called once on a vnode, and never if that vnode was created with VNFS_ADDFSREF.
501 There should be a corresponding call to vnode_removefsref() when the vnode is reclaimed; VFS assumes that a
502 n unused vnode will not be marked as referenced by a filesystem.
503 @param vp The vnode to mark.
504 @return Always 0.
505 */
506int vnode_addfsref(vnode_t);
507
508/*!
509 @function vnode_removefsref
510 @abstract Mark a vnode as no longer being stored in a filesystem hash.
511 @discussion Should only be called once on a vnode (during a reclaim), and only after the vnode has either been created with VNFS_ADDFSREF or marked by vnode_addfsref().
512 @param vp The vnode to unmark.
513 @return Always 0.
514 */
515int vnode_removefsref(vnode_t);
516
517/*!
518 @function vnode_hasdirtyblks
519 @abstract Check if a vnode has dirty data waiting to be written to disk.
520 @discussion Note that this routine is unsynchronized; it is only a snapshot and its result may cease to be true at the moment it is returned..
521 @param vp The vnode to test.
522 @return Nonzero if there are dirty blocks, 0 otherwise
523 */
524int vnode_hasdirtyblks(vnode_t);
525
526/*!
527 @function vnode_hascleanblks
528 @abstract Check if a vnode has clean buffers associated with it.
529 @discussion Note that this routine is unsynchronized; it is only a snapshot and its result may cease to be true at the moment it is returned..
530 @param vp The vnode to test.
531 @return Nonzero if there are clean blocks, 0 otherwise.
532 */
533int vnode_hascleanblks(vnode_t);
534
535#define VNODE_ASYNC_THROTTLE 15
536/*!
537 @function vnode_waitforwrites
538 @abstract Wait for the number of pending writes on a vnode to drop below a target.
539 @param vp The vnode to monitor.
540 @param output_target Max pending write count with which to return.
541 @param slpflag Flags for msleep().
542 @param slptimeout Frequency with which to force a check for completion; increments of 10 ms.
543 @param msg String to pass msleep() .
544 @return 0 for success, or an error value from msleep().
545 */
546int vnode_waitforwrites(vnode_t, int, int, int, const char *);
547
548/*!
549 @function vnode_startwrite
550 @abstract Increment the count of pending writes on a vnode.
551 @param vp The vnode whose count to increment.
552 @return void.
553 */
554void vnode_startwrite(vnode_t);
555
556/*!
557 @function vnode_startwrite
558 @abstract Decrement the count of pending writes on a vnode .
559 @discussion Also wakes up threads waiting for the write count to drop, as in vnode_waitforwrites.
560 @param vp The vnode whose count to decrement.
561 @return void.
562 */
563void vnode_writedone(vnode_t);
564
565/*!
566 @function vnode_vtype
567 @abstract Return a vnode's type.
568 @param vp The vnode whose type to grab.
569 @return The vnode's type.
570 */
571enum vtype vnode_vtype(vnode_t);
572
573/*!
574 @function vnode_vid
575 @abstract Return a vnode's vid (generation number), which is constant from creation until reclaim.
576 @param vp The vnode whose vid to grab.
577 @return The vnode's vid.
578 */
579uint32_t vnode_vid(vnode_t);
580
581/*!
582 @function vnode_mountedhere
583 @abstract Returns a pointer to a mount placed on top of a vnode, should it exist.
584 @param vp The vnode from whom to take the covering mount.
585 @return Pointer to mount covering a vnode, or NULL if none exists.
586 */
587mount_t vnode_mountedhere(vnode_t vp);
588
589/*!
590 @function vnode_mount
591 @abstract Get the mount structure for the filesystem that a vnode belongs to.
592 @param vp The vnode whose mount to grab.
593 @return The mount, directly.
594 */
595mount_t vnode_mount(vnode_t);
596
597/*!
598 @function vnode_specrdev
599 @abstract Return the device id of the device associated with a special file.
600 @param vp The vnode whose device id to extract--vnode must be a special file.
601 @return The device id.
602 */
603dev_t vnode_specrdev(vnode_t);
604
605/*!
606 @function vnode_fsnode
607 @abstract Gets the filesystem-specific data associated with a vnode.
608 @param vp The vnode whose data to grab.
609 @return The filesystem-specific data, directly.
610 */
611void * vnode_fsnode(vnode_t);
612
613/*!
614 @function vnode_clearfsnode
615 @abstract Sets a vnode's filesystem-specific data to be NULL.
616 @discussion This routine should only be called when a vnode is no longer in use, i.e. during a VNOP_RECLAIM.
617 @param vp The vnode whose data to clear out.
618 @return void.
619 */
620void vnode_clearfsnode(vnode_t);
621
622/*!
623 @function vnode_isvroot
624 @abstract Determine if a vnode is the root of its filesystem.
625 @param vp The vnode to test.
626 @return Nonzero if the vnode is the root, 0 if it is not.
627 */
628int vnode_isvroot(vnode_t);
629
630/*!
631 @function vnode_issystem
632 @abstract Determine if a vnode is marked as a System vnode.
633 @param vp The vnode to test.
634 @return Nonzero if the vnode is a system vnode, 0 if it is not.
635 */
636int vnode_issystem(vnode_t);
637
638/*!
639 @function vnode_ismount
640 @abstract Determine if there is currently a mount occurring which will cover this vnode.
641 @discussion Note that this is only a snapshot; a mount may begin or end at any time.
642 @param vp The vnode to test.
643 @return Nonzero if there is a mount in progress, 0 otherwise.
644 */
645int vnode_ismount(vnode_t);
646
647/*!
648 @function vnode_isreg
649 @abstract Determine if a vnode is a regular file.
650 @param vp The vnode to test.
651 @return Nonzero if the vnode is of type VREG, 0 otherwise.
652 */
653int vnode_isreg(vnode_t);
654
655/*!
656 @function vnode_isdir
657 @abstract Determine if a vnode is a directory.
658 @param vp The vnode to test.
659 @return Nonzero if the vnode is of type VDIR, 0 otherwise.
660 */
661int vnode_isdir(vnode_t);
662
663/*!
664 @function vnode_islnk
665 @abstract Determine if a vnode is a symbolic link.
666 @param vp The vnode to test.
667 @return Nonzero if the vnode is of type VLNK, 0 otherwise.
668 */
669int vnode_islnk(vnode_t);
670
671/*!
672 @function vnode_isfifo
673 @abstract Determine if a vnode is a named pipe.
674 @param vp The vnode to test.
675 @return Nonzero if the vnode is of type VFIFO, 0 otherwise.
676 */
677int vnode_isfifo(vnode_t);
678
679/*!
680 @function vnode_isblk
681 @abstract Determine if a vnode is a block device special file.
682 @param vp The vnode to test.
683 @return Nonzero if the vnode is of type VBLK, 0 otherwise.
684 */
685int vnode_isblk(vnode_t);
686
687/*!
688 @function vnode_ischr
689 @abstract Determine if a vnode is a character device special file.
690 @param vp The vnode to test.
691 @return Nonzero if the vnode is of type VCHR, 0 otherwise.
692 */
693int vnode_ischr(vnode_t);
694
695/*!
696 @function vnode_isswap
697 @abstract Determine if a vnode is being used as a swap file.
698 @param vp The vnode to test.
699 @return Nonzero if the vnode is being used as swap, 0 otherwise.
700 */
701int vnode_isswap(vnode_t vp);
702
703#ifdef __APPLE_API_UNSTABLE
704/*!
705 @function vnode_isnamedstream
706 @abstract Determine if a vnode is a named stream.
707 @param vp The vnode to test.
708 @return Nonzero if the vnode is a named stream, 0 otherwise.
709 */
710int vnode_isnamedstream(vnode_t);
711#endif
712
713/*!
714 @function vnode_ismountedon
715 @abstract Determine if a vnode is a block device on which a filesystem has been mounted.
716 @discussion A block device marked as being mounted on cannot be opened.
717 @param vp The vnode to test.
718 @return Nonzero if the vnode is a block device on which an filesystem is mounted, 0 otherwise.
719 */
720int vnode_ismountedon(vnode_t);
721
722/*!
723 @function vnode_setmountedon
724 @abstract Set flags indicating that a block device vnode has been mounted as a filesystem.
725 @discussion A block device marked as being mounted on cannot be opened.
726 @param vp The vnode to set flags on, a block device.
727 @return void.
728 */
729void vnode_setmountedon(vnode_t);
730
731/*!
732 @function vnode_clearmountedon
733 @abstract Clear flags indicating that a block device vnode has been mounted as a filesystem.
734 @param vp The vnode to clear flags on, a block device.
735 @return void.
736 */
737void vnode_clearmountedon(vnode_t);
738
739/*!
740 @function vnode_isrecycled
741 @abstract Check if a vnode is dead or in the process of being killed (recycled).
742 @discussion This is only a snapshot: a vnode may start to be recycled, or go from dead to in use, at any time.
743 @param vp The vnode to test.
744 @return Nonzero if vnode is dead or being recycled, 0 otherwise.
745 */
746int vnode_isrecycled(vnode_t);
747
748/*!
749 @function vnode_isnocache
750 @abstract Check if a vnode is set to not have its data cached in memory (i.e. we write-through to disk and always read from disk).
751 @param vp The vnode to test.
752 @return Nonzero if vnode is set to not have data chached, 0 otherwise.
753 */
754int vnode_isnocache(vnode_t);
755
756/*!
757 @function vnode_israge
758 @abstract Check if a vnode is marked for rapid aging
759 @param vp The vnode to test.
760 @return Nonzero if vnode is marked for rapid aging, 0 otherwise
761 */
762int vnode_israge(vnode_t);
763
764/*!
765 @function vnode_setnocache
766 @abstract Set a vnode to not have its data cached in memory (i.e. we write-through to disk and always read from disk).
767 @param vp The vnode whose flags to set.
768 @return void.
769 */
770void vnode_setnocache(vnode_t);
771
772/*!
773 @function vnode_clearnocache
774 @abstract Clear the flag on a vnode indicating that data should not be cached in memory (i.e. we write-through to disk and always read from disk).
775 @param vp The vnode whose flags to clear.
776 @return void.
777 */
778void vnode_clearnocache(vnode_t);
779
780/*!
781 @function vnode_isnoreadahead
782 @abstract Check if a vnode is set to not have data speculatively read in in hopes of future cache hits.
783 @param vp The vnode to test.
784 @return Nonzero if readahead is disabled, 0 otherwise.
785 */
786int vnode_isnoreadahead(vnode_t);
787
788/*!
789 @function vnode_setnoreadahead
790 @abstract Set a vnode to not have data speculatively read in in hopes of hitting in cache.
791 @param vp The vnode on which to prevent readahead.
792 @return void.
793 */
794void vnode_setnoreadahead(vnode_t);
795
796/*!
797 @function vnode_clearnoreadahead
798 @abstract Clear the flag indicating that a vnode should not have data speculatively read in.
799 @param vp The vnode whose flag to clear.
800 @return void.
801 */
802void vnode_clearnoreadahead(vnode_t);
803
804/* left only for compat reasons as User code depends on this from getattrlist, for ex */
805
806/*!
807 @function vnode_settag
808 @abstract Set a vnode filesystem-specific "tag."
809 @discussion Sets a tag indicating which filesystem a vnode belongs to, e.g. VT_HFS, VT_UDF, VT_ZFS. The kernel never inspects this data, though the filesystem tags are defined in vnode.h; it is for the benefit of user programs via getattrlist.
810 @param vp The vnode whose tag to set.
811 @return void.
812 */
813void vnode_settag(vnode_t, int);
814
815/*!
816 @function vnode_tag
817 @abstract Get the vnode filesystem-specific "tag."
818 @discussion Gets the tag indicating which filesystem a vnode belongs to, e.g. VT_HFS, VT_UDF, VT_ZFS. The kernel never inspects this data, though the filesystem tags are defined in vnode.h; it is for the benefit of user programs via getattrlist.
819 @param vp The vnode whose tag to grab.
820 @return The tag.
821 */
822int vnode_tag(vnode_t);
823
824/*!
825 @function vnode_getattr
826 @abstract Get vnode attributes.
827 @discussion Desired attributes are set with VATTR_SET_ACTIVE and VNODE_ATTR* macros. Supported attributes are determined after call with VATTR_IS_SUPPORTED.
828 @param vp The vnode whose attributes to grab.
829 @param vap Structure containing: 1) A list of requested attributes 2) Space to indicate which attributes are supported and being returned 3) Space to return attributes.
830 @param ctx Context for authentication.
831 @return 0 for success or an error code.
832 */
833int vnode_getattr(vnode_t vp, struct vnode_attr *vap, vfs_context_t ctx);
834
835/*!
836 @function vnode_setattr
837 @abstract Set vnode attributes.
838 @discussion Attributes to set are marked with VATTR_SET_ACTIVE and VNODE_ATTR* macros. Attributes successfully set are determined after call with VATTR_IS_SUPPORTED.
839 @param vp The vnode whose attributes to set.
840 @param vap Structure containing: 1) A list of attributes to set 2) Space for values for those attributes 3) Space to indicate which attributes were set.
841 @param ctx Context for authentication.
842 @return 0 for success or an error code.
843 */
844int vnode_setattr(vnode_t vp, struct vnode_attr *vap, vfs_context_t ctx);
845
846/*!
847 @function vfs_rootvnode
848 @abstract Returns the root vnode with an iocount.
849 @discussion Caller must vnode_put() the root node when done.
850 @return Pointer to root vnode if successful; error code if there is a problem taking an iocount.
851 */
852vnode_t vfs_rootvnode(void);
853
854/*!
855 @function vnode_uncache_credentials
856 @abstract Clear out cached credentials on a vnode.
857 @discussion When we authorize an action on a vnode, we cache the credential that was authorized and the actions it was authorized for in case a similar request follows. This function destroys that caching.
858 @param vp The vnode whose cache to clear.
859 @return void.
860 */
861void vnode_uncache_credentials(vnode_t vp);
862
863/*!
864 @function vnode_setmultipath
865 @abstract Mark a vnode as being reachable by multiple paths, i.e. as a hard link.
866 @discussion "Multipath" vnodes can be reached through more than one entry in the filesystem, and so must be handled differently for caching and event notification purposes. A filesystem should mark a vnode with multiple hardlinks this way.
867 @param vp The vnode to mark.
868 @return void.
869 */
870void vnode_setmultipath(vnode_t vp);
871
872/*!
873 @function vnode_vfsmaxsymlen
874 @abstract Determine the maximum length of a symbolic link for the filesystem on which a vnode resides.
875 @param vp The vnode for which to get filesystem symlink size cap.
876 @return Max symlink length.
877 */
878uint32_t vnode_vfsmaxsymlen(vnode_t);
879
880/*!
881 @function vnode_vfsisrdonly
882 @abstract Determine if the filesystem to which a vnode belongs is mounted read-only.
883 @param vp The vnode for which to get filesystem writeability.
884 @return Nonzero if the filesystem is read-only, 0 otherwise.
885 */
886int vnode_vfsisrdonly(vnode_t);
887
888/*!
889 @function vnode_vfstypenum
890 @abstract Get the "type number" of the filesystem to which a vnode belongs.
891 @discussion This is an archaic construct; most filesystems are assigned a type number based on the order in which they are registered with the system.
892 @param vp The vnode whose filesystem to examine.
893 @return The type number of the fileystem to which the vnode belongs.
894 */
895int vnode_vfstypenum(vnode_t);
896
897/*!
898 @function vnode_vfsname
899 @abstract Get the name of the filesystem to which a vnode belongs.
900 @param vp The vnode whose filesystem to examine.
901 @param buf Destination for vfs name: should have size MFSNAMELEN or greater.
902 @return The name of the fileystem to which the vnode belongs.
903 */
904void vnode_vfsname(vnode_t, char *);
905
906/*!
907 @function vnode_vfs64bitready
908 @abstract Determine if the filesystem to which a vnode belongs is marked as ready to interact with 64-bit user processes.
909 @param vp The vnode whose filesystem to examine.
910 @return Nonzero if filesystem is marked ready for 64-bit interactions; 0 otherwise.
911 */
912int vnode_vfs64bitready(vnode_t);
913
914/* These should move to private ... not documenting for now */
915int vfs_context_get_special_port(vfs_context_t, int, ipc_port_t *);
916int vfs_context_set_special_port(vfs_context_t, int, ipc_port_t);
917
918/*!
919 @function vfs_context_proc
920 @abstract Get the BSD process structure associated with a vfs_context_t.
921 @param ctx Context whose associated process to find.
922 @return Process if available, NULL otherwise.
923 */
924proc_t vfs_context_proc(vfs_context_t);
925
926/*!
927 @function vfs_context_ucred
928 @abstract Get the credential associated with a vfs_context_t.
929 @discussion Succeeds if and only if the context has a thread, the thread has a task, and the task has a BSD proc.
930 @param ctx Context whose associated process to find.
931 @return Process if available, NULL otherwise.
932 */
933kauth_cred_t vfs_context_ucred(vfs_context_t);
934
935/*!
936 @function vfs_context_pid
937 @abstract Get the process id of the BSD process associated with a vfs_context_t.
938 @param ctx Context whose associated process to find.
939 @return Process id.
940 */
941int vfs_context_pid(vfs_context_t);
942
943/*!
944 @function vfs_context_issignal
945 @abstract Get a bitfield of pending signals for the BSD process associated with a vfs_context_t.
946 @discussion The bitfield is constructed using the sigmask() macro, in the sense of bits |= sigmask(SIGSEGV).
947 @param ctx Context whose associated process to find.
948 @return Bitfield of pending signals.
949 */
950int vfs_context_issignal(vfs_context_t, sigset_t);
951
952/*!
953 @function vfs_context_suser
954 @abstract Determine if a vfs_context_t corresponds to the superuser.
955 @param ctx Context to examine.
956 @return Nonzero if context belongs to superuser, 0 otherwise.
957 */
958int vfs_context_suser(vfs_context_t);
959
960/*!
961 @function vfs_context_is64bit
962 @abstract Determine if a vfs_context_t corresponds to a 64-bit user process.
963 @param ctx Context to examine.
964 @return Nonzero if context is of 64-bit process, 0 otherwise.
965 */
966int vfs_context_is64bit(vfs_context_t);
967
968/*!
969 @function vfs_context_create
970 @abstract Create a new vfs_context_t with appropriate references held.
971 @discussion The context must be released with vfs_context_rele() when no longer in use.
972 @param ctx Context to copy, or NULL to use information from running thread.
973 @return The new context, or NULL in the event of failure.
974 */
975vfs_context_t vfs_context_create(vfs_context_t);
976
977/*!
978 @function vfs_context_rele
979 @abstract Release references on components of a context and deallocate it.
980 @discussion A context should not be referenced after vfs_context_rele has been called.
981 @param ctx Context to release.
982 @return Always 0.
983 */
984int vfs_context_rele(vfs_context_t);
985
986/*!
987 @function vfs_context_current
988 @abstract Get the vfs_context for the current thread, or the kernel context if there is no context for current thread.
989 @discussion Kexts should not use this function--it is preferred to use vfs_context_create(NULL) and vfs_context_rele(), which ensure proper reference counting of underlying structures.
990 @return Context for current thread, or kernel context if thread context is unavailable.
991 */
992vfs_context_t vfs_context_current(void);
993#ifdef KERNEL_PRIVATE
994int vfs_context_bind(vfs_context_t);
995#endif
996
997/*!
998 @function vflush
999 @abstract Reclaim the vnodes associated with a mount.
1000 @param mp The mount whose vnodes to kill.
1001 @param skipvp A specific vnode to not reclaim or to let interrupt an un-forced flush
1002 @param flags Control which
1003 @discussion This function is used to clear out the vnodes associated with a mount as part of the unmount process.
1004 Its parameters can determine which vnodes to skip in the process and whether in-use vnodes should be forcibly reclaimed.
1005 Filesystems should call this function from their unmount code, because VFS code will always call it with SKIPROOT | SKIPSWAP | SKIPSYSTEM; filesystems
1006 must take care of such vnodes themselves.
1007 SKIPSYSTEM skip vnodes marked VSYSTEM
1008 FORCECLOSE force file closeure
1009 WRITECLOSE only close writeable files
1010 SKIPSWAP skip vnodes marked VSWAP
1011 SKIPROOT skip root vnodes marked VROOT
1012 @return 0 for success, EBUSY if vnodes were busy and FORCECLOSE was not set.
1013 */
1014int vflush(struct mount *mp, struct vnode *skipvp, int flags);
1015
1016/*!
1017 @function vnode_get
1018 @abstract Increase the iocount on a vnode.
1019 @discussion If vnode_get() succeeds, the resulting io-reference must be dropped with vnode_put().
1020 This function succeeds unless the vnode in question is dead or in the process of dying AND the current iocount is zero.
1021 This means that it can block an ongoing reclaim which is blocked behind some other iocount.
1022
1023 On success, vnode_get() returns with an iocount held on the vnode; this type of reference is intended to be held only for short periods of time (e.g.
1024 across a function call) and provides a strong guarantee about the life of the vnode; vnodes with positive iocounts cannot be
1025 recycled, and an iocount is required for any operation on a vnode. However, vnode_get() does not provide any guarantees
1026 about the identity of the vnode it is called on; unless there is a known existing iocount on the vnode at time the call is made,
1027 it could be recycled and put back in use before the vnode_get() succeeds, so the caller may be referencing a
1028 completely different vnode than was intended. vnode_getwithref() and vnode_getwithvid()
1029 provide guarantees about vnode identity.
1030
1031 @return 0 for success, ENOENT if the vnode is dead and without existing io-reference.
1032 */
1033int vnode_get(vnode_t);
1034
1035/*!
1036 @function vnode_getwithvid
1037 @abstract Increase the iocount on a vnode, checking that the vnode is alive and has not changed vid (i.e. been recycled)
1038 @discussion If vnode_getwithvid() succeeds, the resulting io-reference must be dropped with vnode_put().
1039 This function succeeds unless the vnode in question is dead, in the process of dying, or has been recycled (and given a different vnode id).
1040 The intended usage is that a vnode is stored and its vid (vnode_vid(vp)) recorded while an iocount is held (example: a filesystem hash). The
1041 iocount is then dropped, and time passes (perhaps locks are dropped and picked back up). Subsequently, vnode_getwithvid() is called to get an iocount,
1042 but we are alerted if the vnode has been recycled.
1043
1044 On success, vnode_getwithvid() returns with an iocount held on the vnode; this type of reference is intended to be held only for short periods of time (e.g.
1045 across a function call) and provides a strong guarantee about the life of the vnode. vnodes with positive iocounts cannot be
1046 recycled. An iocount is required for any operation on a vnode.
1047 @return 0 for success, ENOENT if the vnode is dead, in the process of being reclaimed, or has been recycled and reused.
1048 */
1049int vnode_getwithvid(vnode_t, uint32_t);
1050
1051/*!
1052 @function vnode_getwithref
1053 @abstract Increase the iocount on a vnode on which a usecount (persistent reference) is held.
1054 @discussion If vnode_getwithref() succeeds, the resulting io-reference must be dropped with vnode_put().
1055 vnode_getwithref() will succeed on dead vnodes; it should fail with ENOENT on vnodes which are in the process of being reclaimed.
1056 Because it is only called with a usecount on the vnode, the caller is guaranteed that the vnode has not been
1057 reused for a different file, though it may now be dead and have deadfs vnops (which return errors like EIO, ENXIO, ENOTDIR).
1058 On success, vnode_getwithref() returns with an iocount held on the vnode; this type of reference is intended to be held only for short periods of time (e.g.
1059 across a function call) and provides a strong guarantee about the life of the vnode. vnodes with positive iocounts cannot be
1060 recycled. An iocount is required for any operation on a vnode.
1061 @return 0 for success, ENOENT if the vnode is dead, in the process of being reclaimed, or has been recycled and reused.
1062 */
1063int vnode_getwithref(vnode_t);
1064
1065/*!
1066 @function vnode_put
1067 @abstract Decrement the iocount on a vnode.
1068 @discussion vnode_put() is called to indicate that a vnode is no longer in active use. It removes the guarantee that a
1069 vnode will not be recycled. This routine should be used to release io references no matter how they were obtained.
1070 @param vp The vnode whose iocount to drop.
1071 @return Always 0.
1072 */
1073int vnode_put(vnode_t);
1074
1075/*!
1076 @function vnode_ref
1077 @abstract Increment the usecount on a vnode.
1078 @discussion If vnode_ref() succeeds, the resulting usecount must be released with vnode_rele(). vnode_ref() is called to obtain
1079 a persistent reference on a vnode. This type of reference does not provide the same strong guarantee that a vnode will persist
1080 as does an iocount--it merely ensures that a vnode will not be reused to represent a different file. However, a usecount may be
1081 held for extended periods of time, whereas an iocount is intended to be obtained and released quickly as part of performing a
1082 vnode operation. A holder of a usecount must call vnode_getwithref()/vnode_put() in order to perform any operations on that vnode.
1083 @param vp The vnode on which to obtain a persistent reference.
1084 @return 0 for success; ENOENT if the vnode is dead or in the process of being recycled AND the calling thread is not the vnode owner.
1085 */
1086int vnode_ref(vnode_t);
1087
1088/*!
1089 @function vnode_rele
1090 @abstract Decrement the usecount on a vnode.
1091 @discussion vnode_rele() is called to relese a persistent reference on a vnode. Releasing the last usecount
1092 opens the door for a vnode to be reused as a new file; it also triggers a VNOP_INACTIVE call to the filesystem,
1093 though that will not happen immediately if there are outstanding iocount references.
1094 @param vp The vnode whose usecount to drop.
1095 @return void.
1096 */
1097void vnode_rele(vnode_t);
1098
1099/*!
1100 @function vnode_isinuse
1101 @abstract Determine if the number of persistent (usecount) references on a vnode is greater than a given count.
1102 @discussion vnode_isinuse() compares a vnode's usecount (corresponding to vnode_ref() calls) to its refcnt parameter
1103 (the number of references the caller expects to be on the vnode). Note that "kusecount" references, corresponding
1104 to parties interested only in event notifications, e.g. open(..., O_EVTONLY), are not counted towards the total; the comparison is
1105 (usecount - kusecount > recnt). It is
1106 also important to note that the result is only a snapshot; usecounts can change from moment to moment, and the result of vnode_isinuse
1107 may no longer be correct the very moment that the caller receives it.
1108 @param vp The vnode whose use-status to check.
1109 @param refcnt The threshold for saying that a vnode is in use.
1110 @return void.
1111 */
1112int vnode_isinuse(vnode_t, int);
1113
1114/*!
1115 @function vnode_recycle
1116 @abstract Cause a vnode to be reclaimed and prepared for reuse.
1117 @discussion Like all vnode KPIs, must be called with an iocount on the target vnode.
1118 vnode_recycle() will mark that vnode for reclaim when all existing references are dropped.
1119 @param vp The vnode to recycle.
1120 @return 1 if the vnode was reclaimed (i.e. there were no existing references), 0 if it was only marked for future reclaim.
1121 */
1122int vnode_recycle(vnode_t);
1123
1124#ifdef KERNEL_PRIVATE
1125
1126#define VNODE_EVENT_DELETE 0x00000001 /* file was removed */
1127#define VNODE_EVENT_WRITE 0x00000002 /* file or directory contents changed */
1128#define VNODE_EVENT_EXTEND 0x00000004 /* ubc size increased */
1129#define VNODE_EVENT_ATTRIB 0x00000008 /* attributes changed (suitable for permission changes if type unknown)*/
1130#define VNODE_EVENT_LINK 0x00000010 /* link count changed */
1131#define VNODE_EVENT_RENAME 0x00000020 /* vnode was renamed */
1132#define VNODE_EVENT_PERMS 0x00000040 /* permissions changed: will cause a NOTE_ATTRIB */
1133#define VNODE_EVENT_FILE_CREATED 0x00000080 /* file created in directory: will cause NOTE_WRITE */
1134#define VNODE_EVENT_DIR_CREATED 0x00000100 /* directory created inside this directory: will cause NOTE_WRITE */
1135#define VNODE_EVENT_FILE_REMOVED 0x00000200 /* file removed from this directory: will cause NOTE_WRITE */
1136#define VNODE_EVENT_DIR_REMOVED 0x00000400 /* subdirectory from this directory: will cause NOTE_WRITE */
1137
1138#ifdef BSD_KERNEL_PRIVATE
1139#define VNODE_NOTIFY_ATTRS (VNODE_ATTR_BIT(va_fsid) | \
1140 VNODE_ATTR_BIT(va_fileid)| \
1141 VNODE_ATTR_BIT(va_mode) | \
1142 VNODE_ATTR_BIT(va_uid) | \
1143 VNODE_ATTR_BIT(va_gid) | \
1144 VNODE_ATTR_BIT(va_dirlinkcount) | \
1145 VNODE_ATTR_BIT(va_nlink))
1146
1147
1148
1149#endif /* BSD_KERNEL_PRIVATE */
1150
1151/*!
1152 @function vnode_notify
1153 @abstract Send a notification up to VFS.
1154 @param vp Vnode for which to provide notification.
1155 @param vap Attributes for that vnode, to be passed to fsevents.
1156 @discussion Filesystem determines which attributes to pass up using
1157 vfs_get_notify_attributes(&vap). The most specific events possible should be passed,
1158 e.g. VNODE_EVENT_FILE_CREATED on a directory rather than just VNODE_EVENT_WRITE, but
1159 a less specific event can be passed up if more specific information is not available.
1160 Will not reenter the filesystem.
1161 @return 0 for success, else an error code.
1162 */
1163int vnode_notify(vnode_t, uint32_t, struct vnode_attr*);
1164
1165/*!
1166 @function vnode_ismonitored
1167 @abstract Check whether a file has watchers that would make it useful to query a server
1168 for file changes.
1169 @param vp Vnode to examine.
1170 @discussion Will not reenter the filesystem.
1171 @return Zero if not monitored, nonzero if monitored.
1172 */
1173int vnode_ismonitored(vnode_t);
1174
1175/*!
1176 @function vfs_get_notify_attributes
1177 @abstract Determine what attributes are required to send up a notification with vnode_notify().
1178 @param vap Structure to initialize and activate required attributes on.
1179 @discussion Will not reenter the filesystem.
1180 @return 0 for success, nonzero for error (currently always succeeds).
1181 */
1182int vfs_get_notify_attributes(struct vnode_attr *vap);
1183
1184/*!
1185 @function vn_getpath_fsenter
1186 @abstract Attempt to get a vnode's path, willing to enter the filesystem.
1187 @discussion Paths to vnodes are not always straightforward: a file with multiple hard-links will have multiple pathnames,
1188 and it is sometimes impossible to determine a vnode's full path. vn_getpath_fsenter() may enter the filesystem
1189 to try to construct a path, so filesystems should be wary of calling it.
1190 @param vp Vnode whose path to get
1191 @param pathbuf Buffer in which to store path.
1192 @param len Destination for length of resulting path string. Result will include NULL-terminator in count--that is, "len"
1193 will be strlen(pathbuf) + 1.
1194 @return 0 for success or an error.
1195 */
1196int vn_getpath_fsenter(struct vnode *vp, char *pathbuf, int *len);
1197
1198#endif /* KERNEL_PRIVATE */
1199
1200#define VNODE_UPDATE_PARENT 0x01
1201#define VNODE_UPDATE_NAME 0x02
1202#define VNODE_UPDATE_CACHE 0x04
1203#define VNODE_UPDATE_PURGE 0x08
1204/*!
1205 @function vnode_update_identity
1206 @abstract Update vnode data associated with the vfs cache.
1207 @discussion The vfs namecache is central to tracking vnode-identifying data and to locating files on the system. vnode_update_identity()
1208 is used to update vnode data associated with the cache. It can set a vnode's parent and/or name (also potentially set by vnode_create())
1209 or flush cache data.
1210 @param vp The vnode whose information to update.
1211 @param dvp Parent to set on the vnode if VNODE_UPDATE_PARENT is used.
1212 @param name Name to set in the cache for the vnode if VNODE_UPDATE_NAME is used. The buffer passed in can be subsequently freed, as the cache
1213 does its own name storage. String should be NULL-terminated unless length and hash value are specified.
1214 @param name_len Length of name, if known. Passing 0 causes the cache to determine the length itself.
1215 @param name_hashval Hash value of name, if known. Passing 0 causes the cache to hash the name itself.
1216 @param flags VNODE_UPDATE_PARENT: set parent. VNODE_UPDATE_NAME: set name. VNODE_UPDATE_CACHE: flush cache entries for hard links
1217 associated with this file. VNODE_UPDATE_PURGE: flush cache entries for hard links and children of this file.
1218 @return void.
1219 */
1220void vnode_update_identity(vnode_t vp, vnode_t dvp, const char *name, int name_len, uint32_t name_hashval, int flags);
1221
1222/*!
1223 @function vn_bwrite
1224 @abstract System-provided implementation of "bwrite" vnop.
1225 @discussion This routine is available for filesystems which do not want to implement their own "bwrite" vnop. It just calls
1226 buf_bwrite() without modifying its arguments.
1227 @param ap Standard parameters to a bwrite vnop.
1228 @return Results of buf_bwrite directly.
1229 */
1230int vn_bwrite(struct vnop_bwrite_args *ap);
1231
1232/*!
1233 @function vnode_authorize
1234 @abstract Authorize a kauth-style action on a vnode.
1235 @discussion Operations on dead vnodes are always allowed (though never do anything).
1236 @param vp Vnode on which to authorize action.
1237 @param dvp Parent of "vp," can be NULL.
1238 @param action Action to authorize, e.g. KAUTH_VNODE_READ_DATA. See bsd/sys/kauth.h.
1239 @param ctx Context for which to authorize actions.
1240 @return EACCESS if permission is denied. 0 if operation allowed. Various errors from lower layers.
1241 */
1242int vnode_authorize(vnode_t /*vp*/, vnode_t /*dvp*/, kauth_action_t, vfs_context_t);
1243
1244/*!
1245 @function vnode_authattr
1246 @abstract Given a vnode_attr structure, determine what kauth-style actions must be authorized in order to set those attributes.
1247 @discussion vnode_authorize requires kauth-style actions; if we want to set a vnode_attr structure on a vnode, we need to translate
1248 the set of attributes to a set of kauth-style actions. This routine will return errors for certain obviously disallowed, or
1249 incoherent, actions.
1250 @param vp The vnode on which to authorize action.
1251 @param vap Pointer to vnode_attr struct containing desired attributes to set and their values.
1252 @param actionp Destination for set of actions to authorize
1253 @param ctx Context for which to authorize actions.
1254 @return 0 (and a result in "actionp" for success. Otherwise, an error code.
1255 */
1256int vnode_authattr(vnode_t, struct vnode_attr *, kauth_action_t *, vfs_context_t);
1257
1258/*!
1259 @function vnode_authattr_new
1260 @abstract Initialize and validate file creation parameters with respect to the current context.
1261 @discussion vnode_authattr_new() will fill in unitialized values in the vnode_attr struct with defaults, and will validate the structure
1262 with respect to the current context for file creation.
1263 @param dvp The directory in which creation will occur.
1264 @param vap Pointer to vnode_attr struct containing desired attributes to set and their values.
1265 @param noauth If 1, treat the caller as the superuser, i.e. do not check permissions.
1266 @param ctx Context for which to authorize actions.
1267 @return KAUTH_RESULT_ALLOW for success, an error to indicate invalid or disallowed attributes.
1268 */
1269int vnode_authattr_new(vnode_t /*dvp*/, struct vnode_attr *, int /*noauth*/, vfs_context_t);
1270
1271/*!
1272 @function vnode_close
1273 @abstract Close a file as opened with vnode_open().
1274 @discussion vnode_close() drops the refcount (persistent reference) picked up in vnode_open() and calls down to the filesystem with VNOP_CLOSE. It should
1275 be called with both an iocount and a refcount on the vnode and will drop both.
1276 @param vp The vnode to close.
1277 @param flags Flags to close: FWASWRITTEN indicates that the file was written to.
1278 @param ctx Context against which to validate operation.
1279 @return 0 for success or an error from the filesystem.
1280 */
1281errno_t vnode_close(vnode_t, int, vfs_context_t);
1282
1283/*!
1284 @function vn_getpath
1285 @abstract Construct the path to a vnode.
1286 @discussion Paths to vnodes are not always straightforward: a file with multiple hard-links will have multiple pathnames,
1287 and it is sometimes impossible to determine a vnode's full path. vn_getpath() will not enter the filesystem.
1288 @param vp The vnode whose path to obtain.
1289 @param pathbuf Destination for pathname; should be of size MAXPATHLEN
1290 @param len Destination for length of resulting path string. Result will include NULL-terminator in count--that is, "len"
1291 will be strlen(pathbuf) + 1.
1292 @return 0 for success or an error code.
1293 */
1294int vn_getpath(struct vnode *vp, char *pathbuf, int *len);
1295
1296/*
1297 * Flags for the vnode_lookup and vnode_open
1298 */
1299#define VNODE_LOOKUP_NOFOLLOW 0x01
1300#define VNODE_LOOKUP_NOCROSSMOUNT 0x02
1301#define VNODE_LOOKUP_DOWHITEOUT 0x04
1302/*!
1303 @function vnode_lookup
1304 @abstract Convert a path into a vnode.
1305 @discussion This routine is a thin wrapper around xnu-internal lookup routines; if successful,
1306 it returns with an iocount held on the resulting vnode which must be dropped with vnode_put().
1307 @param path Path to look up.
1308 @param flags VNODE_LOOKUP_NOFOLLOW: do not follow symbolic links. VNODE_LOOKUP_NOCROSSMOUNT: do not cross mount points.
1309 @return Results 0 for success or an error code.
1310 */
1311errno_t vnode_lookup(const char *, int, vnode_t *, vfs_context_t);
1312
1313/*!
1314 @function vnode_open
1315 @abstract Open a file identified by a path--roughly speaking an in-kernel open(2).
1316 @discussion If vnode_open() succeeds, it returns with both an iocount and a usecount on the returned vnode. These must
1317 be released eventually; the iocount should be released with vnode_put() as soon as any initial operations
1318 on the vnode are over, whereas the usecount should be released via vnode_close().
1319 @param path Path to look up.
1320 @param fmode e.g. O_NONBLOCK, O_APPEND; see bsd/sys/fcntl.h.
1321 @param cmode Permissions with which to create file if it does not exist.
1322 @param flags Same as vnode_lookup().
1323 @param vpp Destination for vnode.
1324 @param ctx Context with which to authorize open/creation.
1325 @return 0 for success or an error code.
1326 */
1327errno_t vnode_open(const char *, int, int, int, vnode_t *, vfs_context_t);
1328
1329/*
1330 * exported vnode operations
1331 */
1332
1333/*!
1334 @function vnode_iterate
1335 @abstract Perform an operation on (almost) all vnodes from a given mountpoint.
1336 @param mp Mount whose vnodes to operate on.
1337 @param flags
1338 VNODE_RELOAD Mark inactive vnodes for recycle.
1339 VNODE_WAIT
1340 VNODE_WRITEABLE Only examine vnodes with writes in progress.
1341 VNODE_WITHID No effect.
1342 VNODE_NOLOCK_INTERNAL No effect.
1343 VNODE_NODEAD No effect.
1344 VNODE_NOSUSPEND No effect.
1345 VNODE_ITERATE_ALL No effect.
1346 VNODE_ITERATE_ACTIVE No effect.
1347 VNODE_ITERATE_INACTIVE No effect.
1348
1349 @param callout Function to call on each vnode.
1350 @param arg Argument which will be passed to callout along with each vnode.
1351 @return Zero for success, else an error code. Will return 0 immediately if there are no vnodes hooked into the mount.
1352 @discussion Skips vnodes which are dead, in the process of reclaim, suspended, or of type VNON.
1353 */
1354int vnode_iterate(struct mount *, int, int (*)(struct vnode *, void *), void *);
1355
1356/*
1357 * flags passed into vnode_iterate
1358 */
1359#define VNODE_RELOAD 0x01
1360#define VNODE_WAIT 0x02
1361#define VNODE_WRITEABLE 0x04
1362#define VNODE_WITHID 0x08
1363#define VNODE_NOLOCK_INTERNAL 0x10
1364#define VNODE_NODEAD 0x20
1365#define VNODE_NOSUSPEND 0x40
1366#define VNODE_ITERATE_ALL 0x80
1367#define VNODE_ITERATE_ACTIVE 0x100
1368#define VNODE_ITERATE_INACTIVE 0x200
1369#ifdef BSD_KERNEL_PRIVATE
1370#define VNODE_ALWAYS 0x400
1371#endif /* BSD_KERNEL_PRIVATE */
1372
1373/*
1374 * return values from callback
1375 */
1376#define VNODE_RETURNED 0 /* done with vnode, reference can be dropped */
1377#define VNODE_RETURNED_DONE 1 /* done with vnode, reference can be dropped, terminate iteration */
1378#define VNODE_CLAIMED 2 /* don't drop reference */
1379#define VNODE_CLAIMED_DONE 3 /* don't drop reference, terminate iteration */
1380
1381/*!
1382 @function vn_revoke
1383 @abstract Invalidate all references to a vnode.
1384 @discussion Reclaims the vnode, giving it deadfs vnops (though not halting operations which are already in progress).
1385 Also reclaims all aliased vnodes (important for devices). People holding usecounts on the vnode, e.g. processes
1386 with the file open, will find that all subsequent operations but closing the file fail.
1387 @param vp The vnode to revoke.
1388 @param flags Unused.
1389 @param ctx Context against which to validate operation.
1390 @return 0 always.
1391 */
1392int vn_revoke(vnode_t vp, int flags, vfs_context_t);
1393
1394/* namecache function prototypes */
1395/*!
1396 @function cache_lookup
1397 @abstract Check for a filename in a directory using the VFS name cache.
1398 @discussion cache_lookup() will flush negative cache entries and return 0 if the operation of the cn_nameiop is CREATE or RENAME.
1399 Often used from the filesystem during a lookup vnop. The filesystem will be called to if there is a negative cache entry for a file,
1400 so it can make sense to initially check for negative entries (and possibly lush them).
1401 @param dvp Directory in which lookup is occurring.
1402 @param vpp Destination for vnode pointer.
1403 @param cnp Various data about lookup, e.g. filename and intended operation.
1404 @return ENOENT: the filesystem has previously added a negative entry with cache_enter() to indicate that there is no
1405 file of the given name in "dp." -1: successfully found a cached vnode (vpp is set). 0: No data in the cache, or operation is CRETE/RENAME.
1406 */
1407int cache_lookup(vnode_t dvp, vnode_t *vpp, struct componentname *cnp);
1408
1409/*!
1410 @function cache_enter
1411 @abstract Add a (name,vnode) entry to the VFS namecache.
1412 @discussion Generally used to add a cache entry after a successful filesystem-level lookup or to add a
1413 negative entry after one which did not find its target.
1414 @param dvp Directory in which file lives.
1415 @param vp File to add to cache. A non-NULL vp is stored for rapid access; a NULL vp indicates
1416 that there is no such file in the directory and speeds future failed lookups.
1417 @param cnp Various data about lookup, e.g. filename and intended operation.
1418 @return void.
1419 */
1420void cache_enter(vnode_t dvp, vnode_t vp, struct componentname *cnp);
1421
1422/*!
1423 @function cache_purge
1424 @abstract Remove all data relating to a vnode from the namecache.
1425 @discussion Will flush all hardlinks to the vnode as well as all children (should any exist). Logical
1426 to use when cached data about a vnode becomes invalid, for instance in an unlink.
1427 @param vp The vnode to purge.
1428 @return void.
1429 */
1430void cache_purge(vnode_t vp);
1431
1432/*!
1433 @function cache_purge_negatives
1434 @abstract Remove all negative cache entries which are children of a given vnode.
1435 @discussion Appropriate to use when negative cache information for a directory could have
1436 become invalid, e.g. after file creation.
1437 @param vp The vnode whose negative children to purge.
1438 @return void.
1439 */
1440void cache_purge_negatives(vnode_t vp);
1441
1442
1443/*
1444 * Global string-cache routines. You can pass zero for nc_hash
1445 * if you don't know it (add_name() will then compute the hash).
1446 * There are no flags for now but maybe someday.
1447 */
1448/*!
1449 @function vfs_addname
1450 @abstract Deprecated
1451 @discussion vnode_update_identity() and vnode_create() make vfs_addname() unnecessary for kexts.
1452 */
1453const char *vfs_addname(const char *name, uint32_t len, uint32_t nc_hash, uint32_t flags);
1454
1455/*!
1456 @function vfs_removename
1457 @abstract Deprecated
1458 @discussion vnode_update_identity() and vnode_create() make vfs_addname() unnecessary for kexts.
1459 */
1460int vfs_removename(const char *name);
1461
1462/*!
1463 @function vcount
1464 @abstract Count total references to a given file, disregarding "kusecount" (event listener, as with O_EVTONLY) references.
1465 @discussion For a regular file, just return (usecount-kusecount); for device files, return the sum over all
1466 vnodes 'v' which reference that device of (usecount(v) - kusecount(v)). Note that this is merely a snapshot and could be
1467 invalid by the time the caller checks the result.
1468 @param vp The vnode whose references to count.
1469 @return Count of references.
1470 */
1471int vcount(vnode_t vp);
1472
1473/*!
1474 @function vn_path_package_check
1475 @abstract Figure out if a path corresponds to a Mac OS X package.
1476 @discussion Determines if the extension on a path is a known OS X extension type.
1477 @param vp Unused.
1478 @param path Path to check.
1479 @param pathlen Size of path buffer.
1480 @param component Set to index of start of last path component if the path is found to be a package. Set to -1 if
1481 the path is not a known package type.
1482 @return 0 unless some parameter was invalid, in which case EINVAL is returned. Determine package-ness by checking
1483 what *component is set to.
1484 */
1485int vn_path_package_check(vnode_t vp, char *path, int pathlen, int *component);
1486
1487#ifdef KERNEL_PRIVATE
1488/*!
1489 @function vn_searchfs_inappropriate_name
1490 @abstract Figure out if the component is inappropriate for a SearchFS query.
1491 @param name component to check
1492 @param len length of component.
1493 @return 0 if no match, 1 if inappropriate.
1494 */
1495int vn_searchfs_inappropriate_name(const char *name, int len);
1496#endif
1497
1498/*!
1499 @function vn_rdwr
1500 @abstract Read from or write to a file.
1501 @discussion vn_rdwr() abstracts the details of constructing a uio and picking a vnode operation to allow
1502 simple in-kernel file I/O.
1503 @param rw UIO_READ for a read, UIO_WRITE for a write.
1504 @param vp The vnode on which to perform I/O.
1505 @param base Start of buffer into which to read or from which to write data.
1506 @param len Length of buffer.
1507 @param offset Offset within the file at which to start I/O.
1508 @param segflg What kind of address "base" is. See uio_seg definition in sys/uio.h. UIO_SYSSPACE for kernelspace, UIO_USERSPACE for userspace.
1509 UIO_USERSPACE32 and UIO_USERSPACE64 are in general preferred, but vn_rdwr will make sure that has the correct address sizes.
1510 @param ioflg Defined in vnode.h, e.g. IO_NOAUTH, IO_NOCACHE.
1511 @param cred Credential to pass down to filesystem for authentication.
1512 @param aresid Destination for amount of requested I/O which was not completed, as with uio_resid().
1513 @param p Process requesting I/O.
1514 @return 0 for success; errors from filesystem, and EIO if did not perform all requested I/O and the "aresid" parameter is NULL.
1515 */
1516int vn_rdwr(enum uio_rw, vnode_t, caddr_t, int, off_t, enum uio_seg, int, kauth_cred_t, int *, proc_t);
1517
1518/*!
1519 @function vnode_getname
1520 @abstract Get the name of a vnode from the VFS namecache.
1521 @discussion Not all vnodes have names, and vnode names can change (notably, hardlinks). Use this routine at your own risk.
1522 The string is returned with a refcount incremented in the cache; callers must call vnode_putname() to release that reference.
1523 @param vp The vnode whose name to grab.
1524 @return The name, or NULL if unavailable.
1525 */
1526const char *vnode_getname(vnode_t vp);
1527
1528/*!
1529 @function vnode_putname
1530 @abstract Release a reference on a name from the VFS cache.
1531 @discussion Should be called on a string obtained with vnode_getname().
1532 @param name String to release.
1533 @return void.
1534 */
1535void vnode_putname(const char *name);
1536
1537/*!
1538 @function vnode_getparent
1539 @abstract Get an iocount on the parent of a vnode.
1540 @discussion A vnode's parent may change over time or be reclaimed, so vnode_getparent() may return different
1541 results at different times (e.g. a multiple-hardlink file). The parent is returned with an iocount which must
1542 subsequently be dropped with vnode_put().
1543 @param vp The vnode whose parent to grab.
1544 @return Parent if available, else NULL.
1545 */
1546vnode_t vnode_getparent(vnode_t vp);
1547
1548#ifdef BSD_KERNEL_PRIVATE
1549/* Not in export list so can be private */
1550struct stat;
1551int vn_stat(struct vnode *vp, void * sb, kauth_filesec_t *xsec, int isstat64, vfs_context_t ctx);
1552int vn_stat_noauth(struct vnode *vp, void * sb, kauth_filesec_t *xsec, int isstat64, vfs_context_t ctx);
1553int vaccess(mode_t file_mode, uid_t uid, gid_t gid,
1554 mode_t acc_mode, kauth_cred_t cred);
1555int check_mountedon(dev_t dev, enum vtype type, int *errorp);
1556int vn_getcdhash(struct vnode *vp, off_t offset, unsigned char *cdhash);
1557void vnode_reclaim(vnode_t);
1558vfs_context_t vfs_context_kernel(void); /* get from 1st kernel thread */
1559int vfs_context_issuser(vfs_context_t);
1560vnode_t vfs_context_cwd(vfs_context_t);
1561vnode_t current_rootdir(void);
1562vnode_t current_workingdir(void);
1563void *vnode_vfsfsprivate(vnode_t);
1564struct vfsstatfs *vnode_vfsstatfs(vnode_t);
1565uint32_t vnode_vfsvisflags(vnode_t);
1566uint32_t vnode_vfscmdflags(vnode_t);
1567int vnode_is_openevt(vnode_t);
1568void vnode_set_openevt(vnode_t);
1569void vnode_clear_openevt(vnode_t);
1570int vnode_isstandard(vnode_t);
1571int vnode_makeimode(int, int);
1572enum vtype vnode_iftovt(int);
1573int vnode_vttoif(enum vtype);
1574int vnode_isshadow(vnode_t);
1575int vnode_istty(vnode_t vp);
1576/*
1577 * Indicate that a file has multiple hard links. VFS will always call
1578 * VNOP_LOOKUP on this vnode. Volfs will always ask for it's parent
1579 * object ID (instead of using the v_parent pointer).
1580 */
1581vnode_t vnode_parent(vnode_t);
1582void vnode_setparent(vnode_t, vnode_t);
1583const char * vnode_name(vnode_t);
1584void vnode_setname(vnode_t, char *);
1585int vnode_isnoflush(vnode_t);
1586void vnode_setnoflush(vnode_t);
1587void vnode_clearnoflush(vnode_t);
1588/* XXX temporary until we can arrive at a KPI for NFS, Seatbelt */
1589thread_t vfs_context_thread(vfs_context_t);
1590
1591#endif /* BSD_KERNEL_PRIVATE */
1592
1593__END_DECLS
1594
1595#endif /* KERNEL */
1596
1597#endif /* !_VNODE_H_ */