aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modutils/modprobe.c7
-rw-r--r--modutils/modutils.c5
-rw-r--r--modutils/rmmod.c12
3 files changed, 15 insertions, 9 deletions
diff --git a/modutils/modprobe.c b/modutils/modprobe.c
index 314a7a1cb..952ba0377 100644
--- a/modutils/modprobe.c
+++ b/modutils/modprobe.c
@@ -461,9 +461,8 @@ static int do_modprobe(struct module_entry *m)
461 rc = bb_delete_module(m2->modname, O_EXCL); 461 rc = bb_delete_module(m2->modname, O_EXCL);
462 if (rc) { 462 if (rc) {
463 if (first) { 463 if (first) {
464 bb_error_msg("can't unload module %s: %s", 464 bb_perror_msg("can't unload module %s",
465 humanly_readable_name(m2), 465 humanly_readable_name(m2));
466 moderror(rc));
467 break; 466 break;
468 } 467 }
469 } else { 468 } else {
@@ -622,7 +621,7 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
622 * autoclean will be removed". 621 * autoclean will be removed".
623 */ 622 */
624 if (bb_delete_module(NULL, O_NONBLOCK | O_EXCL) != 0) 623 if (bb_delete_module(NULL, O_NONBLOCK | O_EXCL) != 0)
625 bb_perror_msg_and_die("rmmod"); 624 bb_perror_nomsg_and_die();
626 } 625 }
627 return EXIT_SUCCESS; 626 return EXIT_SUCCESS;
628 } 627 }
diff --git a/modutils/modutils.c b/modutils/modutils.c
index 84300d931..ef4134af5 100644
--- a/modutils/modutils.c
+++ b/modutils/modutils.c
@@ -190,6 +190,11 @@ int FAST_FUNC bb_delete_module(const char *module, unsigned int flags)
190 return errno; 190 return errno;
191} 191}
192 192
193/* Note: not suitable for delete_module() errnos.
194 * For them, probably only EWOULDBLOCK needs explaining:
195 * "Other modules depend on us". So far we don't do such
196 * translation and don't use moderror() for removal errors.
197 */
193const char* FAST_FUNC moderror(int err) 198const char* FAST_FUNC moderror(int err)
194{ 199{
195 switch (err) { 200 switch (err) {
diff --git a/modutils/rmmod.c b/modutils/rmmod.c
index f13ff9eb6..5c353ef95 100644
--- a/modutils/rmmod.c
+++ b/modutils/rmmod.c
@@ -28,7 +28,7 @@
28int rmmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 28int rmmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
29int rmmod_main(int argc UNUSED_PARAM, char **argv) 29int rmmod_main(int argc UNUSED_PARAM, char **argv)
30{ 30{
31 int n; 31 int n, err;
32 unsigned flags = O_NONBLOCK | O_EXCL; 32 unsigned flags = O_NONBLOCK | O_EXCL;
33 33
34 /* Parse command line. */ 34 /* Parse command line. */
@@ -40,7 +40,8 @@ int rmmod_main(int argc UNUSED_PARAM, char **argv)
40 flags |= O_TRUNC; 40 flags |= O_TRUNC;
41 if (n & 4) { 41 if (n & 4) {
42 /* Unload _all_ unused modules via NULL delete_module() call */ 42 /* Unload _all_ unused modules via NULL delete_module() call */
43 if (bb_delete_module(NULL, flags) != 0 && errno != EFAULT) 43 err = bb_delete_module(NULL, flags);
44 if (err && err != EFAULT)
44 bb_perror_msg_and_die("rmmod"); 45 bb_perror_msg_and_die("rmmod");
45 return EXIT_SUCCESS; 46 return EXIT_SUCCESS;
46 } 47 }
@@ -58,9 +59,10 @@ int rmmod_main(int argc UNUSED_PARAM, char **argv)
58 safe_strncpy(modname, bname, MODULE_NAME_LEN); 59 safe_strncpy(modname, bname, MODULE_NAME_LEN);
59 else 60 else
60 filename2modname(bname, modname); 61 filename2modname(bname, modname);
61 if (bb_delete_module(modname, flags)) 62 err = bb_delete_module(modname, flags);
62 bb_error_msg_and_die("can't unload '%s': %s", 63 if (err)
63 modname, moderror(errno)); 64 bb_perror_msg_and_die("can't unload module '%s'",
65 modname);
64 } 66 }
65 67
66 return EXIT_SUCCESS; 68 return EXIT_SUCCESS;