Attempt at fixing bug 836, vaguely based on patch from somebody named

clausmuus, forwarded to me by Yann E. Morin.
This commit is contained in:
Rob Landley 2006-06-14 01:51:16 +00:00
parent a34b48abe5
commit d760560c52

View File

@ -574,7 +574,7 @@ static struct dep_t *build_dep ( void )
/* return 1 = loaded, 0 = not loaded, -1 = can't tell */ /* return 1 = loaded, 0 = not loaded, -1 = can't tell */
static int already_loaded (const char *name) static int already_loaded (const char *name)
{ {
int fd; int fd, ret = 0;
char buffer[4096]; char buffer[4096];
fd = open ("/proc/modules", O_RDONLY); fd = open ("/proc/modules", O_RDONLY);
@ -586,17 +586,28 @@ static int already_loaded (const char *name)
p = strchr (buffer, ' '); p = strchr (buffer, ' ');
if (p) { if (p) {
const char *n;
// Truncate buffer at first space and check for matches, with
// the idiosyncrasy that _ and - are interchangeable because the
// 2.6 kernel does weird things.
*p = 0; *p = 0;
for( p = buffer; ENABLE_FEATURE_2_6_MODULES && *p; p++ ) { for (p = buffer, n = name; ; p++, n++) {
*p = ((*p)=='-')?'_':*p; if (*p != *n) {
} if ((*p == '_' || *p == '-') && (*n == '_' || *n == '-'))
if (strcmp (name, buffer) == 0) { continue;
close (fd); break;
return 1; }
// If we made it to the end, that's a match.
if (!*p) {
ret = 1;
goto done;
}
} }
} }
} }
done:
close (fd); close (fd);
return 0; return 0;
} }
@ -628,14 +639,16 @@ static int mod_process ( struct mod_list_t *list, int do_insert )
if ( do_insert ) { if ( do_insert ) {
if (already_loaded (list->m_name) != 1) { if (already_loaded (list->m_name) != 1) {
argv[argc++] = "insmod"; argv[argc++] = "insmod";
if (do_syslog) if (ENABLE_FEATURE_2_4_MODULES) {
argv[argc++] = "-s"; if (do_syslog)
if (autoclean) argv[argc++] = "-s";
argv[argc++] = "-k"; if (autoclean)
if (quiet) argv[argc++] = "-k";
argv[argc++] = "-q"; if (quiet)
else if(verbose) /* verbose and quiet are mutually exclusive */ argv[argc++] = "-q";
argv[argc++] = "-v"; else if(verbose) /* verbose and quiet are mutually exclusive */
argv[argc++] = "-v";
}
argv[argc++] = list-> m_path; argv[argc++] = list-> m_path;
if( ENABLE_FEATURE_CLEAN_UP ) if( ENABLE_FEATURE_CLEAN_UP )
argc_malloc = argc; argc_malloc = argc;