From 4eee8de77cb0ff65f6c3b454e5c7523e489bb586 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Wed, 31 Jul 2002 12:19:49 +0000 Subject: [PATCH] Introduce struct xvnode, which will be used instead of struct vnode for sysctl purposes. Also add two fields to struct vnode, v_cachedfs and v_cachedid, which hold the vnode's device and file id and are filled in by vn_open_cred() and vn_stat(). Sponsored by: DARPA, NAI Labs --- sys/kern/vfs_vnops.c | 7 +++++++ sys/sys/vnode.h | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 218dd723cd3b..c759196196c7 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -209,6 +209,10 @@ vn_open_cred(ndp, flagp, cmode, cred) goto bad; } } + if ((error = VOP_GETATTR(vp, vap, cred, td)) == 0) { + vp->v_cachedfs = vap->va_fsid; + vp->v_cachedid = vap->va_fileid; + } if ((error = VOP_OPEN(vp, fmode, cred, td)) != 0) goto bad; /* @@ -567,6 +571,9 @@ vn_stat(vp, sb, td) if (error) return (error); + vp->v_cachedfs = vap->va_fsid; + vp->v_cachedid = vap->va_fileid; + /* * Zero the spare stat fields */ diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 6f1857c07d3e..524483625c4c 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -146,6 +146,8 @@ struct vnode { const char *filename; /* Source file doing locking */ int line; /* Line number doing locking */ #endif + udev_t v_cachedfs; /* cached fs id */ + ino_t v_cachedid; /* cached file id */ }; #define v_mountedhere v_un.vu_mountedhere #define v_socket v_un.vu_socket @@ -153,6 +155,36 @@ struct vnode { #define v_specnext v_un.vu_spec.vu_specnext #define v_fifoinfo v_un.vu_fifoinfo +/* + * Userland version of struct vnode, for sysctl. + */ +struct xvnode { + size_t xv_size; /* sizeof(struct xvnode) */ + void *xv_vnode; /* address of real vnode */ + u_long xv_flag; /* vnode flags */ + int xv_usecount; /* reference count of users */ + int xv_writecount; /* reference count of writers */ + int xv_holdcnt; /* page & buffer references */ + u_long xv_id; /* capability identifier */ + void *xv_mount; /* address of parent mount */ + long xv_numoutput; /* num of writes in progress */ + enum vtype xv_type; /* vnode type */ + union { + void *xvu_socket; /* socket, if VSOCK */ + void *xvu_fifo; /* fifo, if VFIFO */ + udev_t xvu_rdev; /* maj/min, if VBLK/VCHR */ + struct { + udev_t xvu_dev; /* device, if VDIR/VREG/VLNK */ + ino_t xvu_ino; /* id, if VDIR/VREG/VLNK */ + }; + } xv_un; +}; +#define xv_socket xv_un.xvu_socket +#define xv_fifo xv_un.xvu_fifo +#define xv_rdev xv_un.xvu_rdev +#define xv_dev xv_un.xvu_dev +#define xv_ino xv_un.xvu_ino + #define VN_POLLEVENT(vp, events) \ do { \ if ((vp)->v_pollinfo != NULL && \