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