vnode.h

来自「基于组件方式开发操作系统的OSKIT源代码」· C头文件 代码 · 共 568 行 · 第 1/2 页

H
568
字号
	struct vnode *vp;{	simple_lock(&vp->v_interlock);	vp->v_holdcnt--;	if ((vp->v_freelist.tqe_prev != (struct vnode **)0xdeadb) &&	    vp->v_holdcnt == 0 && vp->v_usecount == 0) {		simple_lock(&vnode_free_list_slock);		TAILQ_REMOVE(&vnode_hold_list, vp, v_freelist);		TAILQ_INSERT_TAIL(&vnode_free_list, vp, v_freelist);		simple_unlock(&vnode_free_list_slock);	}	simple_unlock(&vp->v_interlock);}/* * increase buf or page ref */static __inline voidvhold(vp)	struct vnode *vp;{	simple_lock(&vp->v_interlock);	if ((vp->v_freelist.tqe_prev != (struct vnode **)0xdeadb) &&	    vp->v_holdcnt == 0 && vp->v_usecount == 0) {		simple_lock(&vnode_free_list_slock);		TAILQ_REMOVE(&vnode_free_list, vp, v_freelist);		TAILQ_INSERT_TAIL(&vnode_hold_list, vp, v_freelist);		simple_unlock(&vnode_free_list_slock);	}	vp->v_holdcnt++;	simple_unlock(&vp->v_interlock);}/* * increase reference */static __inline voidvref(vp)	struct vnode *vp;{	simple_lock(&vp->v_interlock);	vp->v_usecount++;	simple_unlock(&vp->v_interlock);}#endif /* DIAGNOSTIC */#define	NULLVP	((struct vnode *)NULL)/* * Global vnode data. */extern	struct vnode *rootvnode;	/* root (i.e. "/") vnode */extern	int desiredvnodes;		/* number of vnodes desired */extern	long numvnodes;			/* current number of vnodes */extern	time_t syncdelay;		/* max time to delay syncing data */extern	time_t filedelay;		/* time to delay syncing files */extern	time_t dirdelay;		/* time to delay syncing directories */extern	time_t metadelay;		/* time to delay syncing metadata */extern	struct vattr va_null;		/* predefined null vattr structure *//* * Macro/function to check for client cache inconsistency w.r.t. leasing. */#define	LEASE_READ	0x1		/* Check lease for readers */#define	LEASE_WRITE	0x2		/* Check lease for modifiers */#endif /* _KERNEL *//* * Mods for exensibility. *//* * Flags for vdesc_flags: */#define VDESC_MAX_VPS		8/* Low order 16 flag bits are reserved for willrele flags for vp arguments. */#define VDESC_VP0_WILLRELE	0x00000001#define VDESC_VP1_WILLRELE	0x00000002#define VDESC_VP2_WILLRELE	0x00000004#define VDESC_VP3_WILLRELE	0x00000008#define VDESC_VP0_WILLUNLOCK	0x00000100#define VDESC_VP1_WILLUNLOCK	0x00000200#define VDESC_VP2_WILLUNLOCK	0x00000400#define VDESC_VP3_WILLUNLOCK	0x00000800#define VDESC_VP0_WILLPUT	0x00000101#define VDESC_VP1_WILLPUT	0x00000202#define VDESC_VP2_WILLPUT	0x00000404#define VDESC_VP3_WILLPUT	0x00000808#define VDESC_NOMAP_VPP		0x00010000#define VDESC_VPP_WILLRELE	0x00020000/* * VDESC_NO_OFFSET is used to identify the end of the offset list * and in places where no such field exists. */#define VDESC_NO_OFFSET -1/* * This structure describes the vnode operation taking place. */struct vnodeop_desc {	int	vdesc_offset;		/* offset in vector--first for speed */	char    *vdesc_name;		/* a readable name for debugging */	int	vdesc_flags;		/* VDESC_* flags */	/*	 * These ops are used by bypass routines to map and locate arguments.	 * Creds and procs are not needed in bypass routines, but sometimes	 * they are useful to (for example) transport layers.	 * Nameidata is useful because it has a cred in it.	 */	int	*vdesc_vp_offsets;	/* list ended by VDESC_NO_OFFSET */	int	vdesc_vpp_offset;	/* return vpp location */	int	vdesc_cred_offset;	/* cred location, if any */	int	vdesc_proc_offset;	/* proc location, if any */	int	vdesc_componentname_offset; /* if any */	/*	 * Finally, we've got a list of private data (about each operation)	 * for each transport layer.  (Support to manage this list is not	 * yet part of BSD.)	 */	caddr_t	*vdesc_transports;};#ifdef _KERNEL/* * A list of all the operation descs. */extern struct vnodeop_desc *vnodeop_descs[];/* * Interlock for scanning list of vnodes attached to a mountpoint */extern struct simplelock mntvnode_slock;/* * This macro is very helpful in defining those offsets in the vdesc struct. * * This is stolen from X11R4.  I ingored all the fancy stuff for * Crays, so if you decide to port this to such a serious machine, * you might want to consult Intrisics.h's XtOffset{,Of,To}. */#define VOPARG_OFFSET(p_type,field) \        ((int) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))#define VOPARG_OFFSETOF(s_type,field) \	VOPARG_OFFSET(s_type*,field)#define VOPARG_OFFSETTO(S_TYPE,S_OFFSET,STRUCT_P) \	((S_TYPE)(((char*)(STRUCT_P))+(S_OFFSET)))/* * This structure is used to configure the new vnodeops vector. */struct vnodeopv_entry_desc {	struct vnodeop_desc *opve_op;   /* which operation this is */	int (*opve_impl) __P((void *));	/* code implementing this operation */};struct vnodeopv_desc {			/* ptr to the ptr to the vector where op should go */	int (***opv_desc_vector_p) __P((void *));	struct vnodeopv_entry_desc *opv_desc_ops;   /* null terminated list */};/* * A default routine which just returns an error. */int vn_default_error __P((void *));/* * A generic structure. * This can be used by bypass routines to identify generic arguments. */struct vop_generic_args {	struct vnodeop_desc *a_desc;	/* other random data follows, presumably */};/* * VOCALL calls an op given an ops vector.  We break it out because BSD's * vclean changes the ops vector and then wants to call ops with the old * vector. *//* * actually, vclean doesn't use it anymore, but nfs does, * for device specials and fifos. */#define VOCALL(OPSV,OFF,AP) (( *((OPSV)[(OFF)])) (AP))/* * This call works for vnodes in the kernel. */#define VCALL(VP,OFF,AP) VOCALL((VP)->v_op,(OFF),(AP))#define VDESC(OP) (& __CONCAT(OP,_desc))#define VOFFSET(OP) (VDESC(OP)->vdesc_offset)/* * Finally, include the default set of vnode operations. */#include <sys/vnode_if.h>/* * Public vnode manipulation functions. */struct file;struct filedesc;struct mount;struct nameidata;struct proc;struct stat;struct ucred;struct uio;struct vattr;struct vnode;int 	bdevvp __P((dev_t dev, struct vnode **vpp));int 	cdevvp __P((dev_t dev, struct vnode **vpp));int 	getnewvnode __P((enum vtagtype tag, struct mount *mp,			 int (**vops) __P((void *)), struct vnode **vpp));void	ungetnewvnode __P((struct vnode *));int	getvnode __P((struct filedesc *fdp, int fd, struct file **fpp));void	vfs_getnewfsid __P((struct mount *));int	speedup_syncer __P((void));void 	vattr_null __P((struct vattr *vap));int 	vcount __P((struct vnode *vp));void	vclean __P((struct vnode *, int, struct proc *));int	vfinddev __P((dev_t, enum vtype, struct vnode **));void	vflushbuf __P((struct vnode *vp, int sync));int	vflush __P((struct mount *mp, struct vnode *vp, int flags));void	vntblinit __P((void));void	vwakeup __P((struct buf *));void	vdevgone __P((int, int, int, enum vtype));int 	vget __P((struct vnode *vp, int lockflag));void 	vgone __P((struct vnode *vp));void	vgonel __P((struct vnode *vp, struct proc *p));int	vinvalbuf __P((struct vnode *vp, int save, struct ucred *cred,	    struct proc *p, int slpflag, int slptimeo));int	vtruncbuf __P((struct vnode *vp, daddr_t lbn,	    int slpflag, int slptimeo));void	vprint __P((char *label, struct vnode *vp));int	vrecycle __P((struct vnode *vp, struct simplelock *inter_lkp,	    struct proc *p));int	vn_bwrite __P((void *ap));int 	vn_close __P((struct vnode *vp,	    int flags, struct ucred *cred, struct proc *p));int 	vn_closefile __P((struct file *fp, struct proc *p));int	vn_ioctl __P((struct file *fp, u_long com, caddr_t data,	    struct proc *p));int	vn_fcntl __P((struct file *fp, u_int com, caddr_t data,	    struct proc *p));int	vn_lock __P((struct vnode *vp, int flags));u_int	vn_setrecurse __P((struct vnode *vp));void	vn_restorerecurse __P((struct vnode *vp, u_int flags));int 	vn_open __P((struct nameidata *ndp, int fmode, int cmode));int 	vn_rdwr __P((enum uio_rw rw, struct vnode *vp, caddr_t base,	    int len, off_t offset, enum uio_seg segflg, int ioflg,	    struct ucred *cred, size_t *aresid, struct proc *p));int	vn_read __P((struct file *fp, off_t *offset, struct uio *uio,	    struct ucred *cred, int flags));int	vn_readdir __P((struct file *fp, char *buf, int segflg, u_int count,	    int *done, struct proc *p, off_t **cookies, int *ncookies));int	vn_poll __P((struct file *fp, int events, struct proc *p));int	vn_stat __P((struct vnode *vp, struct stat *sb, struct proc *p));void	vn_syncer_add_to_worklist __P((struct vnode *vp, int delay));void	vn_syncer_remove_from_worklist __P((struct vnode *vp));int	vn_write __P((struct file *fp, off_t *offset, struct uio *uio,	    struct ucred *cred, int flags));int	vn_writechk __P((struct vnode *vp));void	vn_marktext __P((struct vnode *vp));int	vn_isunder __P((struct vnode *dvp, struct vnode *rvp, struct proc *p));struct vnode *	checkalias __P((struct vnode *vp, dev_t nvp_rdev, struct mount *mp));void 	vput __P((struct vnode *vp));void 	vrele __P((struct vnode *vp));int	vaccess __P((enum vtype type, mode_t file_mode, uid_t uid, gid_t gid,		     mode_t acc_mode, struct ucred *cred));#ifdef DDBvoid	vfs_vnode_print __P((struct vnode *, int, void (*)(const char *, ...)));#endif /* DDB */#endif /* _KERNEL */#endif /* !_SYS_VNODE_H_ */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?