Add "kldstat -h"; showing module sizes in hex is rather weird.
Reviewed by: emaste@ (earlier version) MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D4969
This commit is contained in:
parent
e07528700a
commit
1b18fc10b3
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=294624
@ -29,4 +29,6 @@
|
|||||||
PROG= kldstat
|
PROG= kldstat
|
||||||
MAN= kldstat.8
|
MAN= kldstat.8
|
||||||
|
|
||||||
|
LIBADD= util
|
||||||
|
|
||||||
.include <bsd.prog.mk>
|
.include <bsd.prog.mk>
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
.\"
|
.\"
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd January 22, 2014
|
.Dd January 19, 2016
|
||||||
.Dt KLDSTAT 8
|
.Dt KLDSTAT 8
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -33,6 +33,7 @@
|
|||||||
.Nd display status of dynamic kernel linker
|
.Nd display status of dynamic kernel linker
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
|
.Op Fl h
|
||||||
.Op Fl q
|
.Op Fl q
|
||||||
.Op Fl v
|
.Op Fl v
|
||||||
.Op Fl i Ar id
|
.Op Fl i Ar id
|
||||||
@ -48,6 +49,9 @@ kernel.
|
|||||||
.Pp
|
.Pp
|
||||||
The following options are available:
|
The following options are available:
|
||||||
.Bl -tag -width indentXX
|
.Bl -tag -width indentXX
|
||||||
|
.It Fl h
|
||||||
|
Display the size field in a human-readable form, using unit suffixes
|
||||||
|
instead of hex values.
|
||||||
.It Fl v
|
.It Fl v
|
||||||
Be more verbose.
|
Be more verbose.
|
||||||
.It Fl i Ar id
|
.It Fl i Ar id
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
__FBSDID("$FreeBSD$");
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
#include <libutil.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -51,18 +52,27 @@ printmod(int modid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
printfile(int fileid, int verbose)
|
printfile(int fileid, int verbose, int humanized)
|
||||||
{
|
{
|
||||||
struct kld_file_stat stat;
|
struct kld_file_stat stat;
|
||||||
int modid;
|
int modid;
|
||||||
|
char buf[5];
|
||||||
|
|
||||||
stat.version = sizeof(struct kld_file_stat);
|
stat.version = sizeof(struct kld_file_stat);
|
||||||
if (kldstat(fileid, &stat) < 0)
|
if (kldstat(fileid, &stat) < 0) {
|
||||||
err(1, "can't stat file id %d", fileid);
|
err(1, "can't stat file id %d", fileid);
|
||||||
else
|
} else {
|
||||||
printf("%2d %4d %p %-8zx %s",
|
if (humanized) {
|
||||||
stat.id, stat.refs, stat.address, stat.size,
|
humanize_number(buf, sizeof(buf), stat.size,
|
||||||
stat.name);
|
"", HN_AUTOSCALE, HN_DECIMAL | HN_NOSPACE);
|
||||||
|
|
||||||
|
printf("%2d %4d %p %5s %s",
|
||||||
|
stat.id, stat.refs, stat.address, buf, stat.name);
|
||||||
|
} else {
|
||||||
|
printf("%2d %4d %p %-8zx %s",
|
||||||
|
stat.id, stat.refs, stat.address, stat.size, stat.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
printf(" (%s)\n", stat.pathname);
|
printf(" (%s)\n", stat.pathname);
|
||||||
@ -78,7 +88,7 @@ printfile(int fileid, int verbose)
|
|||||||
static void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "usage: kldstat [-q] [-v] [-i id] [-n filename]\n");
|
fprintf(stderr, "usage: kldstat [-h] [-q] [-v] [-i id] [-n filename]\n");
|
||||||
fprintf(stderr, " kldstat [-q] [-m modname]\n");
|
fprintf(stderr, " kldstat [-q] [-m modname]\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -87,6 +97,7 @@ int
|
|||||||
main(int argc, char** argv)
|
main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
|
int humanized = 0;
|
||||||
int verbose = 0;
|
int verbose = 0;
|
||||||
int fileid = 0;
|
int fileid = 0;
|
||||||
int quiet = 0;
|
int quiet = 0;
|
||||||
@ -94,8 +105,11 @@ main(int argc, char** argv)
|
|||||||
char* modname = NULL;
|
char* modname = NULL;
|
||||||
char* p;
|
char* p;
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "i:m:n:qv")) != -1)
|
while ((c = getopt(argc, argv, "hi:m:n:qv")) != -1)
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
case 'h':
|
||||||
|
humanized = 1;
|
||||||
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
fileid = (int)strtoul(optarg, &p, 10);
|
fileid = (int)strtoul(optarg, &p, 10);
|
||||||
if (*p != '\0')
|
if (*p != '\0')
|
||||||
@ -155,12 +169,15 @@ main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Id Refs Address%*c Size Name\n", POINTER_WIDTH - 7, ' ');
|
if (humanized)
|
||||||
|
printf("Id Refs Address%*c Size Name\n", POINTER_WIDTH - 7, ' ');
|
||||||
|
else
|
||||||
|
printf("Id Refs Address%*c Size Name\n", POINTER_WIDTH - 7, ' ');
|
||||||
if (fileid != 0)
|
if (fileid != 0)
|
||||||
printfile(fileid, verbose);
|
printfile(fileid, verbose, humanized);
|
||||||
else
|
else
|
||||||
for (fileid = kldnext(0); fileid > 0; fileid = kldnext(fileid))
|
for (fileid = kldnext(0); fileid > 0; fileid = kldnext(fileid))
|
||||||
printfile(fileid, verbose);
|
printfile(fileid, verbose, humanized);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user