Source-Changes-HG archive

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

[src/trunk]: src/sbin/modstat By default, don't display the module load addre...



details:   https://anonhg.NetBSD.org/src/rev/4b0b059bbfd9
branches:  trunk
changeset: 812137:4b0b059bbfd9
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Wed Dec 02 00:56:09 2015 +0000

description:
By default, don't display the module load address.  Add a -k option
to restore display of this field.

diffstat:

 sbin/modstat/main.c    |  26 ++++++++++++++++++--------
 sbin/modstat/modstat.8 |   9 +++++++--
 2 files changed, 25 insertions(+), 10 deletions(-)

diffs (116 lines):

diff -r 25dc420fdce1 -r 4b0b059bbfd9 sbin/modstat/main.c
--- a/sbin/modstat/main.c       Wed Dec 02 00:28:24 2015 +0000
+++ b/sbin/modstat/main.c       Wed Dec 02 00:56:09 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.20 2015/11/04 16:04:55 christos Exp $       */
+/*     $NetBSD: main.c,v 1.21 2015/12/02 00:56:09 pgoyette Exp $       */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: main.c,v 1.20 2015/11/04 16:04:55 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.21 2015/12/02 00:56:09 pgoyette Exp $");
 #endif /* !lint */
 
 #include <sys/module.h>
@@ -41,6 +41,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <stdbool.h>
 
 #include "prog_ops.h"
 
@@ -80,16 +81,20 @@
        int ch, rc, modauto = 1;
        size_t maxnamelen = 16, i, modautolen;
        char loadable = '\0';
+       bool address = false;
 
        name = NULL;
 
-       while ((ch = getopt(argc, argv, "Aaen:")) != -1) {
+       while ((ch = getopt(argc, argv, "Aaekn:")) != -1) {
                switch (ch) {
                case 'A':                       /* FALLTHROUGH */
                case 'a':                       /* FALLTHROUGH */
                case 'e':
                        loadable = (char)ch;
                        break;
+               case 'k':
+                       address = true;
+                       break;
                case 'n':
                        name = optarg;
                        break;
@@ -179,9 +184,11 @@
                if (maxnamelen < namelen)
                        maxnamelen = namelen;
        }
-       printf("%-*s %-8s %-8s %-4s %-5s %-16s %-7s %s \n",
-           (int)maxnamelen, "NAME", "CLASS", "SOURCE", "FLAG", "REFS",
-           "ADDRESS", "SIZE", "REQUIRES");
+       printf("%-*s %-8s %-8s %-4s %-5s ",
+           (int)maxnamelen, "NAME", "CLASS", "SOURCE", "FLAG", "REFS");
+       if (address)
+               printf("%-16s ", "ADDRESS");
+       printf("%-7s %s \n", "SIZE", "REQUIRES");
        for (ms = iov.iov_base; len != 0; ms++, len--) {
                const char *class;
                const char *source;
@@ -208,10 +215,13 @@
                else
                        source = "UNKNOWN";
 
-               printf("%-*s %-8s %-8s %-4s %-5d %-16" PRIx64 " %-7s %s\n",
+               printf("%-*s %-8s %-8s %-4s %-5d ",
                    (int)maxnamelen, ms->ms_name, class, source, 
                    modflags[ms->ms_flags & (__arraycount(modflags) - 1)],
-                   ms->ms_refcnt, ms->ms_addr, sbuf, ms->ms_required);
+                   ms->ms_refcnt);
+               if (address)
+                       printf("%-16" PRIx64 " ", ms->ms_addr);
+               printf("%-7s %s\n", sbuf, ms->ms_required);
        }
 
        exit(EXIT_SUCCESS);
diff -r 25dc420fdce1 -r 4b0b059bbfd9 sbin/modstat/modstat.8
--- a/sbin/modstat/modstat.8    Wed Dec 02 00:28:24 2015 +0000
+++ b/sbin/modstat/modstat.8    Wed Dec 02 00:56:09 2015 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: modstat.8,v 1.18 2015/11/29 21:36:35 wiz Exp $
+.\" $NetBSD: modstat.8,v 1.19 2015/12/02 00:56:09 pgoyette Exp $
 .\"
 .\" Copyright (c) 1993 Christopher G. Demetriou
 .\" All rights reserved.
@@ -32,7 +32,7 @@
 .\"
 .\" <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
 .\"
-.Dd November 4, 2015
+.Dd December 2, 2015
 .Dt MODSTAT 8
 .Os
 .Sh NAME
@@ -63,6 +63,8 @@
 .Li kern.module.autoload .
 .It Fl e
 Tells you whether or not you may load a module at the moment.
+.It Fl k
+Display the module's kernel address (disabled by default).
 .It Fl n Ar name
 Display the status of only the module with this name.
 Please note that
@@ -107,6 +109,9 @@
 .It Li ADDRESS
 The kernel address at which the module is loaded.
 Builtin modules will show 0 here.
+This field is only displayed if the
+.Fl k
+option is specified.
 .It Li REQUIRES
 Additional modules that must be present.
 .El



Home | Main Index | Thread Index | Old Index