diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1999-07-01 21:41:59 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1999-07-01 21:41:59 +0000 |
commit | 4b4956e1eedc8a45854598167564ea8bebf37011 (patch) | |
tree | 2a5c5b40da9171ac0bc34cdf87d9d9f43c17a496 /usr.bin | |
parent | 1e54d6354b93f11af29b6ea04c5015b359cfa39a (diff) |
pretty good attempt at supporting nullfs
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/fstat/fstat.c | 87 |
1 files changed, 84 insertions, 3 deletions
diff --git a/usr.bin/fstat/fstat.c b/usr.bin/fstat/fstat.c index 7d982c87341..c99d12b1b28 100644 --- a/usr.bin/fstat/fstat.c +++ b/usr.bin/fstat/fstat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fstat.c,v 1.22 1999/04/30 02:26:59 art Exp $ */ +/* $OpenBSD: fstat.c,v 1.23 1999/07/01 21:41:58 deraadt Exp $ */ /*- * Copyright (c) 1988, 1993 @@ -41,7 +41,7 @@ static char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)fstat.c 8.1 (Berkeley) 6/6/93";*/ -static char *rcsid = "$OpenBSD: fstat.c,v 1.22 1999/04/30 02:26:59 art Exp $"; +static char *rcsid = "$OpenBSD: fstat.c,v 1.23 1999/07/01 21:41:58 deraadt Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -57,13 +57,14 @@ static char *rcsid = "$OpenBSD: fstat.c,v 1.22 1999/04/30 02:26:59 art Exp $"; #include <sys/unpcb.h> #include <sys/sysctl.h> #include <sys/filedesc.h> +#include <sys/mount.h> #define _KERNEL #include <sys/file.h> #include <ufs/ufs/quota.h> #include <ufs/ufs/inode.h> +#include <miscfs/nullfs/null.h> #undef _KERNEL #define NFS -#include <sys/mount.h> #include <nfs/nfsproto.h> #include <nfs/rpcv2.h> #include <nfs/nfs.h> @@ -412,6 +413,10 @@ vtrans(vp, i, flag) if (!xfs_filestat(&vn, &fst)) badtype = "error"; break; + case VT_NULL: + if (!null_filestat(&vn, &fst)) + badtype = "error"; + break; default: { static char unknown[30]; sprintf(badtype = unknown, "?(%x)", vn.v_tag); @@ -604,6 +609,82 @@ xfs_filestat(vp, fsp) return 1; } +int +null_filestat(vp, fsp) + struct vnode *vp; + struct filestat *fsp; +{ + struct null_node node; + struct filestat fst; + struct vnode vn; + int fail = 1; + + memset(&fst, 0, sizeof fst); + + if (!KVM_READ(VTONULL(vp), &node, sizeof (node))) { + dprintf("can't read node at %p for pid %d", VTONULL(vp), Pid); + return 0; + } + + /* + * Attempt to find information that might be useful. + */ + if (node.null_lowervp) { + if (!KVM_READ(node.null_lowervp, &vn, sizeof (vn))) { + dprintf("can't read vnode at %p for pid %d", + node.null_lowervp, Pid); + return 0; + } + + fail = 0; + if (vn.v_type == VNON || vn.v_tag == VT_NON) + fail = 1; + else if (vn.v_type == VBAD) + fail = 1; + else + switch (vn.v_tag) { + case VT_UFS: + case VT_MFS: + if (!ufs_filestat(&vn, &fst)) + fail = 1; + break; + case VT_NFS: + if (!nfs_filestat(&vn, &fst)) + fail = 1; + break; + case VT_EXT2FS: + if (!ext2fs_filestat(&vn, &fst)) + fail = 1; + break; + case VT_ISOFS: + if (!isofs_filestat(&vn, &fst)) + fail = 1; + break; + case VT_MSDOSFS: + if (!msdos_filestat(&vn, &fst)) + fail = 1; + break; + case VT_XFS: + if (!xfs_filestat(&vn, &fst)) + fail = 1; + break; + default: + break; + } + } + + fsp->fsid = (long)node.null_vnode; + if (fail) + fsp->fileid = (long)node.null_lowervp; + else + fsp->fileid = fst.fileid; + fsp->mode = fst.mode; + fsp->size = fst.mode; + fsp->rdev = fst.mode; + + return 1; +} + char * getmnton(m) struct mount *m; |