summaryrefslogtreecommitdiffstats
path: root/sbin/kldstat/kldstat.c
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/kldstat/kldstat.c')
-rw-r--r--sbin/kldstat/kldstat.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/sbin/kldstat/kldstat.c b/sbin/kldstat/kldstat.c
index ce5ebf4..fd8f220 100644
--- a/sbin/kldstat/kldstat.c
+++ b/sbin/kldstat/kldstat.c
@@ -76,7 +76,7 @@ static void printfile(int fileid, int verbose)
static void
usage(void)
{
- fprintf(stderr, "usage: kldstat [-v] [-i id] [-n name]\n");
+ fprintf(stderr, "usage: kldstat [-v] [-i id] [-n name] [-m name]\n");
exit(1);
}
@@ -87,15 +87,19 @@ main(int argc, char** argv)
int verbose = 0;
int fileid = 0;
char* filename = NULL;
+ char* modname = NULL;
char* p;
- while ((c = getopt(argc, argv, "i:n:v")) != -1)
+ while ((c = getopt(argc, argv, "i:m:n:v")) != -1)
switch (c) {
case 'i':
fileid = (int)strtoul(optarg, &p, 10);
if (*p != '\0')
usage();
break;
+ case 'm':
+ modname = optarg;
+ break;
case 'n':
filename = optarg;
break;
@@ -111,6 +115,24 @@ main(int argc, char** argv)
if (argc != 0)
usage();
+ if (modname != NULL) {
+ int modid;
+ struct module_stat stat;
+
+ if ((modid = modfind(modname)) < 0)
+ err(1, "can't find module %s", modname);
+
+ stat.version = sizeof(struct module_stat);
+ if (modstat(modid, &stat) < 0)
+ warn("can't stat module id %d", modid);
+ else {
+ printf("Id Refs Name\n");
+ printf("%3d %4d %s\n", stat.id, stat.refs, stat.name);
+ }
+
+ return 0;
+ }
+
if (filename != NULL) {
if ((fileid = kldfind(filename)) < 0)
err(1, "can't find file %s", filename);
OpenPOWER on IntegriCloud