diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-05-28 03:54:29 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-05-28 03:54:29 +0200 |
commit | f3cbfc0e2c2486e14ad099b8075293857c4890e8 (patch) | |
tree | 89d299561d91e3c0244c6c37f7a1507da083eb68 | |
parent | 398c65997050ffadf0f445a8f858b74e0355753d (diff) | |
download | busybox-w32-f3cbfc0e2c2486e14ad099b8075293857c4890e8.tar.gz busybox-w32-f3cbfc0e2c2486e14ad099b8075293857c4890e8.tar.bz2 busybox-w32-f3cbfc0e2c2486e14ad099b8075293857c4890e8.zip |
modprobe: fix more bugs in modprobe -r
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | modutils/modprobe.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/modutils/modprobe.c b/modutils/modprobe.c index 54cd84c6a..d000c9123 100644 --- a/modutils/modprobe.c +++ b/modutils/modprobe.c | |||
@@ -211,9 +211,9 @@ static int read_config(const char *path) | |||
211 | 211 | ||
212 | static int do_modprobe(struct module_entry *m) | 212 | static int do_modprobe(struct module_entry *m) |
213 | { | 213 | { |
214 | struct module_entry *m2; | 214 | struct module_entry *m2 = m2; /* for compiler */ |
215 | char *fn, *options; | 215 | char *fn, *options; |
216 | int rc = -1; | 216 | int rc, first; |
217 | llist_t *l; | 217 | llist_t *l; |
218 | 218 | ||
219 | if (!(m->flags & MODULE_FLAG_FOUND_IN_MODDEP)) { | 219 | if (!(m->flags & MODULE_FLAG_FOUND_IN_MODDEP)) { |
@@ -228,13 +228,22 @@ static int do_modprobe(struct module_entry *m) | |||
228 | for (l = m->deps; l != NULL; l = l->link) | 228 | for (l = m->deps; l != NULL; l = l->link) |
229 | DBG("dep: %s", l->data); | 229 | DBG("dep: %s", l->data); |
230 | 230 | ||
231 | first = 1; | ||
231 | rc = 0; | 232 | rc = 0; |
232 | while (m->deps && rc == 0) { | 233 | while (m->deps && rc == 0) { |
233 | fn = llist_pop(&m->deps); | 234 | fn = llist_pop(&m->deps); |
234 | m2 = get_or_add_modentry(fn); | 235 | m2 = get_or_add_modentry(fn); |
235 | if (option_mask32 & MODPROBE_OPT_REMOVE) { | 236 | if (option_mask32 & MODPROBE_OPT_REMOVE) { |
236 | if (bb_delete_module(m->modname, O_EXCL) != 0) | 237 | if (m2->flags & MODULE_FLAG_LOADED) { |
237 | 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; | ||
238 | } else if (!(m2->flags & MODULE_FLAG_LOADED)) { | 247 | } else if (!(m2->flags & MODULE_FLAG_LOADED)) { |
239 | options = m2->options; | 248 | options = m2->options; |
240 | m2->options = NULL; | 249 | m2->options = NULL; |
@@ -252,11 +261,10 @@ static int do_modprobe(struct module_entry *m) | |||
252 | free(fn); | 261 | free(fn); |
253 | } | 262 | } |
254 | 263 | ||
255 | //FIXME: what if rc < 0? | 264 | if (rc && !(option_mask32 & INSMOD_OPT_SILENT)) { |
256 | if (rc > 0 && !(option_mask32 & INSMOD_OPT_SILENT)) { | ||
257 | bb_error_msg("failed to %sload module %s: %s", | 265 | bb_error_msg("failed to %sload module %s: %s", |
258 | (option_mask32 & MODPROBE_OPT_REMOVE) ? "un" : "", | 266 | (option_mask32 & MODPROBE_OPT_REMOVE) ? "un" : "", |
259 | m->probed_name ? m->probed_name : m->modname, | 267 | m2->probed_name ? m2->probed_name : m2->modname, |
260 | moderror(rc) | 268 | moderror(rc) |
261 | ); | 269 | ); |
262 | } | 270 | } |