Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F136869711
D4969.id12395.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D4969.id12395.diff
View Options
Index: sbin/kldstat/Makefile
===================================================================
--- sbin/kldstat/Makefile
+++ sbin/kldstat/Makefile
@@ -29,4 +29,6 @@
PROG= kldstat
MAN= kldstat.8
+LIBADD= util
+
.include <bsd.prog.mk>
Index: sbin/kldstat/kldstat.c
===================================================================
--- sbin/kldstat/kldstat.c
+++ sbin/kldstat/kldstat.c
@@ -36,6 +36,8 @@
#include <sys/module.h>
#include <sys/linker.h>
+#include <libutil.h>
+
#define POINTER_WIDTH ((int)(sizeof(void *) * 2 + 2))
static void
@@ -51,18 +53,28 @@
}
static void
-printfile(int fileid, int verbose)
+printfile(int fileid, int verbose, int humanized)
{
struct kld_file_stat stat;
int modid;
+ char buf[6];
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);
- else
- printf("%2d %4d %p %-8zx %s",
- stat.id, stat.refs, stat.address, stat.size,
- stat.name);
+ } else {
+ if (humanized) {
+ humanize_number(buf, sizeof(buf), stat.size,
+ "", HN_AUTOSCALE, HN_DECIMAL | HN_NOSPACE);
+ printf("%2d %4d %p %-8s %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) {
printf(" (%s)\n", stat.pathname);
@@ -78,8 +90,8 @@
static void
usage(void)
{
- fprintf(stderr, "usage: kldstat [-q] [-v] [-i id] [-n filename]\n");
- fprintf(stderr, " kldstat [-q] [-m modname]\n");
+ fprintf(stderr, "usage: kldstat [-h] [-q] [-v] [-i id] [-n filename]\n");
+ fprintf(stderr, " kldstat [-h] [-q] [-m modname]\n");
exit(1);
}
@@ -87,6 +99,7 @@
main(int argc, char** argv)
{
int c;
+ int humanized = 0;
int verbose = 0;
int fileid = 0;
int quiet = 0;
@@ -94,8 +107,11 @@
char* modname = NULL;
char* p;
- while ((c = getopt(argc, argv, "i:m:n:qv")) != -1)
+ while ((c = getopt(argc, argv, "hi:m:n:qv")) != -1)
switch (c) {
+ case 'h':
+ humanized = 1;
+ break;
case 'i':
fileid = (int)strtoul(optarg, &p, 10);
if (*p != '\0')
@@ -157,10 +173,10 @@
printf("Id Refs Address%*c Size Name\n", POINTER_WIDTH - 7, ' ');
if (fileid != 0)
- printfile(fileid, verbose);
+ printfile(fileid, verbose, humanized);
else
for (fileid = kldnext(0); fileid > 0; fileid = kldnext(fileid))
- printfile(fileid, verbose);
+ printfile(fileid, verbose, humanized);
return 0;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 21, 6:36 AM (12 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
25754426
Default Alt Text
D4969.id12395.diff (2 KB)
Attached To
Mode
D4969: Add "kldstat -h"; showing module sizes in hex is rather weird.
Attached
Detach File
Event Timeline
Log In to Comment