Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/fstat New -A option. Add an output column with the a...
details: https://anonhg.NetBSD.org/src/rev/fd0b060fd92e
branches: trunk
changeset: 325252:fd0b060fd92e
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Sun Dec 15 08:16:24 2013 +0000
description:
New -A option. Add an output column with the address of the
kernel object (vnode or file) that can be matched with prstat(8) output.
diffstat:
usr.bin/fstat/fstat.1 | 9 +++++++--
usr.bin/fstat/fstat.c | 29 ++++++++++++++++++++---------
2 files changed, 27 insertions(+), 11 deletions(-)
diffs (148 lines):
diff -r 81da6452da66 -r fd0b060fd92e usr.bin/fstat/fstat.1
--- a/usr.bin/fstat/fstat.1 Sun Dec 15 07:52:53 2013 +0000
+++ b/usr.bin/fstat/fstat.1 Sun Dec 15 08:16:24 2013 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: fstat.1,v 1.31 2012/10/03 19:35:08 wiz Exp $
+.\" $NetBSD: fstat.1,v 1.32 2013/12/15 08:16:24 mlelstv Exp $
.\"
.\" Copyright (c) 1987, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -37,7 +37,7 @@
.Nd display status of open files
.Sh SYNOPSIS
.Nm
-.Op Fl fnv
+.Op Fl fnAv
.Op Fl M Ar core
.Op Fl N Ar system
.Op Fl p Ar pid
@@ -87,6 +87,11 @@
Report all files open by the specified process.
.It Fl u
Report all files open by the specified user.
+.It Fl A
+Add an output column with the address of the kernel object (vnode or file),
+that can be matched with
+.Xr pstat 8
+output.
.It Fl v
Verbose mode.
Print error messages upon failures to locate particular
diff -r 81da6452da66 -r fd0b060fd92e usr.bin/fstat/fstat.c
--- a/usr.bin/fstat/fstat.c Sun Dec 15 07:52:53 2013 +0000
+++ b/usr.bin/fstat/fstat.c Sun Dec 15 08:16:24 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fstat.c,v 1.103 2013/10/19 15:56:05 christos Exp $ */
+/* $NetBSD: fstat.c,v 1.104 2013/12/15 08:16:24 mlelstv 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.103 2013/10/19 15:56:05 christos Exp $");
+__RCSID("$NetBSD: fstat.c,v 1.104 2013/12/15 08:16:24 mlelstv Exp $");
#endif
#endif /* not lint */
@@ -133,6 +133,7 @@
uflg; /* show files open by a particular (effective) user */
static int checkfile; /* true if restricting to particular files or filesystems */
static int nflg; /* (numerical) display f.s. and rdev as dev_t */
+static int Aflg; /* prefix with address of file structure */
int vflg; /* display errors in locating kernel data objects etc... */
static fdfile_t **ofiles; /* buffer of pointers to file structures */
@@ -175,7 +176,7 @@
static int ufs_filestat(struct vnode *, struct filestat *);
static void usage(void) __dead;
static const char *vfilestat(struct vnode *, struct filestat *);
-static void vtrans(struct vnode *, int, int);
+static void vtrans(struct vnode *, int, int, long);
static void ftrans(fdfile_t *, int);
static void ptrans(struct file *, struct pipe *, int);
static void kdriver_init(void);
@@ -195,7 +196,7 @@
arg = 0;
what = KERN_PROC_ALL;
nlistf = memf = NULL;
- while ((ch = getopt(argc, argv, "fnp:u:vN:M:")) != -1)
+ while ((ch = getopt(argc, argv, "fnAp:u:vN:M:")) != -1)
switch((char)ch) {
case 'f':
fsflg = 1;
@@ -209,6 +210,9 @@
case 'n':
nflg = 1;
break;
+ case 'A':
+ Aflg = 1;
+ break;
case 'p':
if (pflg++)
usage();
@@ -277,6 +281,8 @@
if ((p = kvm_getproc2(kd, what, arg, sizeof *p, &cnt)) == NULL) {
errx(1, "%s", kvm_geterr(kd));
}
+ if (Aflg)
+ (void)printf("%-*s ", 2*(int)(sizeof(void*)), "ADDR");
if (nflg)
(void)printf("%s",
"USER CMD PID FD DEV INUM MODE SZ|DV R/W");
@@ -444,11 +450,11 @@
* root directory vnode, if one
*/
if (cwdi.cwdi_rdir)
- vtrans(cwdi.cwdi_rdir, RDIR, FREAD);
+ vtrans(cwdi.cwdi_rdir, RDIR, FREAD, (long)cwdi.cwdi_rdir);
/*
* current working directory vnode
*/
- vtrans(cwdi.cwdi_cdir, CDIR, FREAD);
+ vtrans(cwdi.cwdi_cdir, CDIR, FREAD, (long)cwdi.cwdi_cdir);
#if 0
/*
* Disable for now, since p->p_tracep appears to point to a ktr_desc *
@@ -496,9 +502,12 @@
i, fdfile.ff_file, Pid);
return;
}
+ if (Aflg && file.f_type != DTYPE_VNODE)
+ (void)printf("%*lx ",
+ 2*(int)(sizeof(void*)), (long)fdfile.ff_file);
switch (file.f_type) {
case DTYPE_VNODE:
- vtrans(file.f_data, i, file.f_flag);
+ vtrans(file.f_data, i, file.f_flag, (long)fdfile.ff_file);
break;
case DTYPE_SOCKET:
if (checkfile == 0)
@@ -590,7 +599,7 @@
}
static void
-vtrans(struct vnode *vp, int i, int flag)
+vtrans(struct vnode *vp, int i, int flag, long addr)
{
struct vnode vn;
struct filestat fst;
@@ -620,6 +629,8 @@
if (fsmatch == 0 || (filename == NULL && fsflg == 0))
return;
}
+ if (Aflg)
+ (void)printf("%*lx ", 2*(int)(sizeof(void*)), addr);
PREFIX(i);
if (badtype == dead) {
char buf[1024];
@@ -1314,7 +1325,7 @@
static void
usage(void)
{
- (void)fprintf(stderr, "Usage: %s [-fnv] [-p pid] [-u user] "
+ (void)fprintf(stderr, "Usage: %s [-Afnv] [-p pid] [-u user] "
"[-N system] [-M core] [file ...]\n", getprogname());
exit(1);
}
Home |
Main Index |
Thread Index |
Old Index