Project

General

Profile

Statistics
| Revision:

root / lab4 / .minix-src / include / sys / vnode.h @ 14

History | View | Annotate | Download (20.5 KB)

1 13 up20180614
/*        $NetBSD: vnode.h,v 1.256 2015/07/12 08:11:28 hannken 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.
86
 */
87
enum vtype        { VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK, VFIFO, VBAD };
88
89
#define        VNODE_TYPES \
90
    "VNON", "VREG", "VDIR", "VBLK", "VCHR", "VLNK", "VSOCK", "VFIFO", "VBAD"
91
92
/*
93
 * Vnode tag types.
94
 * These are for the benefit of external programs only (e.g., pstat)
95
 * and should NEVER be inspected by the kernel.
96
 */
97
enum vtagtype        {
98
        VT_NON, VT_UFS, VT_NFS, VT_MFS, VT_MSDOSFS, VT_LFS, VT_LOFS,
99
        VT_FDESC, VT_PORTAL, VT_NULL, VT_UMAP, VT_KERNFS, VT_PROCFS,
100
        VT_AFS, VT_ISOFS, VT_UNION, VT_ADOSFS, VT_EXT2FS, VT_CODA,
101
        VT_FILECORE, VT_NTFS, VT_VFS, VT_OVERLAY, VT_SMBFS, VT_PTYFS,
102
        VT_TMPFS, VT_UDF, VT_SYSVBFS, VT_PUFFS, VT_HFS, VT_EFS, VT_ZFS,
103
        VT_RUMP, VT_NILFS, VT_V7FS, VT_CHFS
104
};
105
106
#define        VNODE_TAGS \
107
    "VT_NON", "VT_UFS", "VT_NFS", "VT_MFS", "VT_MSDOSFS", "VT_LFS", "VT_LOFS", \
108
    "VT_FDESC", "VT_PORTAL", "VT_NULL", "VT_UMAP", "VT_KERNFS", "VT_PROCFS", \
109
    "VT_AFS", "VT_ISOFS", "VT_UNION", "VT_ADOSFS", "VT_EXT2FS", "VT_CODA", \
110
    "VT_FILECORE", "VT_NTFS", "VT_VFS", "VT_OVERLAY", "VT_SMBFS", "VT_PTYFS", \
111
    "VT_TMPFS", "VT_UDF", "VT_SYSVBFS", "VT_PUFFS", "VT_HFS", "VT_EFS", \
112
    "VT_ZFS", "VT_RUMP", "VT_NILFS", "VT_V7FS", "VT_CHFS"
113
114
struct vnode;
115
struct buf;
116
117
LIST_HEAD(buflists, buf);
118
TAILQ_HEAD(vnodelst, vnode);
119
120
/*
121
 * Reading or writing any of these items requires holding the appropriate
122
 * lock.  Field markings and the corresponding locks:
123
 *
124
 *        :        stable, reference to the vnode is required
125
 *        f        vnode_free_list_lock, or vrele_lock for vrele_list
126
 *        i        v_interlock
127
 *        m        mntvnode_lock
128
 *        n        namecache_lock
129
 *        s        syncer_data_lock
130
 *        u        locked by underlying filesystem
131
 *        v        vnode lock
132
 *        x        v_interlock + bufcache_lock to modify, either to inspect
133
 *
134
 * Each underlying filesystem allocates its own private area and hangs
135
 * it from v_data.
136
 */
