aboutsummaryrefslogtreecommitdiff
path: root/modutils/lsmod.c
diff options
context:
space:
mode:
authorlandley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-08-28 19:40:08 +0000
committerlandley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-08-28 19:40:08 +0000
commit680deb07073f10d09509e43bbe68753b4abaa726 (patch)
treec330a3b93c62f67b2099d030b6d8c016d902c01a /modutils/lsmod.c
parent91e9e31ac059a4f9c08c6c0759591b569f320a3d (diff)
downloadbusybox-w32-680deb07073f10d09509e43bbe68753b4abaa726.tar.gz
busybox-w32-680deb07073f10d09509e43bbe68753b4abaa726.tar.bz2
busybox-w32-680deb07073f10d09509e43bbe68753b4abaa726.zip
No real need for my_query_module() and this eliminates some type-punned
pointer warning on certain gcc versions (and saves 38 bytes). git-svn-id: svn://busybox.net/trunk/busybox@16003 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'modutils/lsmod.c')
-rw-r--r--modutils/lsmod.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/modutils/lsmod.c b/modutils/lsmod.c
index ed194edd6..2bc1ae6b1 100644
--- a/modutils/lsmod.c
+++ b/modutils/lsmod.c
@@ -15,7 +15,7 @@
15 15
16 16
17#ifndef CONFIG_FEATURE_CHECK_TAINTED_MODULE 17#ifndef CONFIG_FEATURE_CHECK_TAINTED_MODULE
18static inline void check_tainted(void) { printf("\n"); } 18static void check_tainted(void) { printf("\n"); }
19#else 19#else
20#define TAINT_FILENAME "/proc/sys/kernel/tainted" 20#define TAINT_FILENAME "/proc/sys/kernel/tainted"
21#define TAINT_PROPRIETORY_MODULE (1<<0) 21#define TAINT_PROPRIETORY_MODULE (1<<0)
@@ -80,13 +80,15 @@ int lsmod_main(int argc, char **argv)
80 char *module_names, *mn, *deps, *dn; 80 char *module_names, *mn, *deps, *dn;
81 size_t bufsize, depsize, nmod, count, i, j; 81 size_t bufsize, depsize, nmod, count, i, j;
82 82
83 module_names = xmalloc(bufsize = 256); 83 module_names = deps = NULL;
84 if (my_query_module(NULL, QM_MODULES, &module_names, &bufsize, &nmod)) { 84 bufsize = depsize = 0;
85 bb_perror_msg_and_die("QM_MODULES"); 85 while(query_module(NULL, QM_MODULES, module_names, bufsize, &nmod)) {
86 if (errno != ENOSPC) bb_perror_msg_and_die("QM_MODULES");
87 module_names = xmalloc(bufsize = nmod);
86 } 88 }
87 89
88 deps = xmalloc(depsize = 256); 90 deps = xmalloc(depsize = 256);
89 printf("Module Size Used by"); 91 printf("Module\t\t\tSize Used by");
90 check_tainted(); 92 check_tainted();
91 93
92 for (i = 0, mn = module_names; i < nmod; mn += strlen(mn) + 1, i++) { 94 for (i = 0, mn = module_names; i < nmod; mn += strlen(mn) + 1, i++) {
@@ -98,12 +100,13 @@ int lsmod_main(int argc, char **argv)
98 /* else choke */ 100 /* else choke */
99 bb_perror_msg_and_die("module %s: QM_INFO", mn); 101 bb_perror_msg_and_die("module %s: QM_INFO", mn);
100 } 102 }
101 if (my_query_module(mn, QM_REFS, &deps, &depsize, &count)) { 103 while (query_module(mn, QM_REFS, deps, depsize, &count)) {
102 if (errno == ENOENT) { 104 if (errno == ENOENT) {
103 /* The module was removed out from underneath us. */ 105 /* The module was removed out from underneath us. */
104 continue; 106 continue;
105 } 107 } else if (errno != ENOSPC)
106 bb_perror_msg_and_die("module %s: QM_REFS", mn); 108 bb_perror_msg_and_die("module %s: QM_REFS", mn);
109 deps = xrealloc(deps, count);
107 } 110 }
108 printf("%-20s%8lu%4ld", mn, info.size, info.usecount); 111 printf("%-20s%8lu%4ld", mn, info.size, info.usecount);
109 if (info.flags & NEW_MOD_DELETED) 112 if (info.flags & NEW_MOD_DELETED)