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