137
struct vnode {
138
        struct uvm_object v_uobj;                /* i: the VM object */
139
        kcondvar_t        v_cv;                        /* i: synchronization */
140
        voff_t                v_size;                        /* i: size of file */
141
        voff_t                v_writesize;                /* i: new size after write */
142
        int                v_iflag;                /* i: VI_* flags */
143
        int                v_vflag;                /* v: VV_* flags */
144
        int                v_uflag;                /* u: VU_* flags */
145
        int                v_numoutput;                /* i: # of pending writes */
146
        int                v_writecount;                /* i: ref count of writers */
147
        int                v_holdcnt;                /* i: page & buffer refs */
148
        int                v_synclist_slot;        /* s: synclist slot index */
149
        struct mount        *v_mount;                /* v: ptr to vfs we are in */
150
        int                (**v_op)(void *);        /* :: vnode operations vector */
151
        TAILQ_ENTRY(vnode) v_freelist;                /* f: vnode freelist */
152
        struct vnodelst        *v_freelisthd;                /* f: which freelist? */
153
        TAILQ_ENTRY(vnode) v_mntvnodes;                /* m: vnodes for mount point */
154
        struct buflists        v_cleanblkhd;                /* x: clean blocklist head */
155
        struct buflists        v_dirtyblkhd;                /* x: dirty blocklist head */
156
        TAILQ_ENTRY(vnode) v_synclist;                /* s: vnodes with dirty bufs */
157
        LIST_HEAD(, namecache) v_dnclist;        /* n: namecaches (children) */
158
        LIST_HEAD(, namecache) v_nclist;        /* n: namecaches (parent) */
159
        union {
160
                struct mount        *vu_mountedhere;/* v: ptr to vfs (VDIR) */
161
                struct socket        *vu_socket;        /* v: unix ipc (VSOCK) */
162
                struct specnode        *vu_specnode;        /* v: device (VCHR, VBLK) */
163
                struct fifoinfo        *vu_fifoinfo;        /* v: fifo (VFIFO) */
164
                struct uvm_ractx *vu_ractx;        /* i: read-ahead ctx (VREG) */
165
        } v_un;
166
        enum vtype        v_type;                        /* :: vnode type */
167
        enum vtagtype        v_tag;                        /* :: type of underlying data */
168
        krwlock_t        v_lock;                        /* v: lock for this vnode */
169
        void                 *v_data;                /* :: private data for fs */
170
        struct klist        v_klist;                /* i: notes attached to vnode */
171
};
172
#define        v_usecount        v_uobj.uo_refs
173
#define        v_interlock        v_uobj.vmobjlock
174
#define        v_mountedhere        v_un.vu_mountedhere
175
#define        v_socket        v_un.vu_socket
176
#define        v_specnode        v_un.vu_specnode
177
#define        v_fifoinfo        v_un.vu_fifoinfo
178
#define        v_ractx                v_un.vu_ractx
179
180
typedef struct vnodelst vnodelst_t;
181
typedef struct vnode vnode_t;
182
183
/*
184
 * Vnode flags.  The first set are locked by vnode lock or are stable.
185
 * VSYSTEM is only used to skip vflush()ing quota files.  VISTTY is used
186
 * when reading dead vnodes.
187
 */
188
#define        VV_ROOT                0x00000001        /* root of its file system */
189
#define        VV_SYSTEM        0x00000002        /* vnode being used by kernel */
190
#define        VV_ISTTY        0x00000004        /* vnode represents a tty */
191
#define        VV_MAPPED        0x00000008        /* vnode might have user mappings */
192
#define        VV_MPSAFE        0x00000010        /* file system code is MP safe */
193
#define        VV_LOCKSWORK        0x00000020        /* FS supports locking discipline */
194
195
/*
196
 * The second set are locked by vp->v_interlock.
197
 */
198
#define        VI_TEXT                0x00000100        /* vnode is a pure text prototype */
199
#define        VI_EXECMAP        0x00000200        /* might have PROT_EXEC mappings */
200
#define        VI_WRMAP        0x00000400        /* might have PROT_WRITE u. mappings */
201
#define        VI_WRMAPDIRTY        0x00000800        /* might have dirty pages */
202
#ifdef _VFS_VNODE_PRIVATE
203
#define        VI_XLOCK        0x00001000        /* vnode is locked to change type */
204
#endif        /* _VFS_VNODE_PRIVATE */
205
#define        VI_ONWORKLST        0x00004000        /* On syncer work-list */
206
#ifdef _VFS_VNODE_PRIVATE
207
#define        VI_MARKER        0x00008000        /* Dummy marker vnode */
208
#endif        /* _VFS_VNODE_PRIVATE */
209
#ifdef _VFS_VNODE_PRIVATE
210
#define        VI_CLEAN        0x00080000        /* has been reclaimed */
211
#define        VI_CHANGING        0x00100000        /* vnode changes state */
212
#endif        /* _VFS_VNODE_PRIVATE */
213
214
/*
215
 * The third set are locked by the underlying file system.
216
 */
217
#define        VU_DIROP        0x01000000        /* LFS: involved in a directory op */
218
219
#define        VNODE_FLAGBITS \
220
    "\20\1ROOT\2SYSTEM\3ISTTY\4MAPPED\5MPSAFE\6LOCKSWORK\11TEXT\12EXECMAP" \
