]>
git.saurik.com Git - apple/xnu.git/blob - bsd/sys/vnode.h
3f9438ee29f2c19e954686aa9d3e42952b9e3112
2 * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
30 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
32 * Copyright (c) 1989, 1993
33 * The Regents of the University of California. All rights reserved.
35 * Redistribution and use in source and binary forms, with or without
36 * modification, are permitted provided that the following conditions
38 * 1. Redistributions of source code must retain the above copyright
39 * notice, this list of conditions and the following disclaimer.
40 * 2. Redistributions in binary form must reproduce the above copyright
41 * notice, this list of conditions and the following disclaimer in the
42 * documentation and/or other materials provided with the distribution.
43 * 3. All advertising materials mentioning features or use of this software
44 * must display the following acknowledgement:
45 * This product includes software developed by the University of
46 * California, Berkeley and its contributors.
47 * 4. Neither the name of the University nor the names of its contributors
48 * may be used to endorse or promote products derived from this software
49 * without specific prior written permission.
51 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
52 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
53 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
54 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
55 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
56 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
57 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
58 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
59 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
60 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63 * @(#)vnode.h 8.17 (Berkeley) 5/20/95
69 #include <sys/appleapiopts.h>
70 #include <sys/cdefs.h>
72 #include <sys/kernel_types.h>
73 #include <sys/signal.h>
77 * The vnode is the focus of all file activity in UNIX. There is a
78 * unique vnode allocated for each active file, each current directory,
79 * each mounted-on file, text file, and the root.
83 * Vnode types. VNON means no type.
85 enum vtype
{ VNON
, VREG
, VDIR
, VBLK
, VCHR
, VLNK
, VSOCK
, VFIFO
, VBAD
, VSTR
,
90 * These are for the benefit of external programs only (e.g., pstat)
91 * and should NEVER be inspected by the kernel.
94 VT_NON
, VT_UFS
, VT_NFS
, VT_MFS
, VT_MSDOSFS
, VT_LFS
, VT_LOFS
, VT_FDESC
,
95 VT_PORTAL
, VT_NULL
, VT_UMAP
, VT_KERNFS
, VT_PROCFS
, VT_AFS
, VT_ISOFS
,
96 VT_UNION
, VT_HFS
, VT_VOLFS
, VT_DEVFS
, VT_WEBDAV
, VT_UDF
, VT_AFP
,
97 VT_CDDA
, VT_CIFS
,VT_OTHER
};
101 * flags for VNOP_BLOCKMAP
103 #define VNODE_READ 0x01
104 #define VNODE_WRITE 0x02
108 /* flags for VNOP_ALLOCATE */
109 #define PREALLOCATE 0x00000001 /* preallocate allocation blocks */
110 #define ALLOCATECONTIG 0x00000002 /* allocate contigious space */
111 #define ALLOCATEALL 0x00000004 /* allocate all requested space */
112 /* or no space at all */
113 #define FREEREMAINDER 0x00000008 /* deallocate allocated but */
114 /* unfilled blocks */
115 #define ALLOCATEFROMPEOF 0x00000010 /* allocate from the physical eof */
116 #define ALLOCATEFROMVOL 0x00000020 /* allocate from the volume offset */
119 * Token indicating no attribute value yet assigned. some user source uses this
128 #define IO_UNIT 0x0001 /* do I/O as atomic unit */
129 #define IO_APPEND 0x0002 /* append write to end */
130 #define IO_SYNC 0x0004 /* do I/O synchronously */
131 #define IO_NODELOCKED 0x0008 /* underlying node already locked */
132 #define IO_NDELAY 0x0010 /* FNDELAY flag set in file table */
133 #define IO_NOZEROFILL 0x0020 /* F_SETSIZE fcntl uses to prevent zero filling */
134 #define IO_TAILZEROFILL 0x0040 /* zero fills at the tail of write */
135 #define IO_HEADZEROFILL 0x0080 /* zero fills at the head of write */
136 #define IO_NOZEROVALID 0x0100 /* do not zero fill if valid page */
137 #define IO_NOZERODIRTY 0x0200 /* do not zero fill if page is dirty */
138 #define IO_CLOSE 0x0400 /* I/O issued from close path */
139 #define IO_NOCACHE 0x0800 /* same effect as VNOCACHE_DATA, but only for this 1 I/O */
140 #define IO_RAOFF 0x1000 /* same effect as VRAOFF, but only for this 1 I/O */
141 #define IO_DEFWRITE 0x2000 /* defer write if vfs.defwrite is set */
144 * Component Name: this structure describes the pathname
145 * information that is passed through the VNOP interface.
147 struct componentname
{
149 * Arguments to lookup.
151 u_long cn_nameiop
; /* lookup operation */
152 u_long cn_flags
; /* flags (see below) */
153 #ifdef BSD_KERNEL_PRIVATE
154 vfs_context_t cn_context
;
155 void * pad_obsolete2
;
157 /* XXX use of these defines are deprecated */
158 #define cn_proc (cn_context->vc_proc + 0) /* non-lvalue */
159 #define cn_cred (cn_context->vc_ucred + 0) /* non-lvalue */
162 void * obsolete1
; /* use vfs_context_t */
163 void * obsolete2
; /* use vfs_context_t */
166 * Shared between lookup and commit routines.
168 char *cn_pnbuf
; /* pathname buffer */
169 long cn_pnlen
; /* length of allocated buffer */
170 char *cn_nameptr
; /* pointer to looked up name */
171 long cn_namelen
; /* length of looked up component */
172 u_long cn_hash
; /* hash value of looked up name */
173 long cn_consume
; /* chars to consume in lookup() */
177 * component name operations (for VNOP_LOOKUP)
179 #define LOOKUP 0 /* perform name lookup only */
180 #define CREATE 1 /* setup for file creation */
181 #define DELETE 2 /* setup for file deletion */
182 #define RENAME 3 /* setup for file renaming */
183 #define OPMASK 3 /* mask for operation */
186 * component name operational modifier flags
188 #define FOLLOW 0x0040 /* follow symbolic links */
191 * component name parameter descriptors.
193 #define ISDOTDOT 0x002000 /* current component name is .. */
194 #define MAKEENTRY 0x004000 /* entry is to be added to name cache */
195 #define ISLASTCN 0x008000 /* this is last component of pathname */
196 #define ISWHITEOUT 0x020000 /* found whiteout */
197 #define DOWHITEOUT 0x040000 /* do whiteouts */
201 /* The following structure specifies a vnode for creation */
202 struct vnode_fsparam
{
203 struct mount
* vnfs_mp
; /* mount point to which this vnode_t is part of */
204 enum vtype vnfs_vtype
; /* vnode type */
205 const char * vnfs_str
; /* File system Debug aid */
206 struct vnode
* vnfs_dvp
; /* The parent vnode */
207 void * vnfs_fsnode
; /* inode */
208 int (**vnfs_vops
)(void *); /* vnode dispatch table */
209 int vnfs_markroot
; /* is this a root vnode in FS (not a system wide one) */
210 int vnfs_marksystem
; /* is a system vnode */
211 dev_t vnfs_rdev
; /* dev_t for block or char vnodes */
212 off_t vnfs_filesize
; /* that way no need for getattr in UBC */
213 struct componentname
* vnfs_cnp
; /* component name to add to namecache */
214 uint32_t vnfs_flags
; /* flags */
217 #define VNFS_NOCACHE 0x01 /* do not add to name cache at this time */
218 #define VNFS_CANTCACHE 0x02 /* never add this instance to the name cache */
220 #define VNCREATE_FLAVOR 0
221 #define VCREATESIZE sizeof(struct vnode_fsparam)
224 * Vnode attributes, new-style.
226 * The vnode_attr structure is used to transact attribute changes and queries
227 * with the filesystem.
229 * Note that this structure may be extended, but existing fields must not move.
232 #define VATTR_INIT(v) do {(v)->va_supported = (v)->va_active = 0ll; (v)->va_vaflags = 0;} while(0)
233 #define VATTR_SET_ACTIVE(v, a) ((v)->va_active |= VNODE_ATTR_ ## a)
234 #define VATTR_SET_SUPPORTED(v, a) ((v)->va_supported |= VNODE_ATTR_ ## a)
235 #define VATTR_IS_SUPPORTED(v, a) ((v)->va_supported & VNODE_ATTR_ ## a)
236 #define VATTR_CLEAR_ACTIVE(v, a) ((v)->va_active &= ~VNODE_ATTR_ ## a)
237 #define VATTR_CLEAR_SUPPORTED(v, a) ((v)->va_supported &= ~VNODE_ATTR_ ## a)
238 #define VATTR_IS_ACTIVE(v, a) ((v)->va_active & VNODE_ATTR_ ## a)
239 #define VATTR_ALL_SUPPORTED(v) (((v)->va_active & (v)->va_supported) == (v)->va_active)
240 #define VATTR_INACTIVE_SUPPORTED(v) do {(v)->va_active &= ~(v)->va_supported; (v)->va_supported = 0;} while(0)
241 #define VATTR_SET(v, a, x) do { (v)-> a = (x); VATTR_SET_ACTIVE(v, a);} while(0)
242 #define VATTR_WANTED(v, a) VATTR_SET_ACTIVE(v, a)
243 #define VATTR_RETURN(v, a, x) do { (v)-> a = (x); VATTR_SET_SUPPORTED(v, a);} while(0)
244 #define VATTR_NOT_RETURNED(v, a) (VATTR_IS_ACTIVE(v, a) && !VATTR_IS_SUPPORTED(v, a))
247 * Two macros to simplify conditional checking in kernel code.
249 #define VATTR_IS(v, a, x) (VATTR_IS_SUPPORTED(v, a) && (v)-> a == (x))
250 #define VATTR_IS_NOT(v, a, x) (VATTR_IS_SUPPORTED(v, a) && (v)-> a != (x))
252 #define VNODE_ATTR_va_rdev (1LL<< 0) /* 00000001 */
253 #define VNODE_ATTR_va_nlink (1LL<< 1) /* 00000002 */
254 #define VNODE_ATTR_va_total_size (1LL<< 2) /* 00000004 */
255 #define VNODE_ATTR_va_total_alloc (1LL<< 3) /* 00000008 */
256 #define VNODE_ATTR_va_data_size (1LL<< 4) /* 00000010 */
257 #define VNODE_ATTR_va_data_alloc (1LL<< 5) /* 00000020 */
258 #define VNODE_ATTR_va_iosize (1LL<< 6) /* 00000040 */
259 #define VNODE_ATTR_va_uid (1LL<< 7) /* 00000080 */
260 #define VNODE_ATTR_va_gid (1LL<< 8) /* 00000100 */
261 #define VNODE_ATTR_va_mode (1LL<< 9) /* 00000200 */
262 #define VNODE_ATTR_va_flags (1LL<<10) /* 00000400 */
263 #define VNODE_ATTR_va_acl (1LL<<11) /* 00000800 */
264 #define VNODE_ATTR_va_create_time (1LL<<12) /* 00001000 */
265 #define VNODE_ATTR_va_access_time (1LL<<13) /* 00002000 */
266 #define VNODE_ATTR_va_modify_time (1LL<<14) /* 00004000 */
267 #define VNODE_ATTR_va_change_time (1LL<<15) /* 00008000 */
268 #define VNODE_ATTR_va_backup_time (1LL<<16) /* 00010000 */
269 #define VNODE_ATTR_va_fileid (1LL<<17) /* 00020000 */
270 #define VNODE_ATTR_va_linkid (1LL<<18) /* 00040000 */
271 #define VNODE_ATTR_va_parentid (1LL<<19) /* 00080000 */
272 #define VNODE_ATTR_va_fsid (1LL<<20) /* 00100000 */
273 #define VNODE_ATTR_va_filerev (1LL<<21) /* 00200000 */
274 #define VNODE_ATTR_va_gen (1LL<<22) /* 00400000 */
275 #define VNODE_ATTR_va_encoding (1LL<<23) /* 00800000 */
276 #define VNODE_ATTR_va_type (1LL<<24) /* 01000000 */
277 #define VNODE_ATTR_va_name (1LL<<25) /* 02000000 */
278 #define VNODE_ATTR_va_uuuid (1LL<<26) /* 04000000 */
279 #define VNODE_ATTR_va_guuid (1LL<<27) /* 08000000 */
280 #define VNODE_ATTR_va_nchildren (1LL<<28) /* 10000000 */
282 #define VNODE_ATTR_BIT(n) (VNODE_ATTR_ ## n)
284 * Read-only attributes.
286 #define VNODE_ATTR_RDONLY (VNODE_ATTR_BIT(va_rdev) | \
287 VNODE_ATTR_BIT(va_nlink) | \
288 VNODE_ATTR_BIT(va_total_size) | \
289 VNODE_ATTR_BIT(va_total_alloc) | \
290 VNODE_ATTR_BIT(va_data_alloc) | \
291 VNODE_ATTR_BIT(va_iosize) | \
292 VNODE_ATTR_BIT(va_fileid) | \
293 VNODE_ATTR_BIT(va_linkid) | \
294 VNODE_ATTR_BIT(va_parentid) | \
295 VNODE_ATTR_BIT(va_fsid) | \
296 VNODE_ATTR_BIT(va_filerev) | \
297 VNODE_ATTR_BIT(va_gen) | \
298 VNODE_ATTR_BIT(va_name) | \
299 VNODE_ATTR_BIT(va_type) | \
300 VNODE_ATTR_BIT(va_nchildren))
302 * Attributes that can be applied to a new file object.
304 #define VNODE_ATTR_NEWOBJ (VNODE_ATTR_BIT(va_rdev) | \
305 VNODE_ATTR_BIT(va_uid) | \
306 VNODE_ATTR_BIT(va_gid) | \
307 VNODE_ATTR_BIT(va_mode) | \
308 VNODE_ATTR_BIT(va_flags) | \
309 VNODE_ATTR_BIT(va_acl) | \
310 VNODE_ATTR_BIT(va_create_time) | \
311 VNODE_ATTR_BIT(va_modify_time) | \
312 VNODE_ATTR_BIT(va_change_time) | \
313 VNODE_ATTR_BIT(va_encoding) | \
314 VNODE_ATTR_BIT(va_type) | \
315 VNODE_ATTR_BIT(va_uuuid) | \
316 VNODE_ATTR_BIT(va_guuid))
320 uint64_t va_supported
;
324 * Control flags. The low 16 bits are reserved for the
325 * ioflags being passed for truncation operations.
329 /* traditional stat(2) parameter fields */
330 dev_t va_rdev
; /* device id (device nodes only) */
331 uint64_t va_nlink
; /* number of references to this file */
332 uint64_t va_total_size
; /* size in bytes of all forks */
333 uint64_t va_total_alloc
; /* disk space used by all forks */
334 uint64_t va_data_size
; /* size in bytes of the main(data) fork */
335 uint64_t va_data_alloc
; /* disk space used by the main(data) fork */
336 uint32_t va_iosize
; /* optimal I/O blocksize */
338 /* file security information */
339 uid_t va_uid
; /* owner UID */
340 gid_t va_gid
; /* owner GID */
341 mode_t va_mode
; /* posix permissions */
342 uint32_t va_flags
; /* file flags */
343 struct kauth_acl
*va_acl
; /* access control list */
346 struct timespec va_create_time
; /* time of creation */
347 struct timespec va_access_time
; /* time of last access */
348 struct timespec va_modify_time
; /* time of last data modification */
349 struct timespec va_change_time
; /* time of last metadata change */
350 struct timespec va_backup_time
; /* time of last backup */
352 /* file parameters */
353 uint64_t va_fileid
; /* file unique ID in filesystem */
354 uint64_t va_linkid
; /* file link unique ID */
355 uint64_t va_parentid
; /* parent ID */
356 uint32_t va_fsid
; /* filesystem ID */
357 uint64_t va_filerev
; /* file revision counter */ /* XXX */
358 uint32_t va_gen
; /* file generation count */ /* XXX - relationship of
360 /* misc parameters */
361 uint32_t va_encoding
; /* filename encoding script */
363 enum vtype va_type
; /* file type (create only) */
364 char * va_name
; /* Name for ATTR_CMN_NAME; MAXPATHLEN bytes */
365 guid_t va_uuuid
; /* file owner UUID */
366 guid_t va_guuid
; /* file group UUID */
368 uint64_t va_nchildren
; /* Number of items in a directory */
369 /* Meaningful for directories only */
371 /* add new fields here only */
375 * Flags for va_vaflags.
377 #define VA_UTIMES_NULL 0x010000 /* utimes argument was NULL */
378 #define VA_EXCLUSIVE 0x020000 /* exclusive create request */
383 * Modes. Some values same as Ixxx entries from inode.h for now.
385 #define VSUID 0x800 /*04000*/ /* set user id on execution */
386 #define VSGID 0x400 /*02000*/ /* set group id on execution */
387 #define VSVTX 0x200 /*01000*/ /* save swapped text even after use */
388 #define VREAD 0x100 /*00400*/ /* read, write, execute permissions */
389 #define VWRITE 0x080 /*00200*/
390 #define VEXEC 0x040 /*00100*/
394 * Convert between vnode types and inode formats (since POSIX.1
395 * defines mode word of stat structure in terms of inode formats).
397 extern enum vtype iftovt_tab
[];
398 extern int vttoif_tab
[];
399 #define IFTOVT(mode) (iftovt_tab[((mode) & S_IFMT) >> 12])
400 #define VTTOIF(indx) (vttoif_tab[(int)(indx)])
401 #define MAKEIMODE(indx, mode) (int)(VTTOIF(indx) | (mode))
405 * Flags to various vnode functions.
407 #define SKIPSYSTEM 0x0001 /* vflush: skip vnodes marked VSYSTEM */
408 #define FORCECLOSE 0x0002 /* vflush: force file closeure */
409 #define WRITECLOSE 0x0004 /* vflush: only close writeable files */
410 #define SKIPSWAP 0x0008 /* vflush: skip vnodes marked VSWAP */
411 #define SKIPROOT 0x0010 /* vflush: skip root vnodes marked VROOT */
413 #define DOCLOSE 0x0008 /* vclean: close active files */
415 #define V_SAVE 0x0001 /* vinvalbuf: sync file first */
416 #define V_SAVEMETA 0x0002 /* vinvalbuf: leave indirect blocks */
418 #define REVOKEALL 0x0001 /* vnop_revoke: revoke all aliases */
420 /* VNOP_REMOVE: do not delete busy files (Carbon remove file semantics) */
421 #define VNODE_REMOVE_NODELETEBUSY 0x0001
423 /* VNOP_READDIR flags: */
424 #define VNODE_READDIR_EXTENDED 0x0001 /* use extended directory entries */
425 #define VNODE_READDIR_REQSEEKOFF 0x0002 /* requires seek offset (cookies) */
426 #define VNODE_READDIR_SEEKOFF32 0x0004 /* seek offset values should fit in 32 bits */
429 #define NULLVP ((struct vnode *)NULL)
432 * Macro/function to check for client cache inconsistency w.r.t. leasing.
434 #define LEASE_READ 0x1 /* Check lease for readers */
435 #define LEASE_WRITE 0x2 /* Check lease for modifiers */
438 #ifndef BSD_KERNEL_PRIVATE
442 extern int desiredvnodes
; /* number of vnodes desired */
446 * This structure is used to configure the new vnodeops vector.
448 struct vnodeopv_entry_desc
{
449 struct vnodeop_desc
*opve_op
; /* which operation this is */
450 int (*opve_impl
)(void *); /* code implementing this operation */
452 struct vnodeopv_desc
{
453 /* ptr to the ptr to the vector where op should go */
454 int (***opv_desc_vector_p
)(void *);
455 struct vnodeopv_entry_desc
*opv_desc_ops
; /* null terminated list */
459 * A default routine which just returns an error.
461 int vn_default_error(void);
464 * A generic structure.
465 * This can be used by bypass routines to identify generic arguments.
467 struct vnop_generic_args
{
468 struct vnodeop_desc
*a_desc
;
469 /* other random data follows, presumably */
472 #ifndef _KAUTH_ACTION_T
473 typedef int kauth_action_t
;
474 # define _KAUTH_ACTION_T
477 #include <sys/vnode_if.h>
481 errno_t
vnode_create(int, size_t, void *, vnode_t
*);
482 int vnode_addfsref(vnode_t
);
483 int vnode_removefsref(vnode_t
);
485 int vnode_hasdirtyblks(vnode_t
);
486 int vnode_hascleanblks(vnode_t
);
487 #define VNODE_ASYNC_THROTTLE 18
488 /* timeout is in 10 msecs and not hz tick based */
489 int vnode_waitforwrites(vnode_t
, int, int, int, char *);
490 void vnode_startwrite(vnode_t
);
491 void vnode_writedone(vnode_t
);
493 enum vtype
vnode_vtype(vnode_t
);
494 uint32_t vnode_vid(vnode_t
);
495 mount_t
vnode_mountedhere(vnode_t vp
);
496 mount_t
vnode_mount(vnode_t
);
497 dev_t
vnode_specrdev(vnode_t
);
498 void * vnode_fsnode(vnode_t
);
499 void vnode_clearfsnode(vnode_t
);
501 int vnode_isvroot(vnode_t
);
502 int vnode_issystem(vnode_t
);
503 int vnode_ismount(vnode_t
);
504 int vnode_isreg(vnode_t
);
505 int vnode_isdir(vnode_t
);
506 int vnode_islnk(vnode_t
);
507 int vnode_isfifo(vnode_t
);
508 int vnode_isblk(vnode_t
);
509 int vnode_ischr(vnode_t
);
511 int vnode_ismountedon(vnode_t
);
512 void vnode_setmountedon(vnode_t
);
513 void vnode_clearmountedon(vnode_t
);
515 int vnode_isnocache(vnode_t
);
516 void vnode_setnocache(vnode_t
);
517 void vnode_clearnocache(vnode_t
);
518 int vnode_isnoreadahead(vnode_t
);
519 void vnode_setnoreadahead(vnode_t
);
520 void vnode_clearnoreadahead(vnode_t
);
521 /* left only for compat reasons as User code depends on this from getattrlist, for ex */
522 void vnode_settag(vnode_t
, int);
523 int vnode_tag(vnode_t
);
524 int vnode_getattr(vnode_t vp
, struct vnode_attr
*vap
, vfs_context_t ctx
);
525 int vnode_setattr(vnode_t vp
, struct vnode_attr
*vap
, vfs_context_t ctx
);
527 #ifdef BSD_KERNEL_PRIVATE
530 * Indicate that a file has multiple hard links. VFS will always call
531 * VNOP_LOOKUP on this vnode. Volfs will always ask for it's parent
532 * object ID (instead of using the v_parent pointer).
534 void vnode_set_hard_link(vnode_t vp
);
536 vnode_t
vnode_parent(vnode_t
);
537 void vnode_setparent(vnode_t
, vnode_t
);
538 char * vnode_name(vnode_t
);
539 void vnode_setname(vnode_t
, char *);
540 int vnode_isnoflush(vnode_t
);
541 void vnode_setnoflush(vnode_t
);
542 void vnode_clearnoflush(vnode_t
);
545 uint32_t vnode_vfsmaxsymlen(vnode_t
);
546 int vnode_vfsisrdonly(vnode_t
);
547 int vnode_vfstypenum(vnode_t
);
548 void vnode_vfsname(vnode_t
, char *);
549 int vnode_vfs64bitready(vnode_t
);
551 proc_t
vfs_context_proc(vfs_context_t
);
552 ucred_t
vfs_context_ucred(vfs_context_t
);
553 int vfs_context_issuser(vfs_context_t
);
554 int vfs_context_pid(vfs_context_t
);
555 int vfs_context_issignal(vfs_context_t
, sigset_t
);
556 int vfs_context_suser(vfs_context_t
);
557 int vfs_context_is64bit(vfs_context_t
);
558 vfs_context_t
vfs_context_create(vfs_context_t
);
559 int vfs_context_rele(vfs_context_t
);
562 int vflush(struct mount
*mp
, struct vnode
*skipvp
, int flags
);
563 int vnode_get(vnode_t
);
564 int vnode_getwithvid(vnode_t
, int);
565 int vnode_put(vnode_t
);
566 int vnode_ref(vnode_t
);
567 void vnode_rele(vnode_t
);
568 int vnode_isinuse(vnode_t
, int);
569 void vnode_lock(vnode_t
);
570 void vnode_unlock(vnode_t
);
571 int vnode_recycle(vnode_t
);
572 void vnode_reclaim(vnode_t
);
574 #define VNODE_UPDATE_PARENT 0x01
575 #define VNODE_UPDATE_NAME 0x02
576 #define VNODE_UPDATE_CACHE 0x04
577 void vnode_update_identity(vnode_t vp
, vnode_t dvp
, char *name
, int name_len
, int name_hashval
, int flags
);
579 int vn_bwrite(struct vnop_bwrite_args
*ap
);
581 int vnode_authorize(vnode_t
/*vp*/, vnode_t
/*dvp*/, kauth_action_t
, vfs_context_t
);
582 int vnode_authattr(vnode_t
, struct vnode_attr
*, kauth_action_t
*, vfs_context_t
);
583 int vnode_authattr_new(vnode_t
/*dvp*/, struct vnode_attr
*, int /*noauth*/, vfs_context_t
);
584 errno_t
vnode_close(vnode_t
, int, vfs_context_t
);
586 int vn_getpath(struct vnode
*vp
, char *pathbuf
, int *len
);
589 * Flags for the vnode_lookup and vnode_open
591 #define VNODE_LOOKUP_NOFOLLOW 0x01
592 #define VNODE_LOOKUP_NOCROSSMOUNT 0x02
593 #define VNODE_LOOKUP_DOWHITEOUT 0x04
595 errno_t
vnode_lookup(const char *, int, vnode_t
*, vfs_context_t
);
596 errno_t
vnode_open(const char *, int, int, int, vnode_t
*, vfs_context_t
);
599 * exported vnode operations
602 int vnode_iterate(struct mount
*, int, int (*)(struct vnode
*, void *), void *);
604 * flags passed into vnode_iterate
606 #define VNODE_RELOAD 0x01
607 #define VNODE_WAIT 0x02
608 #define VNODE_WRITEABLE 0x04
609 #define VNODE_WITHID 0x08
610 #define VNODE_NOLOCK_INTERNAL 0x10
611 #define VNODE_NODEAD 0x20
612 #define VNODE_NOSUSPEND 0x40
613 #define VNODE_ITERATE_ALL 0x80
614 #define VNODE_ITERATE_ACTIVE 0x100
615 #define VNODE_ITERATE_INACTIVE 0x200
618 * return values from callback
620 #define VNODE_RETURNED 0 /* done with vnode, reference can be dropped */
621 #define VNODE_RETURNED_DONE 1 /* done with vnode, reference can be dropped, terminate iteration */
622 #define VNODE_CLAIMED 2 /* don't drop reference */
623 #define VNODE_CLAIMED_DONE 3 /* don't drop reference, terminate iteration */
627 int vn_stat(struct vnode
*vp
, struct stat
*sb
, kauth_filesec_t
*xsec
, vfs_context_t ctx
);
628 int vn_stat_noauth(struct vnode
*vp
, struct stat
*sb
, kauth_filesec_t
*xsec
, vfs_context_t ctx
);
629 int vn_revoke(vnode_t vp
, int flags
, vfs_context_t
);
631 int vaccess(mode_t file_mode
, uid_t uid
, gid_t gid
,
632 mode_t acc_mode
, struct ucred
*cred
);
635 /* namecache function prototypes */
636 int cache_lookup(vnode_t dvp
, vnode_t
*vpp
, struct componentname
*cnp
);
637 void cache_enter(vnode_t dvp
, vnode_t vp
, struct componentname
*cnp
);
638 void cache_purge(vnode_t vp
);
639 void cache_purge_negatives(vnode_t vp
);
642 * Global string-cache routines. You can pass zero for nc_hash
643 * if you don't know it (add_name() will then compute the hash).
644 * There are no flags for now but maybe someday.
646 char *vfs_addname(const char *name
, size_t len
, u_int nc_hash
, u_int flags
);
647 int vfs_removename(const char *name
);
653 #endif /* !_VNODE_H_ */