Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/fstat Print the interface for bpf.



details:   https://anonhg.NetBSD.org/src/rev/d7b946c3f33d
branches:  trunk
changeset: 820129:d7b946c3f33d
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Dec 30 21:08:23 2016 +0000

description:
Print the interface for bpf.

diffstat:

 usr.bin/fstat/fstat.c |  14 +++++++-------
 usr.bin/fstat/misc.c  |  19 ++++++++++++++++---
 2 files changed, 23 insertions(+), 10 deletions(-)

diffs (92 lines):

diff -r 62c3b1426a65 -r d7b946c3f33d usr.bin/fstat/fstat.c
--- a/usr.bin/fstat/fstat.c     Fri Dec 30 19:55:46 2016 +0000
+++ b/usr.bin/fstat/fstat.c     Fri Dec 30 21:08:23 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fstat.c,v 1.110 2015/12/22 23:35:21 christos Exp $     */
+/*     $NetBSD: fstat.c,v 1.111 2016/12/30 21:08:23 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.110 2015/12/22 23:35:21 christos Exp $");
+__RCSID("$NetBSD: fstat.c,v 1.111 2016/12/30 21:08:23 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -651,23 +651,23 @@
                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);
+               (void)printf("  flags %s\n", buf);
                return;
        } else if (badtype) {
-               (void)printf(" -         -  %10s    -\n", badtype);
+               (void)printf("  -         -  %10s    -\n", badtype);
                return;
        }
        if (nflg)
-               (void)printf(" %2llu,%-2llu",
+               (void)printf("  %2llu,%-2llu",
                    (unsigned long long)major(fst.fsid),
                    (unsigned long long)minor(fst.fsid));
        else
-               (void)printf(" %-8s", getmnton(vn.v_mount));
+               (void)printf("  %-8s", getmnton(vn.v_mount));
        if (nflg)
                (void)snprintf(mode, sizeof mode, "%o", fst.mode);
        else
                strmode(fst.mode, mode);
-       (void)printf(" %7"PRIu64" %*s", fst.fileid, nflg ? 5 : 10, mode);
+       (void)printf("  %7"PRIu64" %*s", fst.fileid, nflg ? 5 : 10, mode);
        switch (vn.v_type) {
        case VBLK:
        case VCHR: {
diff -r 62c3b1426a65 -r d7b946c3f33d usr.bin/fstat/misc.c
--- a/usr.bin/fstat/misc.c      Fri Dec 30 19:55:46 2016 +0000
+++ b/usr.bin/fstat/misc.c      Fri Dec 30 21:08:23 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: misc.c,v 1.16 2016/01/23 16:12:03 christos Exp $       */
+/*     $NetBSD: misc.c,v 1.17 2016/12/30 21:08:23 christos Exp $       */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: misc.c,v 1.16 2016/01/23 16:12:03 christos Exp $");
+__RCSID("$NetBSD: misc.c,v 1.17 2016/12/30 21:08:23 christos Exp $");
 
 #include <stdbool.h>
 #include <sys/param.h>
@@ -113,12 +113,25 @@
 p_bpf(struct file *f)
 {
        struct bpf_d bpf;
+       struct bpf_if bi;
+       struct ifnet ifn;
+
+       strlcpy(ifn.if_xname, "???", sizeof(ifn.if_xname));
 
        if (!KVM_READ(f->f_data, &bpf, sizeof(bpf))) {
                dprintf("can't read bpf at %p for pid %d", f->f_data, Pid);
                return 0;
        }
-       (void)printf("* bpf rec=%lu, dr=%lu, cap=%lu, pid=%lu",
+       if (bpf.bd_bif != NULL) {
+               if (!KVM_READ(bpf.bd_bif, &bi, sizeof(bi)))
+                       dprintf("can't read bpf interface at %p for pid %d",
+                           bpf.bd_bif, Pid);
+               if (bi.bif_ifp != NULL)
+                       if (!KVM_READ(bi.bif_ifp, &ifn, sizeof(ifn)))
+                               dprintf("can't read net interfsace"
+                                   " at %p for pid %d", bi.bif_ifp, Pid);
+       }
+       (void)printf("* bpf@%s rec=%lu, dr=%lu, cap=%lu, pid=%lu", ifn.if_xname,
            bpf.bd_rcount, bpf.bd_dcount, bpf.bd_ccount,
            (unsigned long)bpf.bd_pid);
        if (bpf.bd_promisc)



Home | Main Index | Thread Index | Old Index