aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 @@
3 * Modprobe written from scratch for BusyBox 3 * Modprobe written from scratch for BusyBox
4 * 4 *
5 * Copyright (c) 2002 by Robert Griebl, griebl@gmx.de 5 * Copyright (c) 2002 by Robert Griebl, griebl@gmx.de
6 * Copyright (c) 2003 by Andrew Dennison, andrew.dennison@motec.com.au
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
@@ -317,10 +318,7 @@ static struct dep_t *build_dep ( void )
317static int mod_process ( struct mod_list_t *list, int do_insert ) 318static int mod_process ( struct mod_list_t *list, int do_insert )
318{ 319{
319 char lcmd [256]; 320 char lcmd [256];
320 int rc = 0; 321 int rc = 1;
321
322 if ( !list )
323 return 1;
324 322
325 while ( list ) { 323 while ( list ) {
326 if ( do_insert ) 324 if ( do_insert )
@@ -330,12 +328,15 @@ static int mod_process ( struct mod_list_t *list, int do_insert )
330 328
331 if ( verbose ) 329 if ( verbose )
332 printf ( "%s\n", lcmd ); 330 printf ( "%s\n", lcmd );
333 if ( !show_only ) 331 if ( !show_only ) {
334 rc |= system ( lcmd ); 332 int rc2 = system ( lcmd );
333 if (do_insert) rc = rc2; /* only last module matters */
334 else if (!rc2) rc = 0; /* success if remove any mod */
335 }
335 336
336 list = do_insert ? list-> m_prev : list-> m_next; 337 list = do_insert ? list-> m_prev : list-> m_next;
337 } 338 }
338 return rc; 339 return (show_only) ? 0 : rc;
339} 340}
340 341
341static void check_dep ( char *mod, struct mod_list_t **head, struct mod_list_t **tail ) 342static 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 )
429{ 430{
430 struct mod_list_t *tail = 0; 431 struct mod_list_t *tail = 0;
431 struct mod_list_t *head = 0; 432 struct mod_list_t *head = 0;
432 int rc = 0; 433 int rc;
433 434
434 // get dep list for module mod 435 // get dep list for module mod
435 check_dep ( mod, &head, &tail ); 436 check_dep ( mod, &head, &tail );
@@ -453,7 +454,7 @@ static int mod_insert ( char *mod, int argc, char **argv )
453 } 454 }
454 455
455 // process tail ---> head 456 // process tail ---> head
456 rc |= mod_process ( tail, 1 ); 457 rc = mod_process ( tail, 1 );
457 } 458 }
458 else 459 else
459 rc = 1; 460 rc = 1;
@@ -461,8 +462,9 @@ static int mod_insert ( char *mod, int argc, char **argv )
461 return rc; 462 return rc;
462} 463}
463 464
464static void mod_remove ( char *mod ) 465static int mod_remove ( char *mod )
465{ 466{
467 int rc;
466 static struct mod_list_t rm_a_dummy = { "-a", 0, 0 }; 468 static struct mod_list_t rm_a_dummy = { "-a", 0, 0 };
467 469
468 struct mod_list_t *head = 0; 470 struct mod_list_t *head = 0;
@@ -474,7 +476,11 @@ static void mod_remove ( char *mod )
474 head = tail = &rm_a_dummy; 476 head = tail = &rm_a_dummy;
475 477
476 if ( head && tail ) 478 if ( head && tail )
477 mod_process ( head, 0 ); // process head ---> tail 479 rc = mod_process ( head, 0 ); // process head ---> tail
480 else
481 rc = 1;
482 return rc;
483
478} 484}
479 485
480 486
@@ -530,11 +536,17 @@ extern int modprobe_main(int argc, char** argv)
530 bb_error_msg_and_die ( "could not parse modules.dep\n" ); 536 bb_error_msg_and_die ( "could not parse modules.dep\n" );
531 537
532 if (remove_opt) { 538 if (remove_opt) {
539 int rc = EXIT_SUCCESS;
533 do { 540 do {
534 mod_remove ( optind < argc ? bb_xstrdup ( argv [optind] ) : NULL ); 541 if (mod_remove ( optind < argc ?
542 bb_xstrdup (argv [optind]) : NULL )) {
543 bb_error_msg ("failed to remove module %s",
544 argv [optind] );
545 rc = EXIT_FAILURE;
546 }
535 } while ( ++optind < argc ); 547 } while ( ++optind < argc );
536 548
537 return EXIT_SUCCESS; 549 return rc;
538 } 550 }
539 551
540 if (optind >= argc) 552 if (optind >= argc)