Print header after trying to open /proc/modules

This fails on kernels compiled without module support or
if procfs is not mounted.
This commit is contained in:
sin 2014-07-04 11:45:58 +01:00
parent 1ec0073bb8
commit 55dd1076fe
1 changed files with 3 additions and 2 deletions

View File

@ -33,11 +33,12 @@ main(int argc, char *argv[])
if (argc > 0) if (argc > 0)
usage(); usage();
printf("%-23s Size Used by\n", "Module");
fp = fopen(modfile, "r"); fp = fopen(modfile, "r");
if (!fp) if (!fp)
eprintf("fopen %s:", modfile); eprintf("fopen %s:", modfile);
printf("%-23s Size Used by\n", "Module");
while (agetline(&buf, &bufsize, fp) != -1) { while (agetline(&buf, &bufsize, fp) != -1) {
parse_modline(buf, &name, &size, &refcount, &users); parse_modline(buf, &name, &size, &refcount, &users);
if (!name || !size || !refcount || !users) if (!name || !size || !refcount || !users)