summaryrefslogtreecommitdiff
path: root/usr.sbin/pstat
diff options
context:
space:
mode:
authormlelstv <mlelstv@NetBSD.org>2009-09-16 07:27:41 +0000
committermlelstv <mlelstv@NetBSD.org>2009-09-16 07:27:41 +0000
commitd2979fb02a62dfb0cd5b9165e5488e9afe9b6701 (patch)
tree7d7f3ce3eb44f83defa830d245b0268b124ef783 /usr.sbin/pstat
parentcdca6f8c2925acf9a4211d27d0866fdd8b2ad623 (diff)
Distinguish between UFS1 and UFS2 inodes by reading the ufsmount structure,
the previous heuristic of comparing the size fields of inode and dinode failed.
Diffstat (limited to 'usr.sbin/pstat')
-rw-r--r--usr.sbin/pstat/pstat.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/usr.sbin/pstat/pstat.c b/usr.sbin/pstat/pstat.c
index 8e570d5b161..a3dcdf5c4b6 100644
--- a/usr.sbin/pstat/pstat.c
+++ b/usr.sbin/pstat/pstat.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pstat.c,v 1.114 2009/04/18 08:05:18 lukem Exp $ */
+/* $NetBSD: pstat.c,v 1.115 2009/09/16 07:27:41 mlelstv Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1991, 1993, 1994\
#if 0
static char sccsid[] = "@(#)pstat.c 8.16 (Berkeley) 5/9/95";
#else
-__RCSID("$NetBSD: pstat.c,v 1.114 2009/04/18 08:05:18 lukem Exp $");
+__RCSID("$NetBSD: pstat.c,v 1.115 2009/09/16 07:27:41 mlelstv Exp $");
#endif
#endif /* not lint */
@@ -52,11 +52,12 @@ __RCSID("$NetBSD: pstat.c,v 1.114 2009/04/18 08:05:18 lukem Exp $");
#include <sys/ucred.h>
#include <stdbool.h>
#define _KERNEL
-#include <sys/file.h>
-#include <ufs/ufs/inode.h>
#define NFS
#include <sys/mount.h>
#undef NFS
+#include <sys/file.h>
+#include <ufs/ufs/inode.h>
+#include <ufs/ufs/ufsmount.h>
#include <sys/uio.h>
#include <miscfs/genfs/layer.h>
#undef _KERNEL
@@ -476,6 +477,7 @@ ufs_print(struct vnode *vp, int ovflw)
struct ufs1_dinode dp1;
struct ufs2_dinode dp2;
} dip;
+ struct ufsmount ump;
char flags[sizeof(ufs_flags) / sizeof(ufs_flags[0])];
char dev[4 + 1 + 7 + 1]; /* 12bit marjor + 20bit minor */
char *name;
@@ -483,13 +485,15 @@ ufs_print(struct vnode *vp, int ovflw)
dev_t rdev;
KGETRET(VTOI(vp), &inode, sizeof(struct inode), "vnode's inode");
- KGETRET(ip->i_din.ffs1_din, &dip, sizeof (struct ufs1_dinode),
- "inode's dinode");
+ KGETRET(ip->i_ump, &ump, sizeof(struct ufsmount),
+ "vnode's mount point");
- if (ip->i_size == dip.dp1.di_size)
+ if (ump.um_fstype == UFS1) {
+ KGETRET(ip->i_din.ffs1_din, &dip, sizeof (struct ufs1_dinode),
+ "inode's dinode");
rdev = dip.dp1.di_rdev;
- else {
- KGETRET(ip->i_din.ffs1_din, &dip, sizeof (struct ufs2_dinode),
+ } else {
+ KGETRET(ip->i_din.ffs2_din, &dip, sizeof (struct ufs2_dinode),
"inode's UFS2 dinode");
rdev = dip.dp2.di_rdev;
}