diff options
author | fjoe <fjoe@FreeBSD.org> | 2005-05-04 12:46:43 +0000 |
---|---|---|
committer | fjoe <fjoe@FreeBSD.org> | 2005-05-04 12:46:43 +0000 |
commit | 5542bd31ad4b03bd09d973ddb03a5b35664bbaea (patch) | |
tree | f1eda1148c9c5f78f2b700724617004e1ae5e6ad /sbin/kldstat | |
parent | c93d1b9f9384d160c5e48411d9ae83019ace5897 (diff) | |
download | FreeBSD-src-5542bd31ad4b03bd09d973ddb03a5b35664bbaea.zip FreeBSD-src-5542bd31ad4b03bd09d973ddb03a5b35664bbaea.tar.gz |
Add -m option (find module using modfind() and stat it).
Diffstat (limited to 'sbin/kldstat')
-rw-r--r-- | sbin/kldstat/kldstat.8 | 10 | ||||
-rw-r--r-- | sbin/kldstat/kldstat.c | 26 |
2 files changed, 31 insertions, 5 deletions
diff --git a/sbin/kldstat/kldstat.8 b/sbin/kldstat/kldstat.8 index 77d933d..b2b72c2 100644 --- a/sbin/kldstat/kldstat.8 +++ b/sbin/kldstat/kldstat.8 @@ -35,7 +35,9 @@ .Nm .Op Fl v .Op Fl i Ar id -.Op Fl n Ar name +.Op Fl n Ar filename +.Nm +.Op Fl m Ar modname .Sh DESCRIPTION The .Nm @@ -48,8 +50,10 @@ The following options are available: Be more verbose. .It Fl i Ar id Display the status of only the file with this ID. -.It Fl n Ar name -Display the status of only the file with this name. +.It Fl n Ar filename +Display the status of only the file with this filename. +.It Fl m Ar modname +Display the status of only the module with this modname. .El .Sh EXIT STATUS .Ex -std 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); |