221
    "\13WRMAP\14WRMAPDIRTY\15XLOCK\17ONWORKLST\20MARKER" \
222
    "\24CLEAN\25CHANGING\31DIROP"
223
224
#define        VSIZENOTSET        ((voff_t)-1)
225
226
/*
227
 * vnode lock flags
228
 */
229
#define        LK_SHARED        0x00000001        /* shared lock */
230
#define        LK_EXCLUSIVE        0x00000002        /* exclusive lock */
231
#define        LK_NOWAIT        0x00000010        /* do not sleep to await lock */
232
#define        LK_RETRY        0x00020000        /* vn_lock: retry until locked */
233
234
/*
235
 * Vnode attributes.  A field value of VNOVAL represents a field whose value
236
 * is unavailable (getattr) or which is not to be changed (setattr).
237
 */
238
struct vattr {
239
        enum vtype        va_type;        /* vnode type (for create) */
240
        mode_t                va_mode;        /* files access mode and type */
241
        nlink_t                va_nlink;        /* number of references to file */
242
        uid_t                va_uid;                /* owner user id */
243
        gid_t                va_gid;                /* owner group id */
244
        dev_t                va_fsid;        /* file system id (dev for now) */
245
        ino_t                va_fileid;        /* file id */
246
        u_quad_t        va_size;        /* file size in bytes */
247
        long                va_blocksize;        /* blocksize preferred for i/o */
248
        struct timespec        va_atime;        /* time of last access */
249
        struct timespec        va_mtime;        /* time of last modification */
250
        struct timespec        va_ctime;        /* time file changed */
251
        struct timespec va_birthtime;        /* time file created */
252
        u_long                va_gen;                /* generation number of file */
253
        u_long                va_flags;        /* flags defined for file */
254
        dev_t                va_rdev;        /* device the special file represents */
255
        u_quad_t        va_bytes;        /* bytes of disk space held by file */
256
        u_quad_t        va_filerev;        /* file modification number */
257
        u_int                va_vaflags;        /* operations flags, see below */
258
        long                va_spare;        /* remain quad aligned */
259
};
260
261
/*
262
 * Flags for va_vaflags.
263
 */
264
#define        VA_UTIMES_NULL        0x01                /* utimes argument was NULL */
265
#define        VA_EXCLUSIVE        0x02                /* exclusive create request */
266
267
#ifdef _KERNEL
268
269
/*
270
 * Flags for ioflag.
271
 */
272
#define        IO_UNIT                0x00010                /* do I/O as atomic unit */
273
#define        IO_APPEND        0x00020                /* append write to end */
274
#define        IO_SYNC                (0x40|IO_DSYNC)        /* sync I/O file integrity completion */
275
#define        IO_NODELOCKED        0x00080                /* underlying node already locked */
276
#define        IO_NDELAY        0x00100                /* FNDELAY flag set in file table */
277
#define        IO_DSYNC        0x00200                /* sync I/O data integrity completion */
278
#define        IO_ALTSEMANTICS        0x00400                /* use alternate i/o semantics */
279
#define        IO_NORMAL        0x00800                /* operate on regular data */
280
#define        IO_EXT                0x01000                /* operate on extended attributes */
281
#define        IO_DIRECT        0x02000                /* direct I/O hint */
282
#define        IO_JOURNALLOCKED 0x04000        /* journal is already locked */
283
#define        IO_ADV_MASK        0x00003                /* access pattern hint */
284
285
#define        IO_ADV_SHIFT        0
286
#define        IO_ADV_ENCODE(adv)        (((adv) << IO_ADV_SHIFT) & IO_ADV_MASK)
287
#define        IO_ADV_DECODE(ioflag)        (((ioflag) & IO_ADV_MASK) >> IO_ADV_SHIFT)
288
289
/*
290
 *  Modes.
291
 */
292
#define        VREAD        00004                /* read, write, execute permissions */
293
#define        VWRITE        00002
294
#define        VEXEC        00001
295
296
/*
297
 * Token indicating no attribute value yet assigned.
298
 */
299
#define        VNOVAL        (-1)
300
301
/*
302
 * Convert between vnode types and inode formats (since POSIX.1
303
 * defines mode word of stat structure in terms of inode formats).
304
 */
