kmodloader: fix lsmod depends output
authorHauke Mehrtens <hauke@hauke-m.de>
Wed, 13 Jul 2016 14:55:20 +0000 (16:55 +0200)
committerFelix Fietkau <nbd@nbd.name>
Tue, 19 Jul 2016 11:55:43 +0000 (13:55 +0200)
Without this patch only the first dependency is shown, with this patch
all module dependencies are show.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
kmodloader.c

index ad1f1c0f4f9e7d13cac8905a26dff94f863806df..e32e6affb64899a366cb81f6483865a061160891 100644 (file)
@@ -658,15 +658,26 @@ static int main_rmmod(int argc, char **argv)
 static int main_lsmod(int argc, char **argv)
 {
        struct module *m;
+       char *dep;
 
        if (scan_loaded_modules())
                return -1;
 
        avl_for_each_element(&modules, m, avl)
-               if (m->state == LOADED)
-                       printf("%-20s%8d%3d %s\n",
-                               m->name, m->size, m->usage,
-                               (*m->depends == '-') ? ("") : (m->depends));
+               if (m->state == LOADED) {
+                       printf("%-20s%8d%3d ",
+                               m->name, m->size, m->usage);
+                       if (m->depends && strcmp(m->depends, "-") && strcmp(m->depends, "")) {
+                               dep = m->depends;
+                               while (*dep) {
+                                       printf("%s", dep);
+                                       dep = dep + strlen(dep) + 1;
+                                       if (*dep)
+                                               printf(",");
+                               }
+                       }
+                       printf("\n");
+               }
 
        free_modules();