Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/fstat - remove bogus casts



details:   https://anonhg.NetBSD.org/src/rev/9e2fd1119329
branches:  trunk
changeset: 769447:9e2fd1119329
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Sep 10 18:35:28 2011 +0000

description:
- remove bogus casts
- print recycled vnode flags

diffstat:

 usr.bin/fstat/fstat.c |  30 +++++++++++++++++++++---------
 1 files changed, 21 insertions(+), 9 deletions(-)

diffs (102 lines):

diff -r cce8aaaf693f -r 9e2fd1119329 usr.bin/fstat/fstat.c
--- a/usr.bin/fstat/fstat.c     Sat Sep 10 18:34:54 2011 +0000
+++ b/usr.bin/fstat/fstat.c     Sat Sep 10 18:35:28 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fstat.c,v 1.91 2011/09/03 13:24:19 christos Exp $      */
+/*     $NetBSD: fstat.c,v 1.92 2011/09/10 18:35:28 christos Exp $      */
 
 /*-
  * Copyright (c) 1988, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)fstat.c    8.3 (Berkeley) 5/2/95";
 #else
-__RCSID("$NetBSD: fstat.c,v 1.91 2011/09/03 13:24:19 christos Exp $");
+__RCSID("$NetBSD: fstat.c,v 1.92 2011/09/10 18:35:28 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -106,6 +106,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <err.h>
+#include <util.h>
 
 #include "fstat.h"
 
@@ -358,7 +359,7 @@
         * ktrace vnode, if one
         */
        if (p->p_tracep)
-               ftrans((struct file *)(intptr_t)p->p_tracep, TRACE);
+               ftrans(p->p_tracep, TRACE);
 #endif
        /*
         * open files
@@ -398,15 +399,15 @@
        }
        switch (file.f_type) {
        case DTYPE_VNODE:
-               vtrans((struct vnode *)file.f_data, i, file.f_flag);
+               vtrans(file.f_data, i, file.f_flag);
                break;
        case DTYPE_SOCKET:
                if (checkfile == 0)
-                       socktrans((struct socket *)file.f_data, i);
+                       socktrans(file.f_data, i);
                break;
        case DTYPE_PIPE:
                if (checkfile == 0)
-                       ptrans(&file, (struct pipe *)file.f_data, i);
+                       ptrans(&file, file.f_data, i);
                break;
        case DTYPE_MISC:
        case DTYPE_KQUEUE:
@@ -423,17 +424,22 @@
        }
 }
 
+static const char dead[] = "dead";
+
 static const char *
 vfilestat(struct vnode *vp, struct filestat *fsp)
 {
        const char *badtype = NULL;
 
-       if (vp->v_type == VNON || vp->v_tag == VT_NON)
+       if (vp->v_type == VNON)
                badtype = "none";
        else if (vp->v_type == VBAD)
                badtype = "bad";
        else
                switch (vp->v_tag) {
+               case VT_NON:
+                       badtype = dead;
+                       break;
                case VT_UFS:
                case VT_LFS:
                case VT_MFS:
@@ -502,7 +508,7 @@
                int fsmatch = 0;
                DEVS *d;
 
-               if (badtype)
+               if (badtype && badtype != dead)
                        return;
                for (d = devs; d != NULL; d = d->next)
                        if (d->fsid == fst.fsid) {
@@ -516,7 +522,13 @@
                        return;
        }
        PREFIX(i);
-       if (badtype) {
+       if (badtype == dead) {
+               char buf[1024];
+               (void)snprintb(buf, sizeof(buf), VNODE_FLAGBITS,
+                   vn.v_iflag | vn.v_vflag | vn.v_uflag);
+               (void)printf(" flags %s\n", buf);
+               return;
+       } else if (badtype) {
                (void)printf(" -         -  %10s    -\n", badtype);
                return;
        }



Home | Main Index | Thread Index | Old Index