busybox: update to 1.23.2
[tomato.git] / release / src / router / busybox / modutils / modprobe.c
blobab33b413086809651e0848e5cae4e115e7e96e69
1 /* vi: set sw=4 ts=4: */
2 /*
3 * Modprobe written from scratch for BusyBox
5 * Copyright (c) 2008 Timo Teras <timo.teras@iki.fi>
6 * Copyright (c) 2008 Vladimir Dronnikov
8 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
9 */
11 //applet:IF_MODPROBE(APPLET(modprobe, BB_DIR_SBIN, BB_SUID_DROP))
13 #include "libbb.h"
14 #include "modutils.h"
15 #include <sys/utsname.h>
16 #include <fnmatch.h>
18 //#define DBG(fmt, ...) bb_error_msg("%s: " fmt, __func__, ## __VA_ARGS__)
19 #define DBG(...) ((void)0)
21 /* Note that unlike older versions of modules.dep/depmod (busybox and m-i-t),
22 * we expect the full dependency list to be specified in modules.dep.
23 * Older versions would only export the direct dependency list.
27 //usage:#if !ENABLE_MODPROBE_SMALL
28 //usage:#define modprobe_notes_usage
29 //usage: "modprobe can (un)load a stack of modules, passing each module options (when\n"
30 //usage: "loading). modprobe uses a configuration file to determine what option(s) to\n"
31 //usage: "pass each module it loads.\n"
32 //usage: "\n"
33 //usage: "The configuration file is searched (in this order):\n"
34 //usage: "\n"
35 //usage: " /etc/modprobe.conf (2.6 only)\n"
36 //usage: " /etc/modules.conf\n"
37 //usage: " /etc/conf.modules (deprecated)\n"
38 //usage: "\n"
39 //usage: "They all have the same syntax (see below). If none is present, it is\n"
40 //usage: "_not_ an error; each loaded module is then expected to load without\n"
41 //usage: "options. Once a file is found, the others are tested for.\n"
42 //usage: "\n"
43 //usage: "/etc/modules.conf entry format:\n"
44 //usage: "\n"
45 //usage: " alias <alias_name> <mod_name>\n"
46 //usage: " Makes it possible to modprobe alias_name, when there is no such module.\n"
47 //usage: " It makes sense if your mod_name is long, or you want a more representative\n"
48 //usage: " name for that module (eg. 'scsi' in place of 'aha7xxx').\n"
49 //usage: " This makes it also possible to use a different set of options (below) for\n"
50 //usage: " the module and the alias.\n"
51 //usage: " A module can be aliased more than once.\n"
52 //usage: "\n"
53 //usage: " options <mod_name|alias_name> <symbol=value...>\n"
54 //usage: " When loading module mod_name (or the module aliased by alias_name), pass\n"
55 //usage: " the \"symbol=value\" pairs as option to that module.\n"
56 //usage: "\n"
57 //usage: "Sample /etc/modules.conf file:\n"
58 //usage: "\n"
59 //usage: " options tulip irq=3\n"
60 //usage: " alias tulip tulip2\n"
61 //usage: " options tulip2 irq=4 io=0x308\n"
62 //usage: "\n"
63 //usage: "Other functionality offered by 'classic' modprobe is not available in\n"
64 //usage: "this implementation.\n"
65 //usage: "\n"
66 //usage: "If module options are present both in the config file, and on the command line,\n"
67 //usage: "then the options from the command line will be passed to the module _after_\n"
68 //usage: "the options from the config file. That way, you can have defaults in the config\n"
69 //usage: "file, and override them for a specific usage from the command line.\n"
70 //usage:#define modprobe_example_usage
71 //usage: "(with the above /etc/modules.conf):\n\n"
72 //usage: "$ modprobe tulip\n"
73 //usage: " will load the module 'tulip' with default option 'irq=3'\n\n"
74 //usage: "$ modprobe tulip irq=5\n"
75 //usage: " will load the module 'tulip' with option 'irq=5', thus overriding the default\n\n"
76 //usage: "$ modprobe tulip2\n"
77 //usage: " will load the module 'tulip' with default options 'irq=4 io=0x308',\n"
78 //usage: " which are the default for alias 'tulip2'\n\n"
79 //usage: "$ modprobe tulip2 irq=8\n"
80 //usage: " will load the module 'tulip' with default options 'irq=4 io=0x308 irq=8',\n"
81 //usage: " which are the default for alias 'tulip2' overridden by the option 'irq=8'\n\n"
82 //usage: " from the command line\n\n"
83 //usage: "$ modprobe tulip2 irq=2 io=0x210\n"
84 //usage: " will load the module 'tulip' with default options 'irq=4 io=0x308 irq=4 io=0x210',\n"
85 //usage: " which are the default for alias 'tulip2' overridden by the options 'irq=2 io=0x210'\n\n"
86 //usage: " from the command line\n"
87 //usage:
88 //usage:#define modprobe_trivial_usage
89 //usage: "[-alrqvsD" IF_FEATURE_MODPROBE_BLACKLIST("b") "]"
90 //usage: " MODULE [SYMBOL=VALUE]..."
91 //usage:#define modprobe_full_usage "\n\n"
92 //usage: " -a Load multiple MODULEs"
93 //usage: "\n -l List (MODULE is a pattern)"
94 //usage: "\n -r Remove MODULE (stacks) or do autoclean"
95 //usage: "\n -q Quiet"
96 //usage: "\n -v Verbose"
97 //usage: "\n -s Log to syslog"
98 //usage: "\n -D Show dependencies"
99 //usage: IF_FEATURE_MODPROBE_BLACKLIST(
100 //usage: "\n -b Apply blacklist to module names too"
101 //usage: )
102 //usage:#endif /* !ENABLE_MODPROBE_SMALL */
104 /* Note: usage text doesn't document various 2.4 options
105 * we pull in through INSMOD_OPTS define
106 * Note2: -b is always accepted, but if !FEATURE_MODPROBE_BLACKLIST,
107 * it is a no-op.
109 #define MODPROBE_OPTS "alrDb"
110 /* -a and -D _are_ in fact compatible */
111 #define MODPROBE_COMPLEMENTARY ("q-v:v-q:l--arD:r--alD:a--lr:D--rl")
112 //#define MODPROBE_OPTS "acd:lnrt:C:b"
113 //#define MODPROBE_COMPLEMENTARY "q-v:v-q:l--acr:a--lr:r--al"
114 enum {
115 OPT_INSERT_ALL = (INSMOD_OPT_UNUSED << 0), /* a */
116 //OPT_DUMP_ONLY = (INSMOD_OPT_UNUSED << x), /* c */
117 //OPT_DIRNAME = (INSMOD_OPT_UNUSED << x), /* d */
118 OPT_LIST_ONLY = (INSMOD_OPT_UNUSED << 1), /* l */
119 //OPT_SHOW_ONLY = (INSMOD_OPT_UNUSED << x), /* n */
120 OPT_REMOVE = (INSMOD_OPT_UNUSED << 2), /* r */
121 //OPT_RESTRICT = (INSMOD_OPT_UNUSED << x), /* t */
122 //OPT_VERONLY = (INSMOD_OPT_UNUSED << x), /* V */
123 //OPT_CONFIGFILE = (INSMOD_OPT_UNUSED << x), /* C */
124 OPT_SHOW_DEPS = (INSMOD_OPT_UNUSED << 3), /* D */
125 OPT_BLACKLIST = (INSMOD_OPT_UNUSED << 4) * ENABLE_FEATURE_MODPROBE_BLACKLIST,
127 #if ENABLE_LONG_OPTS
128 static const char modprobe_longopts[] ALIGN1 =
129 /* nobody asked for long opts (yet) */
130 // "all\0" No_argument "a"
131 // "list\0" No_argument "l"
132 // "remove\0" No_argument "r"
133 // "quiet\0" No_argument "q"
134 // "verbose\0" No_argument "v"
135 // "syslog\0" No_argument "s"
136 /* module-init-tools 3.11.1 has only long opt --show-depends
137 * but no short -D, we provide long opt for scripts which
138 * were written for 3.11.1: */
139 "show-depends\0" No_argument "D"
140 // "use-blacklist\0" No_argument "b"
142 #endif
144 #define MODULE_FLAG_LOADED 0x0001
145 #define MODULE_FLAG_NEED_DEPS 0x0002
146 /* "was seen in modules.dep": */
147 #define MODULE_FLAG_FOUND_IN_MODDEP 0x0004
148 #define MODULE_FLAG_BLACKLISTED 0x0008
150 struct module_entry { /* I'll call it ME. */
151 unsigned flags;
152 char *modname; /* stripped of /path/, .ext and s/-/_/g */
153 const char *probed_name; /* verbatim as seen on cmdline */
154 char *options; /* options from config files */
155 llist_t *realnames; /* strings. if this module is an alias, */
156 /* real module name is one of these. */
157 //Can there really be more than one? Example from real kernel?
158 llist_t *deps; /* strings. modules we depend on */
161 #define DB_HASH_SIZE 256
163 struct globals {
164 llist_t *probes; /* MEs of module(s) requested on cmdline */
165 char *cmdline_mopts; /* module options from cmdline */
166 int num_unresolved_deps;
167 /* bool. "Did we have 'symbol:FOO' requested on cmdline?" */
168 smallint need_symbols;
169 struct utsname uts;
170 llist_t *db[DB_HASH_SIZE]; /* MEs of all modules ever seen (caching for speed) */
171 } FIX_ALIASING;
172 #define G (*ptr_to_globals)
173 #define INIT_G() do { \
174 SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
175 } while (0)
178 static int read_config(const char *path);
180 static char *gather_options_str(char *opts, const char *append)
182 /* Speed-optimized. We call gather_options_str many times. */
183 if (append) {
184 if (opts == NULL) {
185 opts = xstrdup(append);
186 } else {
187 int optlen = strlen(opts);
188 opts = xrealloc(opts, optlen + strlen(append) + 2);
189 sprintf(opts + optlen, " %s", append);
192 return opts;
195 /* These three functions called many times, optimizing for speed.
196 * Users reported minute-long delays when they runn iptables repeatedly
197 * (iptables use modprobe to install needed kernel modules).
199 static struct module_entry *helper_get_module(const char *module, int create)
201 char modname[MODULE_NAME_LEN];
202 struct module_entry *e;
203 llist_t *l;
204 unsigned i;
205 unsigned hash;
207 filename2modname(module, modname);
209 hash = 0;
210 for (i = 0; modname[i]; i++)
211 hash = ((hash << 5) + hash) + modname[i];
212 hash %= DB_HASH_SIZE;
214 for (l = G.db[hash]; l; l = l->link) {
215 e = (struct module_entry *) l->data;
216 if (strcmp(e->modname, modname) == 0)
217 return e;
219 if (!create)
220 return NULL;
222 e = xzalloc(sizeof(*e));
223 e->modname = xstrdup(modname);
224 llist_add_to(&G.db[hash], e);
226 return e;
228 static ALWAYS_INLINE struct module_entry *get_or_add_modentry(const char *module)
230 return helper_get_module(module, 1);
232 /* So far this function always gets a module pathname, never an alias name.
233 * The crucial difference is that pathname needs dirname stripping,
234 * while alias name must NOT do it!
235 * Testcase where dirname stripping is likely to go wrong: "modprobe devname:snd/timer"
237 static ALWAYS_INLINE struct module_entry *get_modentry(const char *pathname)
239 return helper_get_module(bb_get_last_path_component_nostrip(pathname), 0);
242 static void add_probe(const char *name)
244 struct module_entry *m;
246 m = get_or_add_modentry(name);
247 if (!(option_mask32 & (OPT_REMOVE | OPT_SHOW_DEPS))
248 && (m->flags & MODULE_FLAG_LOADED)
250 DBG("skipping %s, it is already loaded", name);
251 return;
254 DBG("queuing %s", name);
255 m->probed_name = name;
256 m->flags |= MODULE_FLAG_NEED_DEPS;
257 llist_add_to_end(&G.probes, m);
258 G.num_unresolved_deps++;
259 if (ENABLE_FEATURE_MODUTILS_SYMBOLS
260 && strncmp(m->modname, "symbol:", 7) == 0
262 G.need_symbols = 1;
266 static int FAST_FUNC config_file_action(const char *filename,
267 struct stat *statbuf UNUSED_PARAM,
268 void *userdata UNUSED_PARAM,
269 int depth UNUSED_PARAM)
271 char *tokens[3];
272 parser_t *p;
273 struct module_entry *m;
274 int rc = TRUE;
276 if (bb_basename(filename)[0] == '.')
277 goto error;
279 p = config_open2(filename, fopen_for_read);
280 if (p == NULL) {
281 rc = FALSE;
282 goto error;
285 while (config_read(p, tokens, 3, 2, "# \t", PARSE_NORMAL)) {
286 //Use index_in_strings?
287 if (strcmp(tokens[0], "alias") == 0) {
288 /* alias <wildcard> <modulename> */
289 llist_t *l;
290 char wildcard[MODULE_NAME_LEN];
291 char *rmod;
293 if (tokens[2] == NULL)
294 continue;
295 filename2modname(tokens[1], wildcard);
297 for (l = G.probes; l; l = l->link) {
298 m = (struct module_entry *) l->data;
299 if (fnmatch(wildcard, m->modname, 0) != 0)
300 continue;
301 rmod = filename2modname(tokens[2], NULL);
302 llist_add_to(&m->realnames, rmod);
304 if (m->flags & MODULE_FLAG_NEED_DEPS) {
305 m->flags &= ~MODULE_FLAG_NEED_DEPS;
306 G.num_unresolved_deps--;
309 m = get_or_add_modentry(rmod);
310 if (!(m->flags & MODULE_FLAG_NEED_DEPS)) {
311 m->flags |= MODULE_FLAG_NEED_DEPS;
312 G.num_unresolved_deps++;
315 } else if (strcmp(tokens[0], "options") == 0) {
316 /* options <modulename> <option...> */
317 if (tokens[2] == NULL)
318 continue;
319 m = get_or_add_modentry(tokens[1]);
320 m->options = gather_options_str(m->options, tokens[2]);
321 } else if (strcmp(tokens[0], "include") == 0) {
322 /* include <filename> */
323 read_config(tokens[1]);
324 } else if (ENABLE_FEATURE_MODPROBE_BLACKLIST
325 && strcmp(tokens[0], "blacklist") == 0
327 /* blacklist <modulename> */
328 get_or_add_modentry(tokens[1])->flags |= MODULE_FLAG_BLACKLISTED;
331 config_close(p);
332 error:
333 return rc;
336 static int read_config(const char *path)
338 return recursive_action(path, ACTION_RECURSE | ACTION_QUIET,
339 config_file_action, NULL, NULL, 1);
342 static const char *humanly_readable_name(struct module_entry *m)
344 /* probed_name may be NULL. modname always exists. */
345 return m->probed_name ? m->probed_name : m->modname;
348 static char *parse_and_add_kcmdline_module_options(char *options, const char *modulename)
350 char *kcmdline_buf;
351 char *kcmdline;
352 char *kptr;
353 int len;
355 kcmdline_buf = xmalloc_open_read_close("/proc/cmdline", NULL);
356 if (!kcmdline_buf)
357 return options;
359 kcmdline = kcmdline_buf;
360 len = strlen(modulename);
361 while ((kptr = strsep(&kcmdline, "\n\t ")) != NULL) {
362 if (strncmp(modulename, kptr, len) != 0)
363 continue;
364 kptr += len;
365 if (*kptr != '.')
366 continue;
367 /* It is "modulename.xxxx" */
368 kptr++;
369 if (strchr(kptr, '=') != NULL) {
370 /* It is "modulename.opt=[val]" */
371 options = gather_options_str(options, kptr);
374 free(kcmdline_buf);
376 return options;
379 /* Return: similar to bb_init_module:
380 * 0 on success,
381 * -errno on open/read error,
382 * errno on init_module() error
384 /* NB: INSMOD_OPT_SILENT bit suppresses ONLY non-existent modules,
385 * not deleted ones (those are still listed in modules.dep).
386 * module-init-tools version 3.4:
387 * # modprobe bogus
388 * FATAL: Module bogus not found. [exitcode 1]
389 * # modprobe -q bogus [silent, exitcode still 1]
390 * but:
391 * # rm kernel/drivers/net/dummy.ko
392 * # modprobe -q dummy
393 * FATAL: Could not open '/lib/modules/xxx/kernel/drivers/net/dummy.ko': No such file or directory
394 * [exitcode 1]
396 static int do_modprobe(struct module_entry *m)
398 int rc, first;
400 if (!(m->flags & MODULE_FLAG_FOUND_IN_MODDEP)) {
401 if (!(option_mask32 & INSMOD_OPT_SILENT))
402 bb_error_msg("module %s not found in modules.dep",
403 humanly_readable_name(m));
404 return -ENOENT;
406 DBG("do_modprob'ing %s", m->modname);
408 if (!(option_mask32 & OPT_REMOVE))
409 m->deps = llist_rev(m->deps);
411 if (0) {
412 llist_t *l;
413 for (l = m->deps; l; l = l->link)
414 DBG("dep: %s", l->data);
417 first = 1;
418 rc = 0;
419 while (m->deps) {
420 struct module_entry *m2;
421 char *fn, *options;
423 rc = 0;
424 fn = llist_pop(&m->deps); /* we leak it */
425 m2 = get_or_add_modentry(bb_get_last_path_component_nostrip(fn));
427 if (option_mask32 & OPT_REMOVE) {
428 /* modprobe -r */
429 if (m2->flags & MODULE_FLAG_LOADED) {
430 rc = bb_delete_module(m2->modname, O_NONBLOCK | O_EXCL);
431 if (rc) {
432 if (first) {
433 bb_error_msg("can't unload module %s: %s",
434 humanly_readable_name(m2),
435 moderror(rc));
436 break;
438 } else {
439 m2->flags &= ~MODULE_FLAG_LOADED;
442 /* do not error out if *deps* fail to unload */
443 first = 0;
444 continue;
447 options = m2->options;
448 m2->options = NULL;
449 options = parse_and_add_kcmdline_module_options(options, m2->modname);
450 if (m == m2)
451 options = gather_options_str(options, G.cmdline_mopts);
453 if (option_mask32 & OPT_SHOW_DEPS) {
454 printf(options ? "insmod %s/%s/%s %s\n"
455 : "insmod %s/%s/%s\n",
456 CONFIG_DEFAULT_MODULES_DIR, G.uts.release, fn,
457 options);
458 free(options);
459 continue;
462 if (m2->flags & MODULE_FLAG_LOADED) {
463 DBG("%s is already loaded, skipping", fn);
464 free(options);
465 continue;
468 rc = bb_init_module(fn, options);
469 DBG("loaded %s '%s', rc:%d", fn, options, rc);
470 if (rc == EEXIST)
471 rc = 0;
472 free(options);
473 if (rc) {
474 bb_error_msg("can't load module %s (%s): %s",
475 humanly_readable_name(m2),
477 moderror(rc)
479 break;
481 m2->flags |= MODULE_FLAG_LOADED;
484 return rc;
487 static void load_modules_dep(void)
489 struct module_entry *m;
490 char *colon, *tokens[2];
491 parser_t *p;
493 /* Modprobe does not work at all without modules.dep,
494 * even if the full module name is given. Returning error here
495 * was making us later confuse user with this message:
496 * "module /full/path/to/existing/file/module.ko not found".
497 * It's better to die immediately, with good message.
498 * xfopen_for_read provides that. */
499 p = config_open2(CONFIG_DEFAULT_DEPMOD_FILE, xfopen_for_read);
501 while (G.num_unresolved_deps
502 && config_read(p, tokens, 2, 1, "# \t", PARSE_NORMAL)
504 colon = last_char_is(tokens[0], ':');
505 if (colon == NULL)
506 continue;
507 *colon = '\0';
509 m = get_modentry(tokens[0]);
510 if (m == NULL)
511 continue;
513 /* Optimization... */
514 if ((m->flags & MODULE_FLAG_LOADED)
515 && !(option_mask32 & (OPT_REMOVE | OPT_SHOW_DEPS))
517 DBG("skip deps of %s, it's already loaded", tokens[0]);
518 continue;
521 m->flags |= MODULE_FLAG_FOUND_IN_MODDEP;
522 if ((m->flags & MODULE_FLAG_NEED_DEPS) && (m->deps == NULL)) {
523 G.num_unresolved_deps--;
524 llist_add_to(&m->deps, xstrdup(tokens[0]));
525 if (tokens[1])
526 string_to_llist(tokens[1], &m->deps, " \t");
527 } else
528 DBG("skipping dep line");
530 config_close(p);
533 int modprobe_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
534 int modprobe_main(int argc UNUSED_PARAM, char **argv)
536 int rc;
537 unsigned opt;
538 struct module_entry *me;
540 INIT_G();
542 IF_LONG_OPTS(applet_long_options = modprobe_longopts;)
543 opt_complementary = MODPROBE_COMPLEMENTARY;
544 opt = getopt32(argv, INSMOD_OPTS MODPROBE_OPTS INSMOD_ARGS);
545 argv += optind;
547 /* Goto modules location */
548 xchdir(CONFIG_DEFAULT_MODULES_DIR);
549 uname(&G.uts);
550 xchdir(G.uts.release);
552 if (opt & OPT_LIST_ONLY) {
553 int i;
554 char *colon, *tokens[2];
555 parser_t *p = config_open2(CONFIG_DEFAULT_DEPMOD_FILE, xfopen_for_read);
557 for (i = 0; argv[i]; i++)
558 replace(argv[i], '-', '_');
560 while (config_read(p, tokens, 2, 1, "# \t", PARSE_NORMAL)) {
561 colon = last_char_is(tokens[0], ':');
562 if (!colon)
563 continue;
564 *colon = '\0';
565 if (!argv[0])
566 puts(tokens[0]);
567 else {
568 char name[MODULE_NAME_LEN];
569 filename2modname(
570 bb_get_last_path_component_nostrip(tokens[0]),
571 name
573 for (i = 0; argv[i]; i++) {
574 if (fnmatch(argv[i], name, 0) == 0) {
575 puts(tokens[0]);
580 return EXIT_SUCCESS;
583 /* Yes, for some reason -l ignores -s... */
584 if (opt & INSMOD_OPT_SYSLOG)
585 logmode = LOGMODE_SYSLOG;
587 if (!argv[0]) {
588 if (opt & OPT_REMOVE) {
589 /* "modprobe -r" (w/o params).
590 * "If name is NULL, all unused modules marked
591 * autoclean will be removed".
593 if (bb_delete_module(NULL, O_NONBLOCK | O_EXCL) != 0)
594 bb_perror_msg_and_die("rmmod");
596 return EXIT_SUCCESS;
599 /* Retrieve module names of already loaded modules */
601 char *s;
602 parser_t *parser = config_open2("/proc/modules", fopen_for_read);
603 while (config_read(parser, &s, 1, 1, "# \t", PARSE_NORMAL & ~PARSE_GREEDY))
604 get_or_add_modentry(s)->flags |= MODULE_FLAG_LOADED;
605 config_close(parser);
608 if (opt & (OPT_INSERT_ALL | OPT_REMOVE)) {
609 /* Each argument is a module name */
610 do {
611 DBG("adding module %s", *argv);
612 add_probe(*argv++);
613 } while (*argv);
614 } else {
615 /* First argument is module name, rest are parameters */
616 DBG("probing just module %s", *argv);
617 add_probe(argv[0]);
618 G.cmdline_mopts = parse_cmdline_module_options(argv, /*quote_spaces:*/ 1);
621 /* Happens if all requested modules are already loaded */
622 if (G.probes == NULL)
623 return EXIT_SUCCESS;
625 read_config("/etc/modprobe.conf");
626 read_config("/etc/modprobe.d");
627 if (ENABLE_FEATURE_MODUTILS_SYMBOLS && G.need_symbols)
628 read_config("modules.symbols");
629 load_modules_dep();
630 if (ENABLE_FEATURE_MODUTILS_ALIAS && G.num_unresolved_deps) {
631 read_config("modules.alias");
632 load_modules_dep();
635 rc = 0;
636 while ((me = llist_pop(&G.probes)) != NULL) {
637 if (me->realnames == NULL) {
638 DBG("probing by module name");
639 /* This is not an alias. Literal names are blacklisted
640 * only if '-b' is given.
642 if (!(opt & OPT_BLACKLIST)
643 || !(me->flags & MODULE_FLAG_BLACKLISTED)
645 rc |= do_modprobe(me);
647 continue;
650 /* Probe all real names for the alias */
651 do {
652 char *realname = llist_pop(&me->realnames);
653 struct module_entry *m2;
655 DBG("probing alias %s by realname %s", me->modname, realname);
656 m2 = get_or_add_modentry(realname);
657 if (!(m2->flags & MODULE_FLAG_BLACKLISTED)
658 && (!(m2->flags & MODULE_FLAG_LOADED)
659 || (opt & (OPT_REMOVE | OPT_SHOW_DEPS)))
661 //TODO: we can pass "me" as 2nd param to do_modprobe,
662 //and make do_modprobe emit more meaningful error messages
663 //with alias name included, not just module name alias resolves to.
664 rc |= do_modprobe(m2);
666 free(realname);
667 } while (me->realnames != NULL);
670 return (rc != 0);