diff options
author | Rob Landley <rob@landley.net> | 2006-06-14 01:51:16 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2006-06-14 01:51:16 +0000 |
commit | d760560c5284f4e36d03772cc6f3bfb8aaeaef56 (patch) | |
tree | 9da2794baee4600e70f033002e03d4a2775b3f85 /modutils | |
parent | a34b48abe511b0e469d8b74f99902cc4df45d93d (diff) | |
download | busybox-w32-d760560c5284f4e36d03772cc6f3bfb8aaeaef56.tar.gz busybox-w32-d760560c5284f4e36d03772cc6f3bfb8aaeaef56.tar.bz2 busybox-w32-d760560c5284f4e36d03772cc6f3bfb8aaeaef56.zip |
Attempt at fixing bug 836, vaguely based on patch from somebody named
clausmuus, forwarded to me by Yann E. Morin.
Diffstat (limited to 'modutils')
-rw-r--r-- | modutils/modprobe.c | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/modutils/modprobe.c b/modutils/modprobe.c index 698eed84a..14da0a729 100644 --- a/modutils/modprobe.c +++ b/modutils/modprobe.c | |||
@@ -574,7 +574,7 @@ static struct dep_t *build_dep ( void ) | |||
574 | /* return 1 = loaded, 0 = not loaded, -1 = can't tell */ | 574 | /* return 1 = loaded, 0 = not loaded, -1 = can't tell */ |
575 | static int already_loaded (const char *name) | 575 | static int already_loaded (const char *name) |
576 | { | 576 | { |
577 | int fd; | 577 | int fd, ret = 0; |
578 | char buffer[4096]; | 578 | char buffer[4096]; |
579 | 579 | ||
580 | fd = open ("/proc/modules", O_RDONLY); | 580 | fd = open ("/proc/modules", O_RDONLY); |
@@ -586,17 +586,28 @@ static int already_loaded (const char *name) | |||
586 | 586 | ||
587 | p = strchr (buffer, ' '); | 587 | p = strchr (buffer, ' '); |
588 | if (p) { | 588 | if (p) { |
589 | const char *n; | ||
590 | |||
591 | // Truncate buffer at first space and check for matches, with | ||
592 | // the idiosyncrasy that _ and - are interchangeable because the | ||
593 | // 2.6 kernel does weird things. | ||
594 | |||
589 | *p = 0; | 595 | *p = 0; |
590 | for( p = buffer; ENABLE_FEATURE_2_6_MODULES && *p; p++ ) { | 596 | for (p = buffer, n = name; ; p++, n++) { |
591 | *p = ((*p)=='-')?'_':*p; | 597 | if (*p != *n) { |
592 | } | 598 | if ((*p == '_' || *p == '-') && (*n == '_' || *n == '-')) |
593 | if (strcmp (name, buffer) == 0) { | 599 | continue; |
594 | close (fd); | 600 | break; |
595 | return 1; | 601 | } |
602 | // If we made it to the end, that's a match. | ||
603 | if (!*p) { | ||
604 | ret = 1; | ||
605 | goto done; | ||
606 | } | ||
596 | } | 607 | } |
597 | } | 608 | } |
598 | } | 609 | } |
599 | 610 | done: | |
600 | close (fd); | 611 | close (fd); |
601 | return 0; | 612 | return 0; |
602 | } | 613 | } |
@@ -628,14 +639,16 @@ static int mod_process ( struct mod_list_t *list, int do_insert ) | |||
628 | if ( do_insert ) { | 639 | if ( do_insert ) { |
629 | if (already_loaded (list->m_name) != 1) { | 640 | if (already_loaded (list->m_name) != 1) { |
630 | argv[argc++] = "insmod"; | 641 | argv[argc++] = "insmod"; |
631 | if (do_syslog) | 642 | if (ENABLE_FEATURE_2_4_MODULES) { |
632 | argv[argc++] = "-s"; | 643 | if (do_syslog) |
633 | if (autoclean) | 644 | argv[argc++] = "-s"; |
634 | argv[argc++] = "-k"; | 645 | if (autoclean) |
635 | if (quiet) | 646 | argv[argc++] = "-k"; |
636 | argv[argc++] = "-q"; | 647 | if (quiet) |
637 | else if(verbose) /* verbose and quiet are mutually exclusive */ | 648 | argv[argc++] = "-q"; |
638 | argv[argc++] = "-v"; | 649 | else if(verbose) /* verbose and quiet are mutually exclusive */ |
650 | argv[argc++] = "-v"; | ||
651 | } | ||
639 | argv[argc++] = list-> m_path; | 652 | argv[argc++] = list-> m_path; |
640 | if( ENABLE_FEATURE_CLEAN_UP ) | 653 | if( ENABLE_FEATURE_CLEAN_UP ) |
641 | argc_malloc = argc; | 654 | argc_malloc = argc; |