1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-02 08:42:48 +00:00

Add -m option (find module using modfind() and stat it).

This commit is contained in:
Max Khon 2005-05-04 12:46:43 +00:00
parent d70ba80285
commit 5d6d6d382f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=145861
2 changed files with 31 additions and 5 deletions

View File

@ -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

View File

@ -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);