305
extern const enum vtype        iftovt_tab[];
306
extern const int        vttoif_tab[];
307
#define        IFTOVT(mode)        (iftovt_tab[((mode) & S_IFMT) >> 12])
308
#define        VTTOIF(indx)        (vttoif_tab[(int)(indx)])
309
#define        MAKEIMODE(indx, mode)        (int)(VTTOIF(indx) | (mode))
310
311
/*
312
 * Flags to various vnode functions.
313
 */
314
#define        SKIPSYSTEM        0x0001                /* vflush: skip vnodes marked VSYSTEM */
315
#define        FORCECLOSE        0x0002                /* vflush: force file closeure */
316
#define        WRITECLOSE        0x0004                /* vflush: only close writable files */
317
#define        V_SAVE                0x0001                /* vinvalbuf: sync file first */
318
319
/*
320
 * Flags to various vnode operations.
321
 */
322
#define        REVOKEALL        0x0001                /* revoke: revoke all aliases */
323
324
#define        FSYNC_WAIT        0x0001                /* fsync: wait for completion */
325
#define        FSYNC_DATAONLY        0x0002                /* fsync: hint: sync file data only */
326
#define        FSYNC_RECLAIM        0x0004                /* fsync: hint: vnode is being reclaimed */
327
#define        FSYNC_LAZY        0x0008                /* fsync: lazy sync (trickle) */
328
#define        FSYNC_NOLOG        0x0010                /* fsync: do not flush the log */
329
#define        FSYNC_CACHE        0x0100                /* fsync: flush disk caches too */
330
331
#define        UPDATE_WAIT        0x0001                /* update: wait for completion */
332
#define        UPDATE_DIROP        0x0002                /* update: hint to fs to wait or not */
333
#define        UPDATE_CLOSE        0x0004                /* update: clean up on close */
334
335
#define VDEAD_NOWAIT        0x0001                /* vdead_check: do not sleep */
336
337
void holdrelel(struct vnode *);
338
void vholdl(struct vnode *);
339
void vref(struct vnode *);
340
341
static __inline void holdrele(struct vnode *) __unused;
342
static __inline void vhold(struct vnode *) __unused;
343
344
/*
345
 * decrease buf or page ref
346
 */
347
static __inline void
348
holdrele(struct vnode *vp)
349
{
350
351
        mutex_enter(vp->v_interlock);
352
        holdrelel(vp);
353
        mutex_exit(vp->v_interlock);
354
}
355
356
/*
357
 * increase buf or page ref
358
 */
359
static __inline void
360
vhold(struct vnode *vp)
361
{
362
363
        mutex_enter(vp->v_interlock);
364
        vholdl(vp);
365
        mutex_exit(vp->v_interlock);
366
}
367
368
#define        NULLVP        ((struct vnode *)NULL)
369
370
static __inline void
371
VN_KNOTE(struct vnode *vp, long hint)
372
{
373
374
        mutex_enter(vp->v_interlock);
375
        KNOTE(&vp->v_klist, hint);
376
        mutex_exit(vp->v_interlock);
377
}
378
379
/*
380
 * Global vnode data.
381
 */
382
extern struct vnode        *rootvnode;        /* root (i.e. "/") vnode */
383
extern int                desiredvnodes;        /* number of vnodes desired */
384
extern u_int                numvnodes;        /* current number of vnodes */
385
386
#endif /* _KERNEL */
387
388
389
/*
390
 * Mods for exensibility.
391
 */
392
393
/*
394
 * Flags for vdesc_flags:
395
 */
396
#define        VDESC_MAX_VPS                8
397
/* Low order 16 flag bits are reserved for willrele flags for vp arguments. */
398
#define        VDESC_VP0_WILLRELE        0x00000001
399
#define        VDESC_VP1_WILLRELE        0x00000002
400
#define        VDESC_VP2_WILLRELE        0x00000004
401
#define        VDESC_VP3_WILLRELE        0x00000008
402
#define        VDESC_VP0_WILLUNLOCK        0x00000100
403
#define        VDESC_VP1_WILLUNLOCK        0x00000200
404
#define        VDESC_VP2_WILLUNLOCK        0x00000400
405
#define        VDESC_VP3_WILLUNLOCK        0x00000800
406
#define        VDESC_VP0_WILLPUT        0x00000101
407
#define        VDESC_VP1_WILLPUT        0x00000202
408
#define        VDESC_VP2_WILLPUT        0x00000404
409
#define        VDESC_VP3_WILLPUT        0x00000808
410
411
/*
412
 * VDESC_NO_OFFSET is used to identify the end of the offset list
413
 * and in places where no such field exists.
414
 */
