summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2002-07-31 12:19:49 +0000
committerdes <des@FreeBSD.org>2002-07-31 12:19:49 +0000
commit3562e9781922827a5053317c2ecd89cf8da93ff3 (patch)
tree8895b6491e9be59df954e6ec8571d1cd5b856c84 /sys
parent43aa4c758e77b281df2f306b5025c1ea7e0030c0 (diff)
downloadFreeBSD-src-3562e9781922827a5053317c2ecd89cf8da93ff3.zip
FreeBSD-src-3562e9781922827a5053317c2ecd89cf8da93ff3.tar.gz
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
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/vfs_vnops.c7
-rw-r--r--sys/sys/vnode.h32
2 files changed, 39 insertions, 0 deletions
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index 218dd72..c759196 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -209,6 +209,10 @@ restart:
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 6f1857c..5244836 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 && \
OpenPOWER on IntegriCloud