summaryrefslogtreecommitdiff
path: root/modutils
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2003-06-20 09:56:37 +0000
committerEric Andersen <andersen@codepoet.org>2003-06-20 09:56:37 +0000
commit908e362133ed337f6adace218a236ff2bcf345ca (patch)
tree7c098f5c748fbee12067ad04168a5af7ca151407 /modutils
parent9d7f0f0fe86be9228db02e672ff5f0b2b4abfff9 (diff)
downloadbusybox-908e362133ed337f6adace218a236ff2bcf345ca.tar.gz
Patch from Andrew Dennison:
I've had some issues with modprobe which I reported a few months ago. This is still an issue so I decided to sort it out. The attached diff includes the changes against the unstable cvs tree that work for me. Changes are: mod_process() will report success if the module at the head of the list loads successfully. It will also report success if any module unloads successfully. The net result being that modprobe will succeed in the cases outlined below. I've also added error reporting to modprobe -r. Previously it would silently fail (but report success) if the module could not be unloaded. Andrew
Diffstat (limited to 'modutils')
-rw-r--r--modutils/modprobe.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/modutils/modprobe.c b/modutils/modprobe.c
index 154e66224..13f17b869 100644
--- a/modutils/modprobe.c
+++ b/modutils/modprobe.c
@@ -3,6 +3,7 @@
* Modprobe written from scratch for BusyBox
*
* Copyright (c) 2002 by Robert Griebl, griebl@gmx.de
+ * Copyright (c) 2003 by Andrew Dennison, andrew.dennison@motec.com.au
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -317,10 +318,7 @@ static struct dep_t *build_dep ( void )
static int mod_process ( struct mod_list_t *list, int do_insert )
{
char lcmd [256];
- int rc = 0;
-
- if ( !list )
- return 1;
+ int rc = 1;
while ( list ) {
if ( do_insert )
@@ -330,12 +328,15 @@ static int mod_process ( struct mod_list_t *list, int do_insert )
if ( verbose )
printf ( "%s\n", lcmd );
- if ( !show_only )
- rc |= system ( lcmd );
+ if ( !show_only ) {
+ int rc2 = system ( lcmd );
+ if (do_insert) rc = rc2; /* only last module matters */
+ else if (!rc2) rc = 0; /* success if remove any mod */
+ }
list = do_insert ? list-> m_prev : list-> m_next;
}
- return rc;
+ return (show_only) ? 0 : rc;
}
static void check_dep ( char *mod, struct mod_list_t **head, struct mod_list_t **tail )
@@ -429,7 +430,7 @@ static int mod_insert ( char *mod, int argc, char **argv )
{
struct mod_list_t *tail = 0;
struct mod_list_t *head = 0;
- int rc = 0;
+ int rc;
// get dep list for module mod
check_dep ( mod, &head, &tail );
@@ -453,7 +454,7 @@ static int mod_insert ( char *mod, int argc, char **argv )
}
// process tail ---> head
- rc |= mod_process ( tail, 1 );
+ rc = mod_process ( tail, 1 );
}
else
rc = 1;
@@ -461,8 +462,9 @@ static int mod_insert ( char *mod, int argc, char **argv )
return rc;
}
-static void mod_remove ( char *mod )
+static int mod_remove ( char *mod )
{
+ int rc;
static struct mod_list_t rm_a_dummy = { "-a", 0, 0 };
struct mod_list_t *head = 0;
@@ -474,7 +476,11 @@ static void mod_remove ( char *mod )
head = tail = &rm_a_dummy;
if ( head && tail )
- mod_process ( head, 0 ); // process head ---> tail
+ rc = mod_process ( head, 0 ); // process head ---> tail
+ else
+ rc = 1;
+ return rc;
+
}
@@ -530,11 +536,17 @@ extern int modprobe_main(int argc, char** argv)
bb_error_msg_and_die ( "could not parse modules.dep\n" );
if (remove_opt) {
+ int rc = EXIT_SUCCESS;
do {
- mod_remove ( optind < argc ? bb_xstrdup ( argv [optind] ) : NULL );
+ if (mod_remove ( optind < argc ?
+ bb_xstrdup (argv [optind]) : NULL )) {
+ bb_error_msg ("failed to remove module %s",
+ argv [optind] );
+ rc = EXIT_FAILURE;
+ }
} while ( ++optind < argc );
- return EXIT_SUCCESS;
+ return rc;
}
if (optind >= argc)