Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/pstat Distinguish between UFS1 and UFS2 inodes by r...



details:   https://anonhg.NetBSD.org/src/rev/5d6c1ce63287
branches:  trunk
changeset: 747457:5d6c1ce63287
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Wed Sep 16 07:27:41 2009 +0000

description:
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:

 usr.sbin/pstat/pstat.c |  22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)

diffs (62 lines):

diff -r 7a82ea951e3d -r 5d6c1ce63287 usr.sbin/pstat/pstat.c
--- a/usr.sbin/pstat/pstat.c    Wed Sep 16 06:10:52 2009 +0000
+++ b/usr.sbin/pstat/pstat.c    Wed Sep 16 07:27:41 2009 +0000
@@ -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 @@
 #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 @@
 #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 @@
                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 @@
        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;
        }



Home | Main Index | Thread Index | Old Index