diff options
author | Rob Landley <rob@landley.net> | 2005-05-03 22:34:03 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2005-05-03 22:34:03 +0000 |
commit | 627814bdc3ef9b405a77686d73e7b53ebd767a07 (patch) | |
tree | 93dfc4ec988cce631f76b4562a460ce9a8f236b3 /modutils/lsmod.c | |
parent | 0d38301d851f29e1f64db1c0759c7fb97c59347e (diff) | |
download | busybox-w32-627814bdc3ef9b405a77686d73e7b53ebd767a07.tar.gz busybox-w32-627814bdc3ef9b405a77686d73e7b53ebd767a07.tar.bz2 busybox-w32-627814bdc3ef9b405a77686d73e7b53ebd767a07.zip |
Takeharu Kato said:
I found that lsmod in busybox does not support linux-2.6.
I fix this issue(it is caused by changes of /proc/modules format).
If you use lsmod in busybox with kernel-2.6, please use this patch.
Diffstat (limited to 'modutils/lsmod.c')
-rw-r--r-- | modutils/lsmod.c | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/modutils/lsmod.c b/modutils/lsmod.c index 7bf314afe..525fc2dc2 100644 --- a/modutils/lsmod.c +++ b/modutils/lsmod.c | |||
@@ -164,10 +164,51 @@ extern int lsmod_main(int argc, char **argv) | |||
164 | { | 164 | { |
165 | printf("Module Size Used by"); | 165 | printf("Module Size Used by"); |
166 | check_tainted(); | 166 | check_tainted(); |
167 | 167 | #if defined(CONFIG_FEATURE_2_6_MODULES) | |
168 | { | ||
169 | FILE *file; | ||
170 | char line[4096]; | ||
171 | |||
172 | file = fopen("/proc/modules", "r"); | ||
173 | |||
174 | if (!file) | ||
175 | bb_error_msg_and_die("Opening /proc/modules"); | ||
176 | |||
177 | while (fgets(line, sizeof(line), file)) { | ||
178 | char *tok; | ||
179 | |||
180 | tok = strtok(line, " \t"); | ||
181 | printf("%-19s", tok); | ||
182 | tok = strtok(NULL, " \t\n"); | ||
183 | printf(" %8s", tok); | ||
184 | tok = strtok(NULL, " \t\n"); | ||
185 | /* Null if no module unloading support. */ | ||
186 | if (tok) { | ||
187 | printf(" %s", tok); | ||
188 | tok = strtok(NULL, "\n"); | ||
189 | if (!tok) | ||
190 | tok = ""; | ||
191 | /* New-style has commas, or -. If so, | ||
192 | truncate (other fields might follow). */ | ||
193 | else if (strchr(tok, ',')) { | ||
194 | tok = strtok(tok, "\t "); | ||
195 | /* Strip trailing comma. */ | ||
196 | if (tok[strlen(tok)-1] == ',') | ||
197 | tok[strlen(tok)-1] = '\0'; | ||
198 | } else if (tok[0] == '-' | ||
199 | && (tok[1] == '\0' || isspace(tok[1]))) | ||
200 | tok = ""; | ||
201 | printf(" %s", tok); | ||
202 | } | ||
203 | printf("\n"); | ||
204 | } | ||
205 | fclose(file); | ||
206 | } | ||
207 | #else | ||
168 | if (bb_xprint_file_by_name("/proc/modules") < 0) { | 208 | if (bb_xprint_file_by_name("/proc/modules") < 0) { |
169 | return 0; | 209 | return 0; |
170 | } | 210 | } |
211 | #endif /* CONFIG_FEATURE_2_6_MODULES */ | ||
171 | return 1; | 212 | return 1; |
172 | } | 213 | } |
173 | 214 | ||