]> git.saurik.com Git - apple/xnu.git/blob - bsd/sys/vnode_internal.h
xnu-1699.32.7.tar.gz
[apple/xnu.git] / bsd / sys / vnode_internal.h
1 /*
2 * Copyright (c) 2000-2010 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 * NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce
65 * support for mandatory and extensible security protections. This notice
66 * is included in support of clause 2.2 (b) of the Apple Public License,
67 * Version 2.0.
68 */
69
70 #ifndef _SYS_VNODE_INTERNAL_H_
71 #define _SYS_VNODE_INTERNAL_H_
72
73 #include <sys/appleapiopts.h>
74 #include <sys/cdefs.h>
75 #include <sys/queue.h>
76 #include <sys/lock.h>
77
78 #include <sys/time.h>
79 #include <sys/uio.h>
80
81 #include <sys/vm.h>
82 #include <sys/systm.h>
83 #include <kern/locks.h>
84 #include <vm/vm_kern.h>
85 #include <sys/vnode.h>
86 #include <sys/namei.h>
87 #include <sys/vfs_context.h>
88 #include <sys/sysctl.h>
89
90
91 struct lockf;
92 struct label;
93
94 LIST_HEAD(buflists, buf);
95
96
97 struct unsafe_fsnode {
98 lck_mtx_t fsnodelock;
99 int32_t fsnode_count;
100 void * fsnodeowner;
101 };
102
103 #if CONFIG_TRIGGERS
104 /*
105 * VFS Internal (private) trigger vnode resolver info.
106 */
107 struct vnode_resolve {
108 lck_mtx_t vr_lock; /* protects vnode_resolve_t fields */
109 trigger_vnode_resolve_callback_t vr_resolve_func;
110 trigger_vnode_unresolve_callback_t vr_unresolve_func;
111 trigger_vnode_rearm_callback_t vr_rearm_func;
112 trigger_vnode_reclaim_callback_t vr_reclaim_func;
113 void * vr_data; /* private data for resolver */
114 uint32_t vr_flags;
115 uint32_t vr_lastseq;
116 };
117 typedef struct vnode_resolve *vnode_resolve_t;
118
119 /* private vr_flags */
120 #define VNT_RESOLVED (1UL << 31)
121 #define VNT_VFS_UNMOUNTED (1UL << 30)
122 #define VNT_EXTERNAL (1UL << 29)
123
124 #endif /* CONFIG_TRIGGERS */
125
126 /*
127 * Reading or writing any of these items requires holding the appropriate lock.
128 * v_freelist is locked by the global vnode_list_lock
129 * v_mntvnodes is locked by the mount_lock
130 * v_nclinks and v_ncchildren are protected by the global name_cache_lock
131 * v_cleanblkhd and v_dirtyblkhd and v_iterblkflags are locked via the global buf_mtxp
132 * the rest of the structure is protected by the vnode_lock
133 */
134 struct vnode {
135 lck_mtx_t v_lock; /* vnode mutex */
136 TAILQ_ENTRY(vnode) v_freelist; /* vnode freelist */
137 TAILQ_ENTRY(vnode) v_mntvnodes; /* vnodes for mount point */
138 LIST_HEAD(, namecache) v_nclinks; /* name cache entries that name this vnode */
139 LIST_HEAD(, namecache) v_ncchildren; /* name cache entries that regard us as there parent */
140 vnode_t v_defer_reclaimlist; /* in case we have to defer the reclaim to avoid recursion */
141 uint32_t v_listflag; /* flags protected by the vnode_list_lock (see below) */
142 uint32_t v_flag; /* vnode flags (see below) */
143 uint16_t v_lflag; /* vnode local and named ref flags */
144 uint8_t v_iterblkflags; /* buf iterator flags */
145 uint8_t v_references; /* number of times io_count has been granted */
146 int32_t v_kusecount; /* count of in-kernel refs */
147 int32_t v_usecount; /* reference count of users */
148 int32_t v_iocount; /* iocounters */
149 void * v_owner; /* act that owns the vnode */
150 uint16_t v_type; /* vnode type */
151 uint16_t v_tag; /* type of underlying data */
152 uint32_t v_id; /* identity of vnode contents */
153 union {
154 struct mount *vu_mountedhere;/* ptr to mounted vfs (VDIR) */
155 struct socket *vu_socket; /* unix ipc (VSOCK) */
156 struct specinfo *vu_specinfo; /* device (VCHR, VBLK) */
157 struct fifoinfo *vu_fifoinfo; /* fifo (VFIFO) */
158 struct ubc_info *vu_ubcinfo; /* valid for (VREG) */
159 } v_un;
160 struct buflists v_cleanblkhd; /* clean blocklist head */
161 struct buflists v_dirtyblkhd; /* dirty blocklist head */
162 struct klist v_knotes; /* knotes attached to this vnode */
163 /*
164 * the following 4 fields are protected
165 * by the name_cache_lock held in
166 * excluive mode
167 */
168 kauth_cred_t v_cred; /* last authorized credential */
169 kauth_action_t v_authorized_actions; /* current authorized actions for v_cred */
170 int v_cred_timestamp; /* determine if entry is stale for MNTK_AUTH_OPAQUE */
171 int v_nc_generation; /* changes when nodes are removed from the name cache */
172 /*
173 * back to the vnode lock for protection
174 */
175 int32_t v_numoutput; /* num of writes in progress */
176 int32_t v_writecount; /* reference count of writers */
177 const char *v_name; /* name component of the vnode */
178 vnode_t v_parent; /* pointer to parent vnode */
179 struct lockf *v_lockf; /* advisory lock list head */
180 #ifndef __LP64__
181 struct unsafe_fsnode *v_unsafefs; /* pointer to struct used to lock */
182 #else
183 int32_t v_reserved1;
184 int32_t v_reserved2;
185 #endif /* __LP64__ */
186 int (**v_op)(void *); /* vnode operations vector */
187 mount_t v_mount; /* ptr to vfs we are in */
188 void * v_data; /* private data for fs */
189 #if CONFIG_MACF
190 struct label *v_label; /* MAC security label */
191 #endif
192 #if CONFIG_TRIGGERS
193 vnode_resolve_t v_resolve; /* trigger vnode resolve info (VDIR only) */
194 #endif /* CONFIG_TRIGGERS */
195 };
196
197 #define v_mountedhere v_un.vu_mountedhere
198 #define v_socket v_un.vu_socket
199 #define v_specinfo v_un.vu_specinfo
200 #define v_fifoinfo v_un.vu_fifoinfo
201 #define v_ubcinfo v_un.vu_ubcinfo
202
203
204 /*
205 * v_iterblkflags
206 */
207 #define VBI_ITER 0x1
208 #define VBI_ITERWANT 0x2
209 #define VBI_CLEAN 0x4
210 #define VBI_DIRTY 0x8
211 #define VBI_NEWBUF 0x10
212
213 /*
214 * v_listflag
215 */
216 #define VLIST_RAGE 0x01 /* vnode is currently in the rapid age list */
217 #define VLIST_DEAD 0x02 /* vnode is currently in the dead list */
218
219 /*
220 * v_lflags
221 */
222 #define VL_SUSPENDED 0x0001 /* vnode is suspended */
223 #define VL_DRAIN 0x0002 /* vnode is being drained */
224 #define VL_TERMINATE 0x0004 /* vnode is in the process of being recycled */
225 #define VL_TERMWANT 0x0008 /* there's a waiter for recycle finish (vnode_getiocount)*/
226 #define VL_DEAD 0x0010 /* vnode is dead, cleaned of filesystem-specific info */
227 #define VL_MARKTERM 0x0020 /* vnode should be recycled when no longer referenced */
228 #define VL_NEEDINACTIVE 0x0080 /* delay VNOP_INACTIVE until iocount goes to 0 */
229
230 #define VL_LABEL 0x0100 /* vnode is marked for labeling */
231 #define VL_LABELWAIT 0x0200 /* vnode is marked for labeling */
232 #define VL_LABELED 0x0400 /* vnode is labeled */
233 #define VL_LWARNED 0x0800
234 #define VL_HASSTREAMS 0x1000 /* vnode has had at least one associated named stream vnode (may not have one any longer) */
235
236 #define VNAMED_UBC 0x2000 /* ubc named reference */
237 #define VNAMED_MOUNT 0x4000 /* mount point named reference */
238 #define VNAMED_FSHASH 0x8000 /* FS hash named reference */
239
240 /*
241 * v_flags
242 */
243 #define VROOT 0x000001 /* root of its file system */
244 #define VTEXT 0x000002 /* vnode is a pure text prototype */
245 #define VSYSTEM 0x000004 /* vnode being used by kernel */
246 #define VISTTY 0x000008 /* vnode represents a tty */
247 #define VRAGE 0x000010 /* vnode is in rapid age state */
248 #define VBDEVVP 0x000020 /* vnode created by bdevvp */
249 #define VDEVFLUSH 0x000040 /* device vnode after vflush */
250 #define VMOUNT 0x000080 /* mount operation in progress */
251 #define VBWAIT 0x000100 /* waiting for output to complete */
252 #define VSHARED_DYLD 0x000200 /* vnode is a dyld shared cache file */
253 #define VNOCACHE_DATA 0x000400 /* don't keep data cached once it's been consumed */
254 #define VSTANDARD 0x000800 /* vnode obtained from common pool */
255 #define VAGE 0x001000 /* Insert vnode at head of free list */
256 #define VRAOFF 0x002000 /* read ahead disabled */
257 #define VNCACHEABLE 0x004000 /* vnode is allowed to be put back in name cache */
258 #if NAMEDSTREAMS
259 #define VISSHADOW 0x008000 /* vnode is a shadow file */
260 #endif
261 #define VSWAP 0x010000 /* vnode is being used as swapfile */
262 #define VTHROTTLED 0x020000 /* writes or pageouts have been throttled */
263 /* wakeup tasks waiting when count falls below threshold */
264 #define VNOFLUSH 0x040000 /* don't vflush() if SKIPSYSTEM */
265 #define VLOCKLOCAL 0x080000 /* this vnode does adv locking in vfs */
266 #define VISHARDLINK 0x100000 /* hard link needs special processing on lookup and in volfs */
267 #define VISUNION 0x200000 /* union special processing */
268 #if NAMEDSTREAMS
269 #define VISNAMEDSTREAM 0x400000 /* vnode is a named stream (eg HFS resource fork) */
270 #endif
271 #define VOPENEVT 0x800000 /* if process is P_CHECKOPENEVT, then or in the O_EVTONLY flag on open */
272 #define VNEEDSSNAPSHOT 0x1000000
273
274 /*
275 * Global vnode data.
276 */
277 extern struct vnode *rootvnode; /* root (i.e. "/") vnode */
278
279 #ifdef CONFIG_IMGSRC_ACCESS
280 #define MAX_IMAGEBOOT_NESTING 2
281 extern struct vnode *imgsrc_rootvnodes[];
282 #endif /* CONFIG_IMGSRC_ACCESS */
283
284
285 /*
286 * Mods for exensibility.
287 */
288
289 /*
290 * Flags for vdesc_flags:
291 */
292 #define VDESC_MAX_VPS 16
293 /* Low order 16 flag bits are reserved for willrele flags for vp arguments. */
294 #define VDESC_VP0_WILLRELE 0x0001
295 #define VDESC_VP1_WILLRELE 0x0002
296 #define VDESC_VP2_WILLRELE 0x0004
297 #define VDESC_VP3_WILLRELE 0x0008
298 #define VDESC_NOMAP_VPP 0x0100
299 #define VDESC_VPP_WILLRELE 0x0200
300
301 /*
302 * VDESC_NO_OFFSET is used to identify the end of the offset list
303 * and in places where no such field exists.
304 */
305 #define VDESC_NO_OFFSET -1
306
307 /*
308 * This structure describes the vnode operation taking place.
309 */
310 struct vnodeop_desc {
311 int vdesc_offset; /* offset in vector--first for speed */
312 const char *vdesc_name; /* a readable name for debugging */
313 int vdesc_flags; /* VDESC_* flags */
314
315 /*
316 * These ops are used by bypass routines to map and locate arguments.
317 * Creds and procs are not needed in bypass routines, but sometimes
318 * they are useful to (for example) transport layers.
319 * Nameidata is useful because it has a cred in it.
320 */
321 int *vdesc_vp_offsets; /* list ended by VDESC_NO_OFFSET */
322 int vdesc_vpp_offset; /* return vpp location */
323 int vdesc_cred_offset; /* cred location, if any */
324 int vdesc_proc_offset; /* proc location, if any */
325 int vdesc_componentname_offset; /* if any */
326 int vdesc_context_offset; /* context location, if any */
327 /*
328 * Finally, we've got a list of private data (about each operation)
329 * for each transport layer. (Support to manage this list is not
330 * yet part of BSD.)
331 */
332 caddr_t *vdesc_transports;
333 };
334
335 /*
336 * A list of all the operation descs.
337 */
338 extern struct vnodeop_desc *vnodeop_descs[];
339
340
341 /*
342 * This macro is very helpful in defining those offsets in the vdesc struct.
343 *
344 * This is stolen from X11R4. I ingored all the fancy stuff for
345 * Crays, so if you decide to port this to such a serious machine,
346 * you might want to consult Intrisics.h's XtOffset{,Of,To}.
347 */
348 #define VOPARG_OFFSET(p_type,field) \
349 ((int) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
350 #define VOPARG_OFFSETOF(s_type,field) \
351 VOPARG_OFFSET(s_type*,field)
352 #define VOPARG_OFFSETTO(S_TYPE,S_OFFSET,STRUCT_P) \
353 ((S_TYPE)(((char*)(STRUCT_P))+(S_OFFSET)))
354
355
356
357 /*
358 * VOCALL calls an op given an ops vector. We break it out because BSD's
359 * vclean changes the ops vector and then wants to call ops with the old
360 * vector.
361 */
362 #define VOCALL(OPSV,OFF,AP) (( *((OPSV)[(OFF)])) (AP))
363
364 /*
365 * This call works for vnodes in the kernel.
366 */
367 #define VCALL(VP,OFF,AP) VOCALL((VP)->v_op,(OFF),(AP))
368 #define VDESC(OP) (& __CONCAT(OP,_desc))
369 #define VOFFSET(OP) (VDESC(OP)->vdesc_offset)
370
371 struct ostat;
372
373 #define BUILDPATH_NO_FS_ENTER 0x1 /* Use cache values, do not enter file system */
374 #define BUILDPATH_CHECKACCESS 0x2 /* Check if parents have search rights */
375 int build_path(vnode_t first_vp, char *buff, int buflen, int *outlen, int flags, vfs_context_t ctx);
376
377 int bdevvp(dev_t dev, struct vnode **vpp);
378 void cvtstat(struct stat *st, struct ostat *ost);
379 void vprint(const char *label, struct vnode *vp);
380
381
382 __private_extern__ int is_package_name(const char *name, int len);
383 __private_extern__ int set_package_extensions_table(user_addr_t data, int nentries, int maxwidth);
384 int vn_rdwr_64(enum uio_rw rw, struct vnode *vp, uint64_t base,
385 int64_t len, off_t offset, enum uio_seg segflg,
386 int ioflg, kauth_cred_t cred, int64_t *aresid,
387 struct proc *p);
388 #if CONFIG_MACF
389 int vn_setlabel (struct vnode *vp, struct label *intlabel,
390 vfs_context_t context);
391 #endif
392 void fifo_printinfo(struct vnode *vp);
393 int vn_open(struct nameidata *ndp, int fmode, int cmode);
394 int vn_open_modflags(struct nameidata *ndp, int *fmode, int cmode);
395 int vn_open_auth(struct nameidata *ndp, int *fmode, struct vnode_attr *);
396 int vn_close(vnode_t, int flags, vfs_context_t ctx);
397 errno_t vn_remove(vnode_t dvp, vnode_t *vpp, struct nameidata *ndp, int32_t flags, struct vnode_attr *vap, vfs_context_t ctx);
398 errno_t vn_rename(struct vnode *fdvp, struct vnode **fvpp, struct componentname *fcnp, struct vnode_attr *fvap,
399 struct vnode *tdvp, struct vnode **tvpp, struct componentname *tcnp, struct vnode_attr *tvap,
400 uint32_t flags, vfs_context_t ctx);
401
402 void lock_vnode_and_post(vnode_t, int);
403
404 #define post_event_if_success(_vp, _error, _event) \
405 do { \
406 if (0 == (_error)) { \
407 lock_vnode_and_post((_vp), (_event)); \
408 } \
409 } while (0)
410
411 /* Authorization subroutines */
412 int vn_authorize_open_existing(vnode_t vp, struct componentname *cnp, int fmode, vfs_context_t ctx, void *reserved);
413 int vn_authorize_create(vnode_t, struct componentname *, struct vnode_attr *, vfs_context_t, void*);
414 int vn_attribute_prepare(vnode_t dvp, struct vnode_attr *vap, uint32_t *defaulted_fieldsp, vfs_context_t ctx);
415 void vn_attribute_cleanup(struct vnode_attr *vap, uint32_t defaulted_fields);
416 int vn_authorize_unlink(vnode_t dvp, vnode_t vp, struct componentname *cnp, vfs_context_t ctx, void *reserved);
417 int vn_authorize_rename(struct vnode *fdvp, struct vnode *fvp, struct componentname *fcnp,
418 struct vnode *tdvp, struct vnode *tvp, struct componentname *tcnp,
419 vfs_context_t ctx, void *reserved);
420 int vn_authorize_rmdir(vnode_t dvp, vnode_t vp, struct componentname *cnp, vfs_context_t ctx, void *reserved);
421
422 typedef int (*vn_create_authorizer_t)(vnode_t, struct componentname *, struct vnode_attr *, vfs_context_t, void*);
423 int vn_authorize_mkdir(vnode_t, struct componentname *, struct vnode_attr *, vfs_context_t, void*);
424 int vn_authorize_null(vnode_t, struct componentname *, struct vnode_attr *, vfs_context_t, void*);
425 /* End of authorization subroutines */
426
427 #define VN_CREATE_NOAUTH (1<<0)
428 #define VN_CREATE_NOINHERIT (1<<1)
429 #define VN_CREATE_UNION (1<<2)
430 #define VN_CREATE_NOLABEL (1<<3)
431 #define VN_CREATE_DOOPEN (1<<4) /* Open file if a batched operation is available */
432 errno_t vn_create(vnode_t, vnode_t *, struct nameidata *, struct vnode_attr *, uint32_t, int, uint32_t*, vfs_context_t);
433 int vn_mkdir(vnode_t dvp, vnode_t *vpp, struct nameidata *ndp, struct vnode_attr *vap, vfs_context_t ctx);
434 int vn_rmdir(vnode_t dvp, vnode_t *vpp, struct nameidata *ndp, struct vnode_attr *vap, vfs_context_t ctx);
435
436 int vn_getxattr(vnode_t, const char *, uio_t, size_t *, int, vfs_context_t);
437 int vn_setxattr(vnode_t, const char *, uio_t, int, vfs_context_t);
438 int vn_removexattr(vnode_t, const char *, int, vfs_context_t);
439 int vn_listxattr(vnode_t, uio_t, size_t *, int, vfs_context_t);
440
441 int default_getxattr(vnode_t, const char *, uio_t, size_t *, int, vfs_context_t);
442 int default_setxattr(vnode_t, const char *, uio_t, int, vfs_context_t);
443 int default_removexattr(vnode_t, const char *, int, vfs_context_t);
444
445 int check_appledouble_header(vnode_t, vfs_context_t);
446
447 #if NAMEDSTREAMS
448 errno_t vnode_getnamedstream(vnode_t, vnode_t *, const char *, enum nsoperation, int, vfs_context_t);
449 errno_t vnode_makenamedstream(vnode_t, vnode_t *, const char *, int, vfs_context_t);
450 errno_t vnode_removenamedstream(vnode_t, vnode_t, const char *, int, vfs_context_t);
451 errno_t vnode_flushnamedstream(vnode_t vp, vnode_t svp, vfs_context_t context);
452 errno_t vnode_relenamedstream(vnode_t vp, vnode_t svp, vfs_context_t context);
453 #endif
454
455
456 void nchinit(void) __attribute__((section("__TEXT, initcode")));
457 int resize_namecache(uint32_t newsize);
458 void name_cache_lock_shared(void);
459 void name_cache_lock(void);
460 void name_cache_unlock(void);
461 void cache_enter_with_gen(vnode_t dvp, vnode_t vp, struct componentname *cnp, int gen);
462 const char *cache_enter_create(vnode_t dvp, vnode_t vp, struct componentname *cnp);
463
464 int vn_pathconf(vnode_t, int, int32_t *, vfs_context_t);
465 extern int nc_disabled;
466
467 #define vnode_lock_convert(v) lck_mtx_convert_spin(&(v)->v_lock)
468
469 void vnode_lock_spin(vnode_t);
470
471
472 void vnode_list_lock(void);
473 void vnode_list_unlock(void);
474
475 #define VNODE_REF_FORCE 0x1
476 int vnode_ref_ext(vnode_t, int, int);
477
478 void vnode_rele_ext(vnode_t, int, int);
479 void vnode_rele_internal(vnode_t, int, int, int);
480 #ifdef BSD_KERNEL_PRIVATE
481 int vnode_getalways(vnode_t);
482 int vget_internal(vnode_t, int, int);
483 errno_t vnode_getiocount(vnode_t, unsigned int, int);
484 #endif /* BSD_KERNEL_PRIVATE */
485 int vnode_get_locked(vnode_t);
486 int vnode_put_locked(vnode_t);
487
488 int vnode_issock(vnode_t);
489 int vnode_isaliased(vnode_t);
490
491 void unlock_fsnode(vnode_t, int *);
492 int lock_fsnode(vnode_t, int *);
493
494 errno_t vnode_resume(vnode_t);
495 errno_t vnode_suspend(vnode_t);
496
497
498 errno_t vnode_size(vnode_t, off_t *, vfs_context_t);
499 errno_t vnode_setsize(vnode_t, off_t, int ioflag, vfs_context_t);
500 int vnode_setattr_fallback(vnode_t vp, struct vnode_attr *vap, vfs_context_t ctx);
501 int vnode_isspec(vnode_t vp);
502
503
504 #ifdef BSD_KERNEL_PRIVATE
505
506 typedef uint32_t compound_vnop_id_t;
507 #define COMPOUND_VNOP_OPEN 0x01
508 #define COMPOUND_VNOP_MKDIR 0x02
509 #define COMPOUND_VNOP_RENAME 0x04
510 #define COMPOUND_VNOP_REMOVE 0x08
511 #define COMPOUND_VNOP_RMDIR 0x10
512
513 int vnode_compound_rename_available(vnode_t vp);
514 int vnode_compound_rmdir_available(vnode_t vp);
515 int vnode_compound_mkdir_available(vnode_t vp);
516 int vnode_compound_remove_available(vnode_t vp);
517 int vnode_compound_open_available(vnode_t vp);
518 int vnode_compound_op_available(vnode_t, compound_vnop_id_t);
519 #endif /* BSD_KERNEL_PRIVATE */
520
521 void vn_setunionwait(vnode_t);
522 void vn_checkunionwait(vnode_t);
523 void vn_clearunionwait(vnode_t, int);
524
525 void SPECHASH_LOCK(void);
526 void SPECHASH_UNLOCK(void);
527
528 void vnode_authorize_init(void) __attribute__((section("__TEXT, initcode")));
529
530 void vfsinit(void) __attribute__((section("__TEXT, initcode")));
531 void vnode_lock(vnode_t);
532 void vnode_unlock(vnode_t);
533
534 /*
535 * XXX exported symbols; should be static
536 */
537 void vfs_op_init(void) __attribute__((section("__TEXT, initcode")));
538 void vfs_opv_init(void) __attribute__((section("__TEXT, initcode")));
539 int vfs_sysctl(int *name, uint32_t namelen, user_addr_t oldp, size_t *oldlenp,
540 user_addr_t newp, size_t newlen, struct proc *p);
541 int sysctl_vnode(struct sysctl_oid *oidp, void *arg1, int arg2, struct sysctl_req *req);
542
543 #ifdef BSD_KERNEL_PRIVATE
544 void vnode_setneedinactive(vnode_t);
545 int vnode_hasnamedstreams(vnode_t); /* Does this vnode have associated named streams? */
546
547 void nspace_proc_exit(struct proc *p);
548
549 #if CONFIG_TRIGGERS
550 /* VFS Internal Vnode Trigger Interfaces (Private) */
551 int vnode_trigger_resolve(vnode_t, struct nameidata *, vfs_context_t);
552 void vnode_trigger_rearm(vnode_t, vfs_context_t);
553 void vfs_nested_trigger_unmounts(mount_t, int, vfs_context_t);
554 #endif /* CONFIG_TRIGGERS */
555
556 #endif /* BSD_KERNEL_PRIVATE */
557
558 #endif /* !_SYS_VNODE_INTERNAL_H_ */