415
#define        VDESC_NO_OFFSET -1
416
417
/*
418
 * This structure describes the vnode operation taking place.
419
 */
420
struct vnodeop_desc {
421
        int                vdesc_offset;        /* offset in vector--first for speed */
422
        const char        *vdesc_name;        /* a readable name for debugging */
423
        int                vdesc_flags;        /* VDESC_* flags */
424
425
        /*
426
         * These ops are used by bypass routines to map and locate arguments.
427
         * Creds and procs are not needed in bypass routines, but sometimes
428
         * they are useful to (for example) transport layers.
429
         * Nameidata is useful because it has a cred in it.
430
         */
431
        const int        *vdesc_vp_offsets;        /* list ended by VDESC_NO_OFFSET */
432
        int                vdesc_vpp_offset;        /* return vpp location */
433
        int                vdesc_cred_offset;        /* cred location, if any */
434
        int                vdesc_componentname_offset; /* if any */
435
};
436
437
#ifdef _KERNEL
438
439
/*
440
 * Interlock for scanning list of vnodes attached to a mountpoint
441
 */
442
extern kmutex_t                mntvnode_lock;
443
444
/*
445
 * Union filesystem hook for vn_readdir().
446
 */
447
extern int (*vn_union_readdir_hook) (struct vnode **, struct file *, struct lwp *);
448
449
/*
450
 * Macros for offsets in the vdesc struct.
451
 */
452
#define        VOPARG_OFFSETOF(type, member)        offsetof(type, member)
453
#define        VOPARG_OFFSETTO(type,offset,sp)        ((type)(((char *)(sp)) + (offset)))
454
455
/*
456
 * This structure is used to configure the new vnodeops vector.
457
 */
458
struct vnodeopv_entry_desc {
459
        const struct vnodeop_desc *opve_op;        /* which operation this is */
460
        int (*opve_impl)(void *);        /* code implementing this operation */
461
};
462
463
struct vnodeopv_desc {
464
                        /* ptr to the ptr to the vector where op should go */
465
        int (***opv_desc_vector_p)(void *);
466
        const struct vnodeopv_entry_desc *opv_desc_ops; /* null terminated list */
467
};
468
469
/*
470
 * A default routine which just returns an error.
471
 */
472
int vn_default_error(void *);
473
474
/*
475
 * A generic structure.
476
 * This can be used by bypass routines to identify generic arguments.
477
 */
478
struct vop_generic_args {
479
        struct vnodeop_desc *a_desc;
480
        /* other random data follows, presumably */
481
};
482
483
/*
484
 * VOCALL calls an op given an ops vector.  We break it out because BSD's
485
 * vclean changes the ops vector and then wants to call ops with the old
486
 * vector.
487
 */
488
/*
489
 * actually, vclean doesn't use it anymore, but nfs does,
490
 * for device specials and fifos.
491
 */
492
#define        VOCALL(OPSV,OFF,AP) (( *((OPSV)[(OFF)])) (AP))
493
494
/*
495
 * This call works for vnodes in the kernel.
496
 */
497
#define        VCALL(VP,OFF,AP) VOCALL((VP)->v_op,(OFF),(AP))
498
#define        VDESC(OP) (& __CONCAT(OP,_desc))
499
#define        VOFFSET(OP) (VDESC(OP)->vdesc_offset)
500
501
/* XXX This include should go away */
502
#include <sys/mount.h>
503
504
/*
505
 * Finally, include the default set of vnode operations.
506
 */
507
#include <sys/vnode_if.h>
508
509
/*
510
 * Public vnode manipulation functions.
511
 */
512
struct file;
513
struct filedesc;
514
struct nameidata;
515
struct proc;
516
struct stat;
517
struct uio;
518
struct vattr;
519
struct vnode;
520
521
/* see vnode(9) */
522
void        vfs_vnode_sysinit(void);
523
int         bdevvp(dev_t, struct vnode **);
524
int         cdevvp(dev_t, struct vnode **);
525
int        vaccess(enum vtype, mode_t, uid_t, gid_t, mode_t, kauth_cred_t);
526
void         vattr_null(struct vattr *);
527
void        vdevgone(int, int, int, enum vtype);
528
int        vfinddev(dev_t, enum vtype, struct vnode **);
529
int        vflush(struct mount *, struct vnode *, int);
530
int        vflushbuf(struct vnode *, int);
531
int         vget(struct vnode *, int, bool);
532
void         vgone(struct vnode *);
533
int        vinvalbuf(struct vnode *, int, kauth_cred_t, struct lwp *, bool, int);
534
void        vprint(const char *, struct vnode *);
535
void         vput(struct vnode *);
536
bool        vrecycle(struct vnode *);
537
void         vrele(struct vnode *);
538
void         vrele_async(struct vnode *);
539
void        vrele_flush(void);
540
int        vtruncbuf(struct vnode *, daddr_t, bool, int);
541
void        vwakeup(struct buf *);
542
int        vdead_check(struct vnode *, int);
543
void        vrevoke(struct vnode *);
544
struct vnode *
545
        vnalloc(struct mount *);
546
void        vnfree(struct vnode *);
547
void        vremfree(struct vnode *);
548
int        vcache_get(struct mount *, const void *, size_t, struct vnode **);
549
int        vcache_new(struct mount *, struct vnode *,
550
            struct vattr *, kauth_cred_t, struct vnode **);
551
int        vcache_rekey_enter(struct mount *, struct vnode *,
552
            const void *, size_t, const void *, size_t);
553
void        vcache_rekey_exit(struct mount *, struct vnode *,
554
            const void *, size_t, const void *, size_t);
555
void        vcache_remove(struct mount *, const void *, size_t);
556
557
/* see vnsubr(9) */
558
int        vn_bwrite(void *);
559
int         vn_close(struct vnode *, int, kauth_cred_t);
560
int        vn_isunder(struct vnode *, struct vnode *, struct lwp *);
561
int        vn_lock(struct vnode *, int);
562
void        vn_markexec(struct vnode *);
563
int        vn_marktext(struct vnode *);
564
int         vn_open(struct nameidata *, int, int);
565
int         vn_rdwr(enum uio_rw, struct vnode *, void *, int, off_t, enum uio_seg,
566
    int, kauth_cred_t, size_t *, struct lwp *);
567
int        vn_readdir(struct file *, char *, int, u_int, int *, struct lwp *,
568
    off_t **, int *);
569
int        vn_stat(struct vnode *, struct stat *);
570
int        vn_kqfilter(struct file *, struct knote *);
571
int        vn_writechk(struct vnode *);
572
int        vn_openchk(struct vnode *, kauth_cred_t, int);
573
int        vn_extattr_get(struct vnode *, int, int, const char *, size_t *,
574
            void *, struct lwp *);
575
int        vn_extattr_set(struct vnode *, int, int, const char *, size_t,
576
            const void *, struct lwp *);
577
int        vn_extattr_rm(struct vnode *, int, int, const char *, struct lwp *);
578
void        vn_ra_allocctx(struct vnode *);
579
int        vn_fifo_bypass(void *);
580
581
/* initialise global vnode management */
582
void        vntblinit(void);
583
584
/* misc stuff */
585
void        sched_sync(void *);
586
void        vn_syncer_add_to_worklist(struct vnode *, int);
587
void        vn_syncer_remove_from_worklist(struct vnode *);
588
int        dorevoke(struct vnode *, kauth_cred_t);
589
int        rawdev_mounted(struct vnode *, struct vnode **);
590
uint8_t        vtype2dt(enum vtype);
591
592
/* see vfssubr(9) */
593
void        vfs_getnewfsid(struct mount *);
594
int        vfs_drainvnodes(long);
595
void        vfs_timestamp(struct timespec *);
596
#if defined(DDB) || defined(DEBUGPRINT)
597
void        vfs_vnode_print(struct vnode *, int, void (*)(const char *, ...)
598
    __printflike(1, 2));
599
void        vfs_mount_print(struct mount *, int, void (*)(const char *, ...)
600
    __printflike(1, 2));
601
#endif /* DDB */
602
603
#endif /* _KERNEL */
604
605
#endif /* !_SYS_VNODE_H_ */