FreeBSD/Linux Kernel Cross Reference
sys/sys/vnode.h
1 /* $NetBSD: vnode.h,v 1.197.4.1 2009/07/21 00:31:58 snj Exp $ */
2
3 /*-
4 * Copyright (c) 2008 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
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. Neither the name of the University nor the names of its contributors
42 * may be used to endorse or promote products derived from this software
43 * without specific prior written permission.
44 *
45 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
46 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
47 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
48 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
49 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
51 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
53 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
54 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
55 * SUCH DAMAGE.
56 *
57 * @(#)vnode.h 8.17 (Berkeley) 5/20/95
58 */
59
60 #ifndef _SYS_VNODE_H_
61 #define _SYS_VNODE_H_
62
63 #include <sys/event.h>
64 #include <sys/queue.h>
65 #include <sys/condvar.h>
66 #include <sys/rwlock.h>
67 #include <sys/mutex.h>
68
69 /* XXX: clean up includes later */
70 #include <uvm/uvm_param.h> /* XXX */
71 #include <uvm/uvm_pglist.h> /* XXX */
72 #include <uvm/uvm_object.h> /* XXX */
73 #include <uvm/uvm_extern.h> /* XXX */
74
75 struct namecache;
76 struct uvm_ractx;
77
78 /*
79 * The vnode is the focus of all file activity in UNIX. There is a
80 * unique vnode allocated for each active file, each current directory,
81 * each mounted-on file, text file, and the root.
82 */
83
84 /*
85 * Vnode types. VNON means no type. __VTYPE_DEFINED allows other
86 * sources to override this definition. __VTYPE_DEFINED should be
87 * considered a temporary feature.
88 */
89 #ifndef __VTYPE_DEFINED
90 #define __VTYPE_DEFINED
91 enum vtype { VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK, VFIFO, VBAD };
92 #endif /* __VTYPE_DEFINED */
93
94 #define VNODE_TYPES \
95 "VNON", "VREG", "VDIR", "VBLK", "VCHR", "VLNK", "VSOCK", "VFIFO", "VBAD"
96
97 /*
98 * Vnode tag types.
99 * These are for the benefit of external programs only (e.g., pstat)
100 * and should NEVER be inspected by the kernel.
101 */
102 enum vtagtype {
103 VT_NON, VT_UFS, VT_NFS, VT_MFS, VT_MSDOSFS, VT_LFS, VT_LOFS,
104 VT_FDESC, VT_PORTAL, VT_NULL, VT_UMAP, VT_KERNFS, VT_PROCFS,
105 VT_AFS, VT_ISOFS, VT_UNION, VT_ADOSFS, VT_EXT2FS, VT_CODA,
106 VT_FILECORE, VT_NTFS, VT_VFS, VT_OVERLAY, VT_SMBFS, VT_PTYFS,
107 VT_TMPFS, VT_UDF, VT_SYSVBFS, VT_PUFFS, VT_HFS, VT_EFS, VT_ZFS
108 };
109
110 #define VNODE_TAGS \
111 "VT_NON", "VT_UFS", "VT_NFS", "VT_MFS", "VT_MSDOSFS", "VT_LFS", "VT_LOFS", \
112 "VT_FDESC", "VT_PORTAL", "VT_NULL", "VT_UMAP", "VT_KERNFS", "VT_PROCFS", \
113 "VT_AFS", "VT_ISOFS", "VT_UNION", "VT_ADOSFS", "VT_EXT2FS", "VT_CODA", \
114 "VT_FILECORE", "VT_NTFS", "VT_VFS", "VT_OVERLAY", "VT_SMBFS", "VT_PTYFS", \
115 "VT_TMPFS", "VT_UDF", "VT_SYSVBFS", "VT_PUFFS", "VT_HFS", "VT_EFS", "VT_ZFS"
116
117 struct vnode;
118 struct buf;
119
120 LIST_HEAD(buflists, buf);
121 TAILQ_HEAD(vnodelst, vnode);
122
123 struct vnlock {
124 krwlock_t vl_lock;
125 u_int vl_canrecurse;
126 u_int vl_recursecnt;
127 };
128
129 /*
130 * Reading or writing any of these items requires holding the appropriate
131 * lock. Field markings and the corresponding locks:
132 *
133 * : stable, reference to the vnode is is required
134 * f vnode_free_list_lock, or vrele_lock if VI_INACTPEND
135 * i v_interlock
136 * m mntvnode_lock
137 * n namecache_lock
138 * s syncer_data_lock
139 * u locked by underlying filesystem
140 * v v_vnlock
141 * x v_interlock + bufcache_lock to modify, either to inspect
142 *
143 * Each underlying filesystem allocates its own private area and hangs
144 * it from v_data.
145 */
146 struct vnode {
147 struct uvm_object v_uobj; /* i: the VM object */
148 kcondvar_t v_cv; /* i: synchronization */
149 voff_t v_size; /* i: size of file */
150 voff_t v_writesize; /* i: new size after write */
151 int v_iflag; /* i: VI_* flags */
152 int v_vflag; /* v: VV_* flags */
153 int v_uflag; /* u: VU_* flags */
154 int v_numoutput; /* i: # of pending writes */
155 int v_writecount; /* i: ref count of writers */
156 int v_holdcnt; /* i: page & buffer refs */
157 int v_synclist_slot; /* s: synclist slot index */
158 struct mount *v_mount; /* v: ptr to vfs we are in */
159 int (**v_op)(void *); /* :: vnode operations vector */
160 TAILQ_ENTRY(vnode) v_freelist; /* f: vnode freelist */
161 struct vnodelst *v_freelisthd; /* f: which freelist? */
162 TAILQ_ENTRY(vnode) v_mntvnodes; /* m: vnodes for mount point */
163 struct buflists v_cleanblkhd; /* x: clean blocklist head */
164 struct buflists v_dirtyblkhd; /* x: dirty blocklist head */
165 TAILQ_ENTRY(vnode) v_synclist; /* s: vnodes with dirty bufs */
166 LIST_HEAD(, namecache) v_dnclist; /* n: namecaches (children) */
167 LIST_HEAD(, namecache) v_nclist; /* n: namecaches (parent) */
168 union {
169 struct mount *vu_mountedhere;/* v: ptr to vfs (VDIR) */
170 struct socket *vu_socket; /* v: unix ipc (VSOCK) */
171 struct specnode *vu_specnode; /* v: device (VCHR, VBLK) */
172 struct fifoinfo *vu_fifoinfo; /* v: fifo (VFIFO) */
173 struct uvm_ractx *vu_ractx; /* i: read-ahead ctx (VREG) */
174 } v_un;
175 enum vtype v_type; /* :: vnode type */
176 enum vtagtype v_tag; /* :: type of underlying data */
177 struct vnlock v_lock; /* v: lock for this vnode */
178 struct vnlock *v_vnlock; /* v: pointer to lock */
179 void *v_data; /* :: private data for fs */
180 struct klist v_klist; /* i: notes attached to vnode */
181 };
182 #define v_usecount v_uobj.uo_refs
183 #define v_interlock v_uobj.vmobjlock
184 #define v_mountedhere v_un.vu_mountedhere
185 #define v_socket v_un.vu_socket
186 #define v_specnode v_un.vu_specnode
187 #define v_fifoinfo v_un.vu_fifoinfo
188 #define v_ractx v_un.vu_ractx
189
190 typedef struct vnodelst vnodelst_t;
191 typedef struct vnode vnode_t;
192
193 /*
194 * All vnode locking operations should use vp->v_vnlock. For leaf filesystems
195 * (such as ffs, lfs, msdosfs, etc), vp->v_vnlock = &vp->v_lock. For
196 * stacked filesystems, vp->v_vnlock may equal lowervp->v_vnlock.
197 *
198 * vp->v_vnlock may also be NULL, which indicates that a leaf node does not
199 * export a struct lock for vnode locking. Stacked filesystems (such as
200 * nullfs) must call the underlying fs for locking. See layerfs_ routines
201 * for examples.
202 *
203 * All filesystems must (pretend to) understand lockmanager flags.
204 */
205
206 /*
207 * Vnode flags. The first set are locked by vp->v_vnlock or are stable.
208 * VSYSTEM is only used to skip vflush()ing quota files. VISTTY is used
209 * when reading dead vnodes.
210 */
211 #define VV_ROOT 0x00000001 /* root of its file system */
212 #define VV_SYSTEM 0x00000002 /* vnode being used by kernel */
213 #define VV_ISTTY 0x00000004 /* vnode represents a tty */
214 #define VV_MAPPED 0x00000008 /* vnode might have user mappings */
215 #define VV_MPSAFE 0x00000010 /* file system code is MP safe */
216 #define VV_LOCKSWORK 0x00000020 /* FS supports locking discipline */
217
218 /* XXXAD ALIASED should be covered by spec lock? */
219
220 /*
221 * The second set are locked by vp->v_interlock.
222 */
223 #define VI_TEXT 0x00000100 /* vnode is a pure text prototype */
224 #define VI_EXECMAP 0x00000200 /* might have PROT_EXEC mappings */
225 #define VI_WRMAP 0x00000400 /* might have PROT_WRITE u. mappings */
226 #define VI_WRMAPDIRTY 0x00000800 /* might have dirty pages */
227 #define VI_XLOCK 0x00001000 /* vnode is locked to change type */
228 #define VI_ONWORKLST 0x00004000 /* On syncer work-list */
229 #define VI_MARKER 0x00008000 /* Dummy marker vnode */
230 #define VI_LAYER 0x00020000 /* vnode is on a layer filesystem */
231 #define VI_CLEAN 0x00080000 /* has been reclaimed */
232 #define VI_INACTPEND 0x00100000 /* inactivation is pending */
233 #define VI_INACTREDO 0x00200000 /* need to redo VOP_INACTIVE() */
234 #define VI_FREEING 0x00400000 /* vnode is being freed */
235 #define VI_INACTNOW 0x00800000 /* VOP_INACTIVE() in progress */
236
237 /*
238 * The third set are locked by the underlying file system.
239 */
240 #define VU_DIROP 0x01000000 /* LFS: involved in a directory op */
241 #define VU_SOFTDEP 0x02000000 /* FFS: involved in softdep processing */
242
243 #define VNODE_FLAGBITS \
244 "\2\1ROOT\2SYSTEM\3ISTTY\4MAPPED\5MPSAFE\6LOCKSWORK\11TEXT\12EXECMAP" \
245 "\13WRMAP\14WRMAPDIRTY\15XLOCK\17ONWORKLST\20MARKER" \
246 "\22LAYER\24CLEAN\25INACTPEND\26INACTREDO\27FREEING" \
247 "\28INACTNOW\31DIROP\32SOFTDEP"
248
249 #define VSIZENOTSET ((voff_t)-1)
250
251 /*
252 * v_usecount; see the comment in vfs_subr.c
253 */
254 #define VC_XLOCK 0x80000000
255 #define VC_MASK 0x7fffffff
256
257 /*
258 * Vnode attributes. A field value of VNOVAL represents a field whose value
259 * is unavailable (getattr) or which is not to be changed (setattr).
260 */
261 struct vattr {
262 enum vtype va_type; /* vnode type (for create) */
263 mode_t va_mode; /* files access mode and type */
264 nlink_t va_nlink; /* number of references to file */
265 uid_t va_uid; /* owner user id */
266 gid_t va_gid; /* owner group id */
267 long va_fsid; /* file system id (dev for now) */
268 ino_t va_fileid; /* file id */
269 u_quad_t va_size; /* file size in bytes */
270 long va_blocksize; /* blocksize preferred for i/o */
271 struct timespec va_atime; /* time of last access */
272 struct timespec va_mtime; /* time of last modification */
273 struct timespec va_ctime; /* time file changed */
274 struct timespec va_birthtime; /* time file created */
275 u_long va_gen; /* generation number of file */
276 u_long va_flags; /* flags defined for file */
277 dev_t va_rdev; /* device the special file represents */
278 u_quad_t va_bytes; /* bytes of disk space held by file */
279 u_quad_t va_filerev; /* file modification number */
280 u_int va_vaflags; /* operations flags, see below */
281 long va_spare; /* remain quad aligned */
282 };
283
284 /*
285 * Flags for va_vaflags.
286 */
287 #define VA_UTIMES_NULL 0x01 /* utimes argument was NULL */
288 #define VA_EXCLUSIVE 0x02 /* exclusive create request */
289
290 #ifdef _KERNEL
291
292 /*
293 * Flags for ioflag.
294 */
295 #define IO_UNIT 0x00010 /* do I/O as atomic unit */
296 #define IO_APPEND 0x00020 /* append write to end */
297 #define IO_SYNC (0x40|IO_DSYNC) /* sync I/O file integrity completion */
298 #define IO_NODELOCKED 0x00080 /* underlying node already locked */
299 #define IO_NDELAY 0x00100 /* FNDELAY flag set in file table */
300 #define IO_DSYNC 0x00200 /* sync I/O data integrity completion */
301 #define IO_ALTSEMANTICS 0x00400 /* use alternate i/o semantics */
302 #define IO_NORMAL 0x00800 /* operate on regular data */
303 #define IO_EXT 0x01000 /* operate on extended attributes */
304 #define IO_DIRECT 0x02000 /* direct I/O hint */
305 #define IO_JOURNALLOCKED 0x04000 /* journal is already locked */
306 #define IO_ADV_MASK 0x00003 /* access pattern hint */
307
308 #define IO_ADV_SHIFT 0
309 #define IO_ADV_ENCODE(adv) (((adv) << IO_ADV_SHIFT) & IO_ADV_MASK)
310 #define IO_ADV_DECODE(ioflag) (((ioflag) & IO_ADV_MASK) >> IO_ADV_SHIFT)
311
312 /*
313 * Modes.
314 */
315 #define VREAD 00004 /* read, write, execute permissions */
316 #define VWRITE 00002
317 #define VEXEC 00001
318
319 /*
320 * Token indicating no attribute value yet assigned.
321 */
322 #define VNOVAL (-1)
323
324 /*
325 * Convert between vnode types and inode formats (since POSIX.1
326 * defines mode word of stat structure in terms of inode formats).
327 */
328 extern const enum vtype iftovt_tab[];
329 extern const int vttoif_tab[];
330 #define IFTOVT(mode) (iftovt_tab[((mode) & S_IFMT) >> 12])
331 #define VTTOIF(indx) (vttoif_tab[(int)(indx)])
332 #define MAKEIMODE(indx, mode) (int)(VTTOIF(indx) | (mode))
333
334 /*
335 * Flags to various vnode functions.
336 */
337 #define SKIPSYSTEM 0x0001 /* vflush: skip vnodes marked VSYSTEM */
338 #define FORCECLOSE 0x0002 /* vflush: force file closeure */
339 #define WRITECLOSE 0x0004 /* vflush: only close writable files */
340 #define DOCLOSE 0x0008 /* vclean: close active files */
341 #define V_SAVE 0x0001 /* vinvalbuf: sync file first */
342
343 /*
344 * Flags to various vnode operations.
345 */
346 #define REVOKEALL 0x0001 /* revoke: revoke all aliases */
347
348 #define FSYNC_WAIT 0x0001 /* fsync: wait for completion */
349 #define FSYNC_DATAONLY 0x0002 /* fsync: hint: sync file data only */
350 #define FSYNC_RECLAIM 0x0004 /* fsync: hint: vnode is being reclaimed */
351 #define FSYNC_LAZY 0x0008 /* fsync: lazy sync (trickle) */
352 #define FSYNC_NOLOG 0x0010 /* fsync: do not flush the log */
353 #define FSYNC_CACHE 0x0100 /* fsync: flush disk caches too */
354 #define FSYNC_VFS 0x0200 /* fsync: via FSYNC_VFS() */
355
356 #define UPDATE_WAIT 0x0001 /* update: wait for completion */
357 #define UPDATE_DIROP 0x0002 /* update: hint to fs to wait or not */
358 #define UPDATE_CLOSE 0x0004 /* update: clean up on close */
359
360 #define HOLDRELE(vp) holdrele(vp)
361 #define VHOLD(vp) vhold(vp)
362 #define VREF(vp) vref(vp)
363 extern kmutex_t vnode_free_list_lock;
364
365 void holdrelel(struct vnode *);
366 void vholdl(struct vnode *);
367 void vref(struct vnode *);
368
369 static __inline void holdrele(struct vnode *) __unused;
370 static __inline void vhold(struct vnode *) __unused;
371
372 #define VATTR_NULL(vap) vattr_null(vap)
373
374 /*
375 * decrease buf or page ref
376 */
377 static __inline void
378 holdrele(struct vnode *vp)
379 {
380
381 mutex_enter(&vp->v_interlock);
382 holdrelel(vp);
383 mutex_exit(&vp->v_interlock);
384 }
385
386 /*
387 * increase buf or page ref
388 */
389 static __inline void
390 vhold(struct vnode *vp)
391 {
392
393 mutex_enter(&vp->v_interlock);
394 vholdl(vp);
395 mutex_exit(&vp->v_interlock);
396 }
397
398 static __inline bool
399 vismarker(struct vnode *vp)
400 {
401
402 return (vp->v_iflag & VI_MARKER) != 0;
403 }
404
405 #define NULLVP ((struct vnode *)NULL)
406
407 static __inline void
408 VN_KNOTE(struct vnode *vp, long hint)
409 {
410
411 mutex_enter(&vp->v_interlock);
412 KNOTE(&vp->v_klist, hint);
413 mutex_exit(&vp->v_interlock);
414 }
415
416 /*
417 * Global vnode data.
418 */
419 extern struct vnode *rootvnode; /* root (i.e. "/") vnode */
420 extern int desiredvnodes; /* number of vnodes desired */
421 extern u_int numvnodes; /* current number of vnodes */
422 extern time_t syncdelay; /* max time to delay syncing data */
423 extern time_t filedelay; /* time to delay syncing files */
424 extern time_t dirdelay; /* time to delay syncing directories */
425 extern time_t metadelay; /* time to delay syncing metadata */
426
427 /*
428 * Macro/function to check for client cache inconsistency w.r.t. leasing.
429 */
430 #define LEASE_READ 0x1 /* Check lease for readers */
431 #define LEASE_WRITE 0x2 /* Check lease for modifiers */
432
433 #endif /* _KERNEL */
434
435
436 /*
437 * Mods for exensibility.
438 */
439
440 /*
441 * Flags for vdesc_flags:
442 */
443 #define VDESC_MAX_VPS 8
444 /* Low order 16 flag bits are reserved for willrele flags for vp arguments. */
445 #define VDESC_VP0_WILLRELE 0x00000001
446 #define VDESC_VP1_WILLRELE 0x00000002
447 #define VDESC_VP2_WILLRELE 0x00000004
448 #define VDESC_VP3_WILLRELE 0x00000008
449 #define VDESC_VP0_WILLUNLOCK 0x00000100
450 #define VDESC_VP1_WILLUNLOCK 0x00000200
451 #define VDESC_VP2_WILLUNLOCK 0x00000400
452 #define VDESC_VP3_WILLUNLOCK 0x00000800
453 #define VDESC_VP0_WILLPUT 0x00000101
454 #define VDESC_VP1_WILLPUT 0x00000202
455 #define VDESC_VP2_WILLPUT 0x00000404
456 #define VDESC_VP3_WILLPUT 0x00000808
457 #define VDESC_NOMAP_VPP 0x00010000
458 #define VDESC_VPP_WILLRELE 0x00020000
459
460 /*
461 * VDESC_NO_OFFSET is used to identify the end of the offset list
462 * and in places where no such field exists.
463 */
464 #define VDESC_NO_OFFSET -1
465
466 /*
467 * This structure describes the vnode operation taking place.
468 */
469 struct vnodeop_desc {
470 int vdesc_offset; /* offset in vector--first for speed */
471 const char *vdesc_name; /* a readable name for debugging */
472 int vdesc_flags; /* VDESC_* flags */
473
474 /*
475 * These ops are used by bypass routines to map and locate arguments.
476 * Creds and procs are not needed in bypass routines, but sometimes
477 * they are useful to (for example) transport layers.
478 * Nameidata is useful because it has a cred in it.
479 */
480 const int *vdesc_vp_offsets; /* list ended by VDESC_NO_OFFSET */
481 int vdesc_vpp_offset; /* return vpp location */
482 int vdesc_cred_offset; /* cred location, if any */
483 int vdesc_componentname_offset; /* if any */
484 /*
485 * Finally, we've got a list of private data (about each operation)
486 * for each transport layer. (Support to manage this list is not
487 * yet part of BSD.)
488 */
489 void * *vdesc_transports;
490 };
491
492 #ifdef _KERNEL
493 #include <sys/mallocvar.h>
494 MALLOC_DECLARE(M_CACHE);
495 MALLOC_DECLARE(M_VNODE);
496
497 /*
498 * A list of all the operation descs.
499 */
500 extern struct vnodeop_desc *vnodeop_descs[];
501
502 /*
503 * Interlock for scanning list of vnodes attached to a mountpoint
504 */
505 extern kmutex_t mntvnode_lock;
506
507 /*
508 * Union filesystem hook for vn_readdir().
509 */
510 extern int (*vn_union_readdir_hook) (struct vnode **, struct file *, struct lwp *);
511
512 /*
513 * This macro is very helpful in defining those offsets in the vdesc struct.
514 *
515 * This is stolen from X11R4. I ingored all the fancy stuff for
516 * Crays, so if you decide to port this to such a serious machine,
517 * you might want to consult Intrisics.h's XtOffset{,Of,To}.
518 */
519 #define VOPARG_OFFSET(p_type,field) \
520 ((int) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
521 #define VOPARG_OFFSETOF(s_type,field) \
522 VOPARG_OFFSET(s_type*,field)
523 #define VOPARG_OFFSETTO(S_TYPE,S_OFFSET,STRUCT_P) \
524 ((S_TYPE)(((char*)(STRUCT_P))+(S_OFFSET)))
525
526
527 /*
528 * This structure is used to configure the new vnodeops vector.
529 */
530 struct vnodeopv_entry_desc {
531 const struct vnodeop_desc *opve_op; /* which operation this is */
532 int (*opve_impl)(void *); /* code implementing this operation */
533 };
534 struct vnodeopv_desc {
535 /* ptr to the ptr to the vector where op should go */
536 int (***opv_desc_vector_p)(void *);
537 const struct vnodeopv_entry_desc *opv_desc_ops; /* null terminated list */
538 };
539
540 /*
541 * A default routine which just returns an error.
542 */
543 int vn_default_error(void *);
544
545 /*
546 * A generic structure.
547 * This can be used by bypass routines to identify generic arguments.
548 */
549 struct vop_generic_args {
550 struct vnodeop_desc *a_desc;
551 /* other random data follows, presumably */
552 };
553
554 /*
555 * VOCALL calls an op given an ops vector. We break it out because BSD's
556 * vclean changes the ops vector and then wants to call ops with the old
557 * vector.
558 */
559 /*
560 * actually, vclean doesn't use it anymore, but nfs does,
561 * for device specials and fifos.
562 */
563 #define VOCALL(OPSV,OFF,AP) (( *((OPSV)[(OFF)])) (AP))
564
565 /*
566 * This call works for vnodes in the kernel.
567 */
568 #define VCALL(VP,OFF,AP) VOCALL((VP)->v_op,(OFF),(AP))
569 #define VDESC(OP) (& __CONCAT(OP,_desc))
570 #define VOFFSET(OP) (VDESC(OP)->vdesc_offset)
571
572 /* XXX This include should go away */
573 #include <sys/mount.h>
574
575 /*
576 * Finally, include the default set of vnode operations.
577 */
578 #include <sys/vnode_if.h>
579
580 /*
581 * Public vnode manipulation functions.
582 */
583 struct file;
584 struct filedesc;
585 struct nameidata;
586 struct proc;
587 struct stat;
588 struct uio;
589 struct vattr;
590 struct vnode;
591
592 /* see vnode(9) */
593 int bdevvp(dev_t, struct vnode **);
594 int cdevvp(dev_t, struct vnode **);
595 int getnewvnode(enum vtagtype, struct mount *, int (**)(void *),
596 struct vnode **);
597 void ungetnewvnode(struct vnode *);
598 int vaccess(enum vtype, mode_t, uid_t, gid_t, mode_t, kauth_cred_t);
599 void vattr_null(struct vattr *);
600 int vcount(struct vnode *);
601 void vdevgone(int, int, int, enum vtype);
602 int vfinddev(dev_t, enum vtype, struct vnode **);
603 int vflush(struct mount *, struct vnode *, int);
604 void vflushbuf(struct vnode *, int);
605 int vget(struct vnode *, int);
606 bool vtryget(struct vnode *);
607 void vgone(struct vnode *);
608 void vgonel(struct vnode *, struct lwp *);
609 int vinvalbuf(struct vnode *, int, kauth_cred_t, struct lwp *, bool, int);
610 void vprint(const char *, struct vnode *);
611 void vput(struct vnode *);
612 int vrecycle(struct vnode *, kmutex_t *, struct lwp *);
613 void vrele(struct vnode *);
614 int vtruncbuf(struct vnode *, daddr_t, bool, int);
615 void vwakeup(struct buf *);
616 void vwait(struct vnode *, int);
617 void vclean(struct vnode *, int);
618 void vrevoke(struct vnode *);
619 void vrelel(struct vnode *, int);
620 #define VRELEL_NOINACTIVE 0x01
621 #define VRELEL_ONHEAD 0x02
622 struct vnode *
623 vnalloc(struct mount *);
624 void vnfree(struct vnode *);
625 void vmark(struct vnode *, struct vnode *);
626 struct vnode *
627 vunmark(struct vnode *);
628 void vn_init1(void);
629
630 /* see vnsubr(9) */
631 int vn_bwrite(void *);
632 int vn_close(struct vnode *, int, kauth_cred_t);
633 int vn_isunder(struct vnode *, struct vnode *, struct lwp *);
634 int vn_lock(struct vnode *, int);
635 void vn_markexec(struct vnode *);
636 int vn_marktext(struct vnode *);
637 int vn_open(struct nameidata *, int, int);
638 int vn_rdwr(enum uio_rw, struct vnode *, void *, int, off_t, enum uio_seg,
639 int, kauth_cred_t, size_t *, struct lwp *);
640 int vn_readdir(struct file *, char *, int, u_int, int *, struct lwp *,
641 off_t **, int *);
642 void vn_restorerecurse(struct vnode *, u_int);
643 u_int vn_setrecurse(struct vnode *);
644 int vn_stat(struct vnode *, struct stat *);
645 int vn_kqfilter(struct file *, struct knote *);
646 int vn_writechk(struct vnode *);
647 int vn_openchk(struct vnode *, kauth_cred_t, int);
648 int vn_extattr_get(struct vnode *, int, int, const char *, size_t *,
649 void *, struct lwp *);
650 int vn_extattr_set(struct vnode *, int, int, const char *, size_t,
651 const void *, struct lwp *);
652 int vn_extattr_rm(struct vnode *, int, int, const char *, struct lwp *);
653 void vn_ra_allocctx(struct vnode *);
654
655 /* initialise global vnode management */
656 void vntblinit(void);
657
658 /* misc stuff */
659 void vn_syncer_add_to_worklist(struct vnode *, int);
660 void vn_syncer_remove_from_worklist(struct vnode *);
661 int speedup_syncer(void);
662 int dorevoke(struct vnode *, kauth_cred_t);
663 int vlockmgr(struct vnlock *, int);
664 int vlockstatus(struct vnlock *);
665
666 /* see vfssubr(9) */
667 void vfs_getnewfsid(struct mount *);
668 int vfs_drainvnodes(long target, struct lwp *);
669 void vfs_timestamp(struct timespec *);
670 #ifdef DDB
671 void vfs_vnode_print(struct vnode *, int, void (*)(const char *, ...));
672 void vfs_mount_print(struct mount *, int, void (*)(const char *, ...));
673 #endif /* DDB */
674 #endif /* _KERNEL */
675
676 #endif /* !_SYS_VNODE_H_ */
Cache object: 9d70baffdbb4043e7d2f60c04a182816
|