aboutsummaryrefslogtreecommitdiff
path: root/toys/lsmod.c
diff options
context:
space:
mode:
Diffstat (limited to 'toys/lsmod.c')
-rw-r--r--toys/lsmod.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/toys/lsmod.c b/toys/lsmod.c
index 41bea371..07ef7f89 100644
--- a/toys/lsmod.c
+++ b/toys/lsmod.c
@@ -23,23 +23,18 @@ config LSMOD
void lsmod_main(void)
{
FILE * file = xfopen("/proc/modules", "r");
- char *name, *size, *refcnt, *users;
- xprintf("%-24s Size Used by\n", "Module");
+ xprintf("%-23s Size Used by\n", "Module");
while (fgets(toybuf, sizeof(toybuf), file)) {
- int len;
+ char *name = strtok(toybuf, " "), *size = strtok(NULL, " "),
+ *refcnt = strtok(NULL, " "), *users = strtok(NULL, " ");
- name = strtok(toybuf, " ");
- size = strtok(NULL, " ");
- refcnt = strtok(NULL, " ");
- users = strtok(NULL, " ");
-
- if(name && size && refcnt && users) {
- len = strlen(users)-1;
+ if(users) {
+ int len = strlen(users)-1;
if (users[len] == ',' || users[len] == '-')
users[len] = 0;
- xprintf("%-20s %8s %s %s\n", name, size, refcnt, users);
+ xprintf("%-19s %8s %s %s\n", name, size, refcnt, users);
} else perror_exit("unrecognized input");
}
fclose(file);