#ifndef _SYS_VNODE_H_
#define _SYS_VNODE_H_
#include <sys/buf.h>
#include <sys/types.h>
#include <sys/event.h>
#include <sys/queue.h>
#include <sys/tree.h>
enum vtype { VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK, VFIFO, VBAD };
#define VTYPE_NAMES \
"VNON", "VREG", "VDIR", "VBLK", "VCHR", "VLNK", "VSOCK", "VFIFO", "VBAD"
enum vtagtype {
VT_NON, VT_UFS, VT_NFS, VT_MFS, VT_MSDOSFS,
VT_PORTAL, VT_PROCFS, VT_AFS, VT_ISOFS, VT_ADOSFS,
VT_EXT2FS, VT_VFS, VT_NTFS, VT_UDF, VT_FUSEFS, VT_TMPFS,
};
#define VTAG_NAMES \
"NON", "UFS", "NFS", "MFS", "MSDOSFS", \
"unused", "unused", "unused", "ISOFS", "unused", \
"EXT2FS", "VFS", "NTFS", "UDF", "FUSEFS", "TMPFS"
LIST_HEAD(buflists, buf);
RBT_HEAD(buf_rb_bufs, buf);
struct namecache;
RBT_HEAD(namecache_rb_cache, namecache);
struct uvm_vnode;
struct vnode {
struct uvm_vnode *v_uvm;
const struct vops *v_op;
enum vtype v_type;
enum vtagtype v_tag;
u_int v_flag;
u_int v_lflag;
u_int v_usecount;
u_int v_uvcount;
u_int v_writecount;
u_int v_lockcount;
u_int v_bioflag;
u_int v_holdcnt;
u_int v_id;
struct mount *v_mount;
TAILQ_ENTRY(vnode) v_freelist;
TAILQ_ENTRY(vnode) v_mntvnodes;
struct buf_rb_bufs v_bufs_tree;
struct buflists v_cleanblkhd;
struct buflists v_dirtyblkhd;
u_int v_numoutput;
LIST_ENTRY(vnode) v_synclist;
union {
struct mount *vu_mountedhere;
struct socket *vu_socket;
struct specinfo *vu_specinfo;
struct fifoinfo *vu_fifoinfo;
} v_un;
struct namecache_rb_cache v_nc_tree;
TAILQ_HEAD(, namecache) v_cache_dst;
void *v_data;
struct klist v_klist;
};
#define v_mountedhere v_un.vu_mountedhere
#define v_socket v_un.vu_socket
#define v_specinfo v_un.vu_specinfo
#define v_fifoinfo v_un.vu_fifoinfo
#define VROOT 0x0001
#define VTEXT 0x0002
#define VSYSTEM 0x0004
#define VISTTY 0x0008
#define VXLOCK 0x0100
#define VXWANT 0x0200
#define VCLONED 0x0400
#define VALIASED 0x0800
#define VLARVAL 0x1000
#define VLOCKSWORK 0x4000
#define VCLONE 0x8000
#define VBIOWAIT 0x0001
#define VBIOONSYNCLIST 0x0002
#define VBIOONFREELIST 0x0004
#define VBIOERROR 0x0008
struct vattr {
enum vtype va_type;
mode_t va_mode;
nlink_t va_nlink;
uid_t va_uid;
gid_t va_gid;
long va_fsid;
u_quad_t va_fileid;
u_quad_t va_size;
long va_blocksize;
struct timespec va_atime;
struct timespec va_mtime;
struct timespec va_ctime;
u_long va_gen;
u_long va_flags;
dev_t va_rdev;
u_quad_t va_bytes;
u_quad_t va_filerev;
u_int va_vaflags;
long va_spare;
};
#define VA_UTIMES_NULL 0x01
#define VA_EXCLUSIVE 0x02
#define VA_UTIMES_CHANGE 0x04
#define IO_UNIT 0x01
#define IO_APPEND 0x02
#define IO_SYNC 0x04
#define IO_NODELOCKED 0x08
#define IO_NDELAY 0x10
#define IO_NOLIMIT 0x20
#define IO_NOCACHE 0x40
#define VSUID 04000
#define VSGID 02000
#define VSVTX 01000
#define VREAD 00400
#define VWRITE 00200
#define VEXEC 00100
#define VNOVAL (-1)
#ifdef _KERNEL
RBT_PROTOTYPE(buf_rb_bufs, buf, b_rbbufs, rb_buf_compare);
extern enum vtype iftovt_tab[];
extern int vttoif_tab[];
#define IFTOVT(mode) (iftovt_tab[((mode) & S_IFMT) >> 12])
#define VTTOIF(indx) (vttoif_tab[(int)(indx)])
#define MAKEIMODE(indx, mode) (int)(VTTOIF(indx) | (mode))
#define SKIPSYSTEM 0x0001
#define FORCECLOSE 0x0002
#define WRITECLOSE 0x0004
#define DOCLOSE 0x0008
#define IGNORECLEAN 0x0010
#define V_SAVE 0x0001
#define V_SAVEMETA 0x0002
#define REVOKEALL 0x0001
#define VN_KNOTE(vp, b) \
knote_locked(&vp->v_klist, (b))
extern struct vnode *rootvnode;
extern int initialvnodes;
extern int maxvnodes;
extern int syncdelay;
extern int rushjob;
extern struct mutex vnode_mtx;
extern void vhold(struct vnode *);
extern void vdrop(struct vnode *);
struct vops {
int (*vop_lock)(void *);
int (*vop_unlock)(void *);
int (*vop_islocked)(void *);
int (*vop_abortop)(void *);
int (*vop_access)(void *);
int (*vop_advlock)(void *);
int (*vop_bmap)(void *);
int (*vop_bwrite)(void *);
int (*vop_close)(void *);
int (*vop_create)(void *);
int (*vop_fsync)(void *);
int (*vop_getattr)(void *);
int (*vop_inactive)(void *);
int (*vop_ioctl)(void *);
int (*vop_link)(void *);
int (*vop_lookup)(void *);
int (*vop_mknod)(void *);
int (*vop_open)(void *);
int (*vop_pathconf)(void *);
int (*vop_print)(void *);
int (*vop_read)(void *);
int (*vop_readdir)(void *);
int (*vop_readlink)(void *);
int (*vop_reclaim)(void *);
int (*vop_remove)(void *);
int (*vop_rename)(void *);
int (*vop_revoke)(void *);
int (*vop_mkdir)(void *);
int (*vop_rmdir)(void *);
int (*vop_setattr)(void *);
int (*vop_strategy)(void *);
int (*vop_symlink)(void *);
int (*vop_write)(void *);
int (*vop_kqfilter)(void *);
};
extern const struct vops dead_vops;
extern const struct vops spec_vops;
struct vop_generic_args {
void *a_garbage;
};
struct vop_islocked_args {
struct vnode *a_vp;
};
int VOP_ISLOCKED(struct vnode *);
struct vop_lookup_args {
struct vnode *a_dvp;
struct vnode **a_vpp;
struct componentname *a_cnp;
};
int VOP_LOOKUP(struct vnode *, struct vnode **, struct componentname *);
struct vop_create_args {
struct vnode *a_dvp;
struct vnode **a_vpp;
struct componentname *a_cnp;
struct vattr *a_vap;
};
int VOP_CREATE(struct vnode *, struct vnode **, struct componentname *,
struct vattr *);
struct vop_mknod_args {
struct vnode *a_dvp;
struct vnode **a_vpp;
struct componentname *a_cnp;
struct vattr *a_vap;
};
int VOP_MKNOD(struct vnode *, struct vnode **, struct componentname *,
struct vattr *);
struct vop_open_args {
struct vnode *a_vp;
int a_mode;
struct ucred *a_cred;
struct proc *a_p;
};
int VOP_OPEN(struct vnode *, int, struct ucred *, struct proc *);
struct vop_close_args {
struct vnode *a_vp;
int a_fflag;
struct ucred *a_cred;
struct proc *a_p;
};
int VOP_CLOSE(struct vnode *, int, struct ucred *, struct proc *);
struct vop_access_args {
struct vnode *a_vp;
int a_mode;
struct ucred *a_cred;
struct proc *a_p;
};
int VOP_ACCESS(struct vnode *, int, struct ucred *, struct proc *);
struct vop_getattr_args {
struct vnode *a_vp;
struct vattr *a_vap;
struct ucred *a_cred;
struct proc *a_p;
};
int VOP_GETATTR(struct vnode *, struct vattr *, struct ucred *, struct proc *);
struct vop_setattr_args {
struct vnode *a_vp;
struct vattr *a_vap;
struct ucred *a_cred;
struct proc *a_p;
};
int VOP_SETATTR(struct vnode *, struct vattr *, struct ucred *, struct proc *);
struct vop_read_args {
struct vnode *a_vp;
struct uio *a_uio;
int a_ioflag;
struct ucred *a_cred;
};
int VOP_READ(struct vnode *, struct uio *, int, struct ucred *);
struct vop_write_args {
struct vnode *a_vp;
struct uio *a_uio;
int a_ioflag;
struct ucred *a_cred;
};
int VOP_WRITE(struct vnode *, struct uio *, int, struct ucred *);
struct vop_ioctl_args {
struct vnode *a_vp;
u_long a_command;
void *a_data;
int a_fflag;
struct ucred *a_cred;
struct proc *a_p;
};
int VOP_IOCTL(struct vnode *, u_long, void *, int, struct ucred *,
struct proc *);
struct vop_kqfilter_args {
struct vnode *a_vp;
int a_fflag;
struct knote *a_kn;
};
int VOP_KQFILTER(struct vnode *, int, struct knote *);
struct vop_revoke_args {
struct vnode *a_vp;
int a_flags;
};
int VOP_REVOKE(struct vnode *, int);
struct vop_fsync_args {
struct vnode *a_vp;
struct ucred *a_cred;
int a_waitfor;
struct proc *a_p;
};
int VOP_FSYNC(struct vnode *, struct ucred *, int, struct proc *);
struct vop_remove_args {
struct vnode *a_dvp;
struct vnode *a_vp;
struct componentname *a_cnp;
};
int VOP_REMOVE(struct vnode *, struct vnode *, struct componentname *);
struct vop_link_args {
struct vnode *a_dvp;
struct vnode *a_vp;
struct componentname *a_cnp;
};
int VOP_LINK(struct vnode *, struct vnode *, struct componentname *);
struct vop_rename_args {
struct vnode *a_fdvp;
struct vnode *a_fvp;
struct componentname *a_fcnp;
struct vnode *a_tdvp;
struct vnode *a_tvp;
struct componentname *a_tcnp;
};
int VOP_RENAME(struct vnode *, struct vnode *, struct componentname *,
struct vnode *, struct vnode *, struct componentname *);
struct vop_mkdir_args {
struct vnode *a_dvp;
struct vnode **a_vpp;
struct componentname *a_cnp;
struct vattr *a_vap;
};
int VOP_MKDIR(struct vnode *, struct vnode **, struct componentname *,
struct vattr *);
struct vop_rmdir_args {
struct vnode *a_dvp;
struct vnode *a_vp;
struct componentname *a_cnp;
};
int VOP_RMDIR(struct vnode *, struct vnode *, struct componentname *);
struct vop_symlink_args {
struct vnode *a_dvp;
struct vnode **a_vpp;
struct componentname *a_cnp;
struct vattr *a_vap;
char *a_target;
};
int VOP_SYMLINK(struct vnode *, struct vnode **, struct componentname *,
struct vattr *, char *);
struct vop_readdir_args {
struct vnode *a_vp;
struct uio *a_uio;
struct ucred *a_cred;
int *a_eofflag;
};
int VOP_READDIR(struct vnode *, struct uio *, struct ucred *, int *);
struct vop_readlink_args {
struct vnode *a_vp;
struct uio *a_uio;
struct ucred *a_cred;
};
int VOP_READLINK(struct vnode *, struct uio *, struct ucred *);
struct vop_abortop_args {
struct vnode *a_dvp;
struct componentname *a_cnp;
};
int VOP_ABORTOP(struct vnode *, struct componentname *);
struct vop_inactive_args {
struct vnode *a_vp;
struct proc *a_p;
};
int VOP_INACTIVE(struct vnode *, struct proc *);
struct vop_reclaim_args {
struct vnode *a_vp;
struct proc *a_p;
};
int VOP_RECLAIM(struct vnode *, struct proc *);
struct vop_lock_args {
struct vnode *a_vp;
int a_flags;
};
int VOP_LOCK(struct vnode *, int);
struct vop_unlock_args {
struct vnode *a_vp;
};
int VOP_UNLOCK(struct vnode *);
struct vop_bmap_args {
struct vnode *a_vp;
daddr_t a_bn;
struct vnode **a_vpp;
daddr_t *a_bnp;
int *a_runp;
};
int VOP_BMAP(struct vnode *, daddr_t, struct vnode **, daddr_t *, int *);
struct vop_print_args {
struct vnode *a_vp;
};
int VOP_PRINT(struct vnode *);
struct vop_pathconf_args {
struct vnode *a_vp;
int a_name;
register_t *a_retval;
};
int VOP_PATHCONF(struct vnode *, int, register_t *);
struct vop_advlock_args {
struct vnode *a_vp;
void *a_id;
int a_op;
struct flock *a_fl;
int a_flags;
};
int VOP_ADVLOCK(struct vnode *, void *, int, struct flock *, int);
struct vop_strategy_args {
struct vnode *a_vp;
struct buf *a_bp;
};
int VOP_STRATEGY(struct vnode *, struct buf *);
struct vop_bwrite_args {
struct buf *a_bp;
};
int VOP_BWRITE(struct buf *);
struct file;
struct mount;
struct nameidata;
struct proc;
struct stat;
struct statfs;
struct ucred;
struct uio;
struct vattr;
struct vnode;
int bdevvp(dev_t, struct vnode **);
int cdevvp(dev_t, struct vnode **);
struct vnode *checkalias(struct vnode *, dev_t, struct mount *);
int getnewvnode(enum vtagtype, struct mount *, const struct vops *,
struct vnode **);
int vaccess(enum vtype, mode_t, uid_t, gid_t, mode_t, struct ucred *);
int vnoperm(struct vnode *);
void vattr_null(struct vattr *);
void vdevgone(int, int, int, enum vtype);
int vcount(struct vnode *);
int vfinddev(dev_t, enum vtype, struct vnode **);
void vflushbuf(struct vnode *, int);
int vflush(struct mount *, struct vnode *, int);
int vget(struct vnode *, int);
void vgone(struct vnode *);
void vgonel(struct vnode *, struct proc *);
int vinvalbuf(struct vnode *, int, struct ucred *, struct proc *,
int, uint64_t);
void vntblinit(void);
int vwaitforio(struct vnode *, int, char *, uint64_t);
void vwakeup(struct vnode *);
void vput(struct vnode *);
int vrecycle(struct vnode *, struct proc *);
int vrele(struct vnode *);
void vref(struct vnode *);
void vprint(char *, struct vnode *);
void copy_statfs_info(struct statfs *, const struct mount *);
#define GETCWD_CHECK_ACCESS 0x0001
int vfs_getcwd_scandir(struct vnode **, struct vnode **, char **, char *,
struct proc *);
int vfs_getcwd_common(struct vnode *, struct vnode *, char **, char *, int,
int, struct proc *);
int vfs_getcwd_getcache(struct vnode **, struct vnode **, char **, char *);
int vop_generic_abortop(void *);
int vop_generic_badop(void *);
int vop_generic_bmap(void *);
int vop_generic_bwrite(void *);
int vop_generic_revoke(void *);
int vop_generic_lookup(void *);
int vn_isunder(struct vnode *, struct vnode *, struct proc *);
int vn_close(struct vnode *, int, struct ucred *, struct proc *);
int vn_open(struct nameidata *, int, int);
int vn_rdwr(enum uio_rw, struct vnode *, caddr_t, int, off_t,
enum uio_seg, int, struct ucred *, size_t *, struct proc *);
int vn_stat(struct vnode *, struct stat *, struct proc *);
int vn_statfile(struct file *, struct stat *, struct proc *);
int vn_lock(struct vnode *, int);
int vn_writechk(struct vnode *);
int vn_fsizechk(struct vnode *, struct uio *, int, ssize_t *);
int vn_ioctl(struct file *, u_long, caddr_t, struct proc *);
void vn_marktext(struct vnode *);
void syncer_thread(void *);
void vn_initialize_syncerd(void);
void vn_syncer_add_to_worklist(struct vnode *, int);
int getvnode(struct proc *, int, struct file **);
void uvm_vnp_setsize(struct vnode *, off_t);
void uvm_vnp_sync(struct mount *);
int uvm_vnp_uncache(struct vnode *);
#endif
#endif