Busybox modprobe has a couple of irritating quirks:
- attempting to modprobe a module that is already loaded yields "Failed to load module", whereas modutils quietly ignores such a request. - if a module genuinely can't be loaded due to missing symbols or similar problems, modprobe doesn't produce any useful diagnostics because the output from insmod has been redirected to /dev/null. Here's a patch to address these issue Patch by Philip Blundell
This commit is contained in:
parent
d6bdd5dc08
commit
350733abb8
@ -319,6 +319,32 @@ static struct dep_t *build_dep ( void )
|
|||||||
return first;
|
return first;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* return 1 = loaded, 0 = not loaded, -1 = can't tell */
|
||||||
|
static int already_loaded (const char *name)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
char buffer[256];
|
||||||
|
|
||||||
|
fd = open ("/proc/modules", O_RDONLY);
|
||||||
|
if (fd < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
while ( reads ( fd, buffer, sizeof( buffer ))) {
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
p = strchr (buffer, ' ');
|
||||||
|
if (p) {
|
||||||
|
*p = 0;
|
||||||
|
if (strcmp (name, buffer) == 0) {
|
||||||
|
close (fd);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
close (fd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int mod_process ( struct mod_list_t *list, int do_insert )
|
static int mod_process ( struct mod_list_t *list, int do_insert )
|
||||||
{
|
{
|
||||||
@ -326,10 +352,13 @@ static int mod_process ( struct mod_list_t *list, int do_insert )
|
|||||||
int rc = 1;
|
int rc = 1;
|
||||||
|
|
||||||
while ( list ) {
|
while ( list ) {
|
||||||
if ( do_insert )
|
if ( do_insert ) {
|
||||||
snprintf ( lcmd, sizeof( lcmd ) - 1, "insmod %s %s %s %s %s 2>/dev/null", do_syslog ? "-s" : "", autoclean ? "-k" : "", quiet ? "-q" : "", list-> m_module, list-> m_options ? list-> m_options : "" );
|
if (already_loaded (list->m_module) != 1)
|
||||||
else
|
snprintf ( lcmd, sizeof( lcmd ) - 1, "insmod %s %s %s %s %s", do_syslog ? "-s" : "", autoclean ? "-k" : "", quiet ? "-q" : "", list-> m_module, list-> m_options ? list-> m_options : "" );
|
||||||
snprintf ( lcmd, sizeof( lcmd ) - 1, "rmmod %s %s 2>/dev/null", do_syslog ? "-s" : "", list-> m_module );
|
} else {
|
||||||
|
if (already_loaded (list->m_module) != 0)
|
||||||
|
snprintf ( lcmd, sizeof( lcmd ) - 1, "rmmod %s %s", do_syslog ? "-s" : "", list-> m_module );
|
||||||
|
}
|
||||||
|
|
||||||
if ( verbose )
|
if ( verbose )
|
||||||
printf ( "%s\n", lcmd );
|
printf ( "%s\n", lcmd );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user