Module Name:    src
Committed By:   christos
Date:           Fri Dec 30 21:08:23 UTC 2016

Modified Files:
        src/usr.bin/fstat: fstat.c misc.c

Log Message:
Print the interface for bpf.


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/usr.bin/fstat/fstat.c
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/fstat/misc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/fstat/fstat.c
diff -u src/usr.bin/fstat/fstat.c:1.110 src/usr.bin/fstat/fstat.c:1.111
--- src/usr.bin/fstat/fstat.c:1.110	Tue Dec 22 18:35:21 2015
+++ src/usr.bin/fstat/fstat.c	Fri Dec 30 16:08:23 2016
@@ -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 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #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 @@ vtrans(struct vnode *vp, int i, int flag
 		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: {

Index: src/usr.bin/fstat/misc.c
diff -u src/usr.bin/fstat/misc.c:1.16 src/usr.bin/fstat/misc.c:1.17
--- src/usr.bin/fstat/misc.c:1.16	Sat Jan 23 11:12:03 2016
+++ src/usr.bin/fstat/misc.c	Fri Dec 30 16:08:23 2016
@@ -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 @@ static int
 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)

Reply via email to