vnode.h

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

H
433
字号
#define VNODEOP_SET(f) DATA_SET(MODVNOPS,f)#else#define VNODEOP_SET(f) DATA_SET(vfs_opv_descs_,f)#endif/* * Global vnode data. */extern	struct vnode *rootvnode;	/* root (i.e. "/") vnode */extern	int desiredvnodes;		/* number of vnodes desired */extern	int prtactive;			/* nonzero to call vprint() */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 */extern void	(*lease_check) __P((struct vnode *vp, struct proc *p,				    struct ucred *ucred, int flag));extern void	(*lease_updatetime) __P((int deltat));#ifdef NFS#ifdef NQNFS#define	LEASE_CHECK(vp, p, cred, flag)	lease_check((vp), (p), (cred), (flag))#define	LEASE_UPDATETIME(dt)		lease_updatetime(dt)#else#define LEASE_CHECK(vp, p, cred, flag)#define LEASE_UPDATETIME(dt)#endif /* NQNFS */#else#define LEASE_CHECK(vp, p, cred, flag) \	do { if(lease_check) lease_check((vp), (p), (cred), (flag)); } while(0)#define LEASE_UPDATETIME(dt) \	do { if(lease_updatetime) lease_updatetime(dt); } while(0)#endif /* NFS */#endif /* KERNEL *//* * Mods for exensibility. *//* * Flags for vdesc_flags: */#define VDESC_MAX_VPS		16/* Low order 16 flag bits are reserved for willrele flags for vp arguments. */#define VDESC_VP0_WILLRELE	0x0001#define VDESC_VP1_WILLRELE	0x0002#define VDESC_VP2_WILLRELE	0x0004#define VDESC_VP3_WILLRELE	0x0008#define VDESC_NOMAP_VPP		0x0100#define VDESC_VPP_WILLRELE	0x0200/* * 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[];/* * 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)();		/* code implementing this operation */};struct vnodeopv_desc {			/* ptr to the ptr to the vector where op should go */	int (***opv_desc_vector_p)();	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. */#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 <vnode_if.h>/* * Public vnode manipulation functions. */struct componentname;struct file;struct mount;struct nameidata;struct proc;struct stat;struct ucred;struct uio;struct vattr;struct vnode;struct vop_bwrite_args;int 	bdevvp __P((dev_t dev, struct vnode **vpp));/* cache_* may belong in namei.h. */void	cache_enter __P((struct vnode *dvp, struct vnode *vp,	    struct componentname *cnp));int	cache_lookup __P((struct vnode *dvp, struct vnode **vpp,	    struct componentname *cnp));void	cache_purge __P((struct vnode *vp));void	cache_purgevfs __P((struct mount *mp));int 	getnewvnode __P((enum vtagtype tag,	    struct mount *mp, int (**vops)(), struct vnode **vpp));int	vinvalbuf __P((struct vnode *vp, int save, struct ucred *cred,	    struct proc *p, int slpflag, int slptimeo));void 	vattr_null __P((struct vattr *vap));int 	vcount __P((struct vnode *vp));int	vfinddev __P((dev_t dev, enum vtype type, struct vnode **vpp));int 	vget __P((struct vnode *vp, int lockflag));void 	vgone __P((struct vnode *vp));void 	vgoneall __P((struct vnode *vp));int	vn_bwrite __P((struct vop_bwrite_args *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, int com, caddr_t data, struct proc *p));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, int *aresid, struct proc *p));int	vn_read __P((struct file *fp, struct uio *uio, struct ucred *cred));int	vn_select __P((struct file *fp, int which, struct proc *p));int	vn_stat __P((struct vnode *vp, struct stat *sb, struct proc *p));int	vn_write __P((struct file *fp, struct uio *uio, struct ucred *cred));struct vnode *	checkalias __P((struct vnode *vp, dev_t nvp_rdev, struct mount *mp));void	vprint __P((char *, struct vnode *));void 	vput __P((struct vnode *vp));void 	vref __P((struct vnode *vp));void 	vrele __P((struct vnode *vp));int 	vn_writechk __P((struct vnode *vp));void	vfs_opv_init __P((struct vnodeopv_desc **));#endif /* KERNEL */#endif /* !_SYS_VNODE_H_ */

⌨️ 快捷键说明

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