[BusyBox-cvs] svn commit: trunk/busybox/modutils
landley at busybox.net
landley at busybox.net
Tue May 3 22:34:04 UTC 2005
Author: landley
Date: 2005-05-03 16:34:03 -0600 (Tue, 03 May 2005)
New Revision: 10243
Log:
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.
Modified:
trunk/busybox/modutils/lsmod.c
Changeset:
Modified: trunk/busybox/modutils/lsmod.c
===================================================================
--- trunk/busybox/modutils/lsmod.c 2005-05-03 22:30:08 UTC (rev 10242)
+++ trunk/busybox/modutils/lsmod.c 2005-05-03 22:34:03 UTC (rev 10243)
@@ -164,10 +164,51 @@
{
printf("Module Size Used by");
check_tainted();
+#if defined(CONFIG_FEATURE_2_6_MODULES)
+ {
+ FILE *file;
+ char line[4096];
+ file = fopen("/proc/modules", "r");
+
+ if (!file)
+ bb_error_msg_and_die("Opening /proc/modules");
+
+ while (fgets(line, sizeof(line), file)) {
+ char *tok;
+
+ tok = strtok(line, " \t");
+ printf("%-19s", tok);
+ tok = strtok(NULL, " \t\n");
+ printf(" %8s", tok);
+ tok = strtok(NULL, " \t\n");
+ /* Null if no module unloading support. */
+ if (tok) {
+ printf(" %s", tok);
+ tok = strtok(NULL, "\n");
+ if (!tok)
+ tok = "";
+ /* New-style has commas, or -. If so,
+ truncate (other fields might follow). */
+ else if (strchr(tok, ',')) {
+ tok = strtok(tok, "\t ");
+ /* Strip trailing comma. */
+ if (tok[strlen(tok)-1] == ',')
+ tok[strlen(tok)-1] = '\0';
+ } else if (tok[0] == '-'
+ && (tok[1] == '\0' || isspace(tok[1])))
+ tok = "";
+ printf(" %s", tok);
+ }
+ printf("\n");
+ }
+ fclose(file);
+ }
+#else
if (bb_xprint_file_by_name("/proc/modules") < 0) {
return 0;
}
+#endif /* CONFIG_FEATURE_2_6_MODULES */
return 1;
}
More information about the busybox-cvs
mailing list