diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-06-22 00:47:18 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-06-22 00:47:18 +0200 |
| commit | fbb12ddc6a53ad97ff6bcc7ed9b253c09001ad2f (patch) | |
| tree | 94c82f9eac30c86a1ec4f4d06f6c17b72b47cf3e /modutils | |
| parent | b6bca7703bbe6aacec0bda964c82fad389a02b69 (diff) | |
| download | busybox-w32-1_14_2.tar.gz busybox-w32-1_14_2.tar.bz2 busybox-w32-1_14_2.zip | |
post 1.14.1 fixes; bump version to 1.14.21_14_2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'modutils')
| -rw-r--r-- | modutils/modprobe-small.c | 2 | ||||
| -rw-r--r-- | modutils/modprobe.c | 39 | ||||
| -rw-r--r-- | modutils/modutils.c | 2 |
3 files changed, 32 insertions, 11 deletions
diff --git a/modutils/modprobe-small.c b/modutils/modprobe-small.c index 6eb950f32..6ee0164c2 100644 --- a/modutils/modprobe-small.c +++ b/modutils/modprobe-small.c | |||
| @@ -656,7 +656,7 @@ depmod -[aA] [-n -e -v -q -V -r -u] | |||
| 656 | [-b basedirectory] [forced_version] | 656 | [-b basedirectory] [forced_version] |
| 657 | depmod [-n -e -v -q -r -u] [-F kernelsyms] module1.ko module2.ko ... | 657 | depmod [-n -e -v -q -r -u] [-F kernelsyms] module1.ko module2.ko ... |
| 658 | If no arguments (except options) are given, "depmod -a" is assumed. | 658 | If no arguments (except options) are given, "depmod -a" is assumed. |
| 659 | depmod will output a dependancy list suitable for the modprobe utility. | 659 | depmod will output a dependency list suitable for the modprobe utility. |
| 660 | Options: | 660 | Options: |
| 661 | -a, --all Probe all modules | 661 | -a, --all Probe all modules |
| 662 | -A, --quick Only does the work if there's a new module | 662 | -A, --quick Only does the work if there's a new module |
diff --git a/modutils/modprobe.c b/modutils/modprobe.c index 0339ebb40..310eebc5f 100644 --- a/modutils/modprobe.c +++ b/modutils/modprobe.c | |||
| @@ -8,12 +8,17 @@ | |||
| 8 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | 8 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | /* Note that unlike older versions of modules.dep/depmod (busybox and m-i-t), | ||
| 12 | * we expect the full dependency list to be specified in modules.dep. Older | ||
| 13 | * versions would only export the direct dependency list. | ||
| 14 | */ | ||
| 15 | |||
| 11 | #include "libbb.h" | 16 | #include "libbb.h" |
| 12 | #include "modutils.h" | 17 | #include "modutils.h" |
| 13 | #include <sys/utsname.h> | 18 | #include <sys/utsname.h> |
| 14 | #include <fnmatch.h> | 19 | #include <fnmatch.h> |
| 15 | 20 | ||
| 16 | //#define DBG(...) bb_error_msg(__VA_ARGS__) | 21 | //#define DBG(fmt, ...) bb_error_msg("%s: " fmt, __func__, ## __VA_ARGS__) |
| 17 | #define DBG(...) ((void)0) | 22 | #define DBG(...) ((void)0) |
| 18 | 23 | ||
| 19 | #define MODULE_FLAG_LOADED 0x0001 | 24 | #define MODULE_FLAG_LOADED 0x0001 |
| @@ -116,6 +121,7 @@ static void add_probe(const char *name) | |||
| 116 | return; | 121 | return; |
| 117 | } | 122 | } |
| 118 | 123 | ||
| 124 | DBG("queuing %s", name); | ||
| 119 | m->probed_name = name; | 125 | m->probed_name = name; |
| 120 | m->flags |= MODULE_FLAG_NEED_DEPS; | 126 | m->flags |= MODULE_FLAG_NEED_DEPS; |
| 121 | llist_add_to_end(&G.probes, m); | 127 | llist_add_to_end(&G.probes, m); |
| @@ -205,9 +211,10 @@ static int read_config(const char *path) | |||
| 205 | 211 | ||
| 206 | static int do_modprobe(struct module_entry *m) | 212 | static int do_modprobe(struct module_entry *m) |
| 207 | { | 213 | { |
| 208 | struct module_entry *m2; | 214 | struct module_entry *m2 = m2; /* for compiler */ |
| 209 | char *fn, *options; | 215 | char *fn, *options; |
| 210 | int rc = -1; | 216 | int rc, first; |
| 217 | llist_t *l; | ||
| 211 | 218 | ||
| 212 | if (!(m->flags & MODULE_FLAG_FOUND_IN_MODDEP)) { | 219 | if (!(m->flags & MODULE_FLAG_FOUND_IN_MODDEP)) { |
| 213 | DBG("skipping %s, not found in modules.dep", m->modname); | 220 | DBG("skipping %s, not found in modules.dep", m->modname); |
| @@ -218,13 +225,25 @@ static int do_modprobe(struct module_entry *m) | |||
| 218 | if (!(option_mask32 & MODPROBE_OPT_REMOVE)) | 225 | if (!(option_mask32 & MODPROBE_OPT_REMOVE)) |
| 219 | m->deps = llist_rev(m->deps); | 226 | m->deps = llist_rev(m->deps); |
| 220 | 227 | ||
| 228 | for (l = m->deps; l != NULL; l = l->link) | ||
| 229 | DBG("dep: %s", l->data); | ||
| 230 | |||
| 231 | first = 1; | ||
| 221 | rc = 0; | 232 | rc = 0; |
| 222 | while (m->deps && rc == 0) { | 233 | while (m->deps && rc == 0) { |
| 223 | fn = llist_pop(&m->deps); | 234 | fn = llist_pop(&m->deps); |
| 224 | m2 = get_or_add_modentry(fn); | 235 | m2 = get_or_add_modentry(fn); |
| 225 | if (option_mask32 & MODPROBE_OPT_REMOVE) { | 236 | if (option_mask32 & MODPROBE_OPT_REMOVE) { |
| 226 | if (bb_delete_module(m->modname, O_EXCL) != 0) | 237 | if (m2->flags & MODULE_FLAG_LOADED) { |
| 227 | rc = errno; | 238 | if (bb_delete_module(m2->modname, O_EXCL) != 0) { |
| 239 | if (first) | ||
| 240 | rc = errno; | ||
| 241 | } else { | ||
| 242 | m2->flags &= ~MODULE_FLAG_LOADED; | ||
| 243 | } | ||
| 244 | } | ||
| 245 | /* do not error out if *deps* fail to unload */ | ||
| 246 | first = 0; | ||
| 228 | } else if (!(m2->flags & MODULE_FLAG_LOADED)) { | 247 | } else if (!(m2->flags & MODULE_FLAG_LOADED)) { |
| 229 | options = m2->options; | 248 | options = m2->options; |
| 230 | m2->options = NULL; | 249 | m2->options = NULL; |
| @@ -242,11 +261,10 @@ static int do_modprobe(struct module_entry *m) | |||
| 242 | free(fn); | 261 | free(fn); |
| 243 | } | 262 | } |
| 244 | 263 | ||
| 245 | //FIXME: what if rc < 0? | 264 | if (rc && !(option_mask32 & INSMOD_OPT_SILENT)) { |
| 246 | if (rc > 0 && !(option_mask32 & INSMOD_OPT_SILENT)) { | ||
| 247 | bb_error_msg("failed to %sload module %s: %s", | 265 | bb_error_msg("failed to %sload module %s: %s", |
| 248 | (option_mask32 & MODPROBE_OPT_REMOVE) ? "un" : "", | 266 | (option_mask32 & MODPROBE_OPT_REMOVE) ? "un" : "", |
| 249 | m->probed_name ? m->probed_name : m->modname, | 267 | m2->probed_name ? m2->probed_name : m2->modname, |
| 250 | moderror(rc) | 268 | moderror(rc) |
| 251 | ); | 269 | ); |
| 252 | } | 270 | } |
| @@ -294,7 +312,8 @@ static void load_modules_dep(void) | |||
| 294 | llist_add_to(&m->deps, xstrdup(tokens[0])); | 312 | llist_add_to(&m->deps, xstrdup(tokens[0])); |
| 295 | if (tokens[1]) | 313 | if (tokens[1]) |
| 296 | string_to_llist(tokens[1], &m->deps, " "); | 314 | string_to_llist(tokens[1], &m->deps, " "); |
| 297 | } | 315 | } else |
| 316 | DBG("skipping dep line"); | ||
| 298 | } | 317 | } |
| 299 | config_close(p); | 318 | config_close(p); |
| 300 | } | 319 | } |
| @@ -344,10 +363,12 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv) | |||
| 344 | if (opt & (MODPROBE_OPT_INSERT_ALL | MODPROBE_OPT_REMOVE)) { | 363 | if (opt & (MODPROBE_OPT_INSERT_ALL | MODPROBE_OPT_REMOVE)) { |
| 345 | /* Each argument is a module name */ | 364 | /* Each argument is a module name */ |
| 346 | do { | 365 | do { |
| 366 | DBG("adding module %s", *argv); | ||
| 347 | add_probe(*argv++); | 367 | add_probe(*argv++); |
| 348 | } while (*argv); | 368 | } while (*argv); |
| 349 | } else { | 369 | } else { |
| 350 | /* First argument is module name, rest are parameters */ | 370 | /* First argument is module name, rest are parameters */ |
| 371 | DBG("probing just module %s", *argv); | ||
| 351 | add_probe(argv[0]); | 372 | add_probe(argv[0]); |
| 352 | G.cmdline_mopts = parse_cmdline_module_options(argv); | 373 | G.cmdline_mopts = parse_cmdline_module_options(argv); |
| 353 | } | 374 | } |
diff --git a/modutils/modutils.c b/modutils/modutils.c index 0f6cb0f2d..f437a9829 100644 --- a/modutils/modutils.c +++ b/modutils/modutils.c | |||
| @@ -57,7 +57,7 @@ char * FAST_FUNC filename2modname(const char *filename, char *modname) | |||
| 57 | from = bb_get_last_path_component_nostrip(filename); | 57 | from = bb_get_last_path_component_nostrip(filename); |
| 58 | for (i = 0; i < (MODULE_NAME_LEN-1) && from[i] != '\0' && from[i] != '.'; i++) | 58 | for (i = 0; i < (MODULE_NAME_LEN-1) && from[i] != '\0' && from[i] != '.'; i++) |
| 59 | modname[i] = (from[i] == '-') ? '_' : from[i]; | 59 | modname[i] = (from[i] == '-') ? '_' : from[i]; |
| 60 | modname[i] = 0; | 60 | modname[i] = '\0'; |
| 61 | 61 | ||
| 62 | return modname; | 62 | return modname; |
| 63 | } | 63 | } |
