It can show all dependencies of specified module. The
module can be specified by alias.

Signed-off-by: Serj Kalichev <[email protected]>
---
 modutils/modprobe.c |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/modutils/modprobe.c b/modutils/modprobe.c
index a5cf4ba..552fe2b 100644
--- a/modutils/modprobe.c
+++ b/modutils/modprobe.c
@@ -86,6 +86,7 @@
 //usage:       IF_FEATURE_MODPROBE_BLACKLIST(
 //usage:     "\n       -b      Apply blacklist to module names too"
 //usage:       )
+//usage:     "\n       -D      Show dependencies"
 //usage:#endif /* !ENABLE_MODPROBE_SMALL */
 
 #include "libbb.h"
@@ -105,7 +106,7 @@
  * we pull in through INSMOD_OPTS define */
 
 #define MODPROBE_COMPLEMENTARY "q-v:v-q:l--ar:a--lr:r--al"
-#define MODPROBE_OPTS  "alr" IF_FEATURE_MODPROBE_BLACKLIST("b")
+#define MODPROBE_OPTS  "alr" IF_FEATURE_MODPROBE_BLACKLIST("b") "D"
 //#define MODPROBE_COMPLEMENTARY "q-v:v-q:l--acr:a--lr:r--al"
 //#define MODPROBE_OPTS  "acd:lnrt:C:" IF_FEATURE_MODPROBE_BLACKLIST("b")
 enum {
@@ -119,6 +120,7 @@ enum {
        //MODPROBE_OPT_VERONLY  = (INSMOD_OPT_UNUSED << x), /* V */
        //MODPROBE_OPT_CONFIGFILE=(INSMOD_OPT_UNUSED << x), /* C */
        MODPROBE_OPT_BLACKLIST  = (INSMOD_OPT_UNUSED << 3) * 
ENABLE_FEATURE_MODPROBE_BLACKLIST,
+       MODPROBE_OPT_SHOW_DEPS  = (INSMOD_OPT_UNUSED << 4), /* D */
 };
 
 #define MODULE_FLAG_LOADED              0x0001
@@ -202,7 +204,7 @@ static void add_probe(const char *name)
        struct module_entry *m;
 
        m = get_or_add_modentry(name);
-       if (!(option_mask32 & MODPROBE_OPT_REMOVE)
+       if (!(option_mask32 & (MODPROBE_OPT_REMOVE | MODPROBE_OPT_SHOW_DEPS))
         && (m->flags & MODULE_FLAG_LOADED)
        ) {
                DBG("skipping %s, it is already loaded", name);
@@ -357,6 +359,7 @@ static int do_modprobe(struct module_entry *m)
        char *fn, *options;
        int rc, first;
        llist_t *l;
+       struct utsname uts;
 
        if (!(m->flags & MODULE_FLAG_FOUND_IN_MODDEP)) {
                if (!(option_mask32 & INSMOD_OPT_SILENT))
@@ -374,6 +377,7 @@ static int do_modprobe(struct module_entry *m)
 
        first = 1;
        rc = 0;
+       uname(&uts);
        while (m->deps) {
                rc = 0;
                fn = llist_pop(&m->deps); /* we leak it */
@@ -399,7 +403,8 @@ static int do_modprobe(struct module_entry *m)
                        continue;
                }
 
-               if (m2->flags & MODULE_FLAG_LOADED) {
+               if ((m2->flags & MODULE_FLAG_LOADED) &&
+                       !(option_mask32 & MODPROBE_OPT_SHOW_DEPS)) {
                        DBG("%s is already loaded, skipping", fn);
                        continue;
                }
@@ -409,7 +414,11 @@ static int do_modprobe(struct module_entry *m)
                options = parse_and_add_kcmdline_module_options(options, 
m2->modname);
                if (m == m2)
                        options = gather_options_str(options, G.cmdline_mopts);
-               rc = bb_init_module(fn, options);
+               if (option_mask32 & MODPROBE_OPT_SHOW_DEPS)
+                       printf("insmod %s/%s/%s\n", CONFIG_DEFAULT_MODULES_DIR,
+                               uts.release, fn);
+               else
+                       rc = bb_init_module(fn, options);
                DBG("loaded %s '%s', rc:%d", fn, options, rc);
                if (rc == EEXIST)
                        rc = 0;
@@ -456,7 +465,7 @@ static void load_modules_dep(void)
 
                /* Optimization... */
                if ((m->flags & MODULE_FLAG_LOADED)
-                && !(option_mask32 & MODPROBE_OPT_REMOVE)
+                && !(option_mask32 & (MODPROBE_OPT_REMOVE | 
MODPROBE_OPT_SHOW_DEPS))
                ) {
                        DBG("skip deps of %s, it's already loaded", tokens[0]);
                        continue;
@@ -592,7 +601,7 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
                        m2 = get_or_add_modentry(realname);
                        if (!(m2->flags & MODULE_FLAG_BLACKLISTED)
                         && (!(m2->flags & MODULE_FLAG_LOADED)
-                           || (opt & MODPROBE_OPT_REMOVE))
+                           || (opt & (MODPROBE_OPT_REMOVE | 
MODPROBE_OPT_SHOW_DEPS)))
                        ) {
 //TODO: we can pass "me" as 2nd param to do_modprobe,
 //and make do_modprobe emit more meaningful error messages
-- 
1.7.3.3

_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to