re-indent
This commit is contained in:
parent
d242e49c89
commit
3b1a74467a
1931
modutils/insmod.c
1931
modutils/insmod.c
File diff suppressed because it is too large
Load Diff
@ -36,20 +36,20 @@
|
|||||||
struct dep_t {
|
struct dep_t {
|
||||||
char * m_module;
|
char * m_module;
|
||||||
char * m_options;
|
char * m_options;
|
||||||
|
|
||||||
int m_isalias : 1;
|
int m_isalias : 1;
|
||||||
int m_reserved : 15;
|
int m_reserved : 15;
|
||||||
|
|
||||||
int m_depcnt : 16;
|
int m_depcnt : 16;
|
||||||
char ** m_deparr;
|
char ** m_deparr;
|
||||||
|
|
||||||
struct dep_t * m_next;
|
struct dep_t * m_next;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mod_list_t {
|
struct mod_list_t {
|
||||||
char * m_module;
|
char * m_module;
|
||||||
char * m_options;
|
char * m_options;
|
||||||
|
|
||||||
struct mod_list_t * m_prev;
|
struct mod_list_t * m_prev;
|
||||||
struct mod_list_t * m_next;
|
struct mod_list_t * m_next;
|
||||||
};
|
};
|
||||||
@ -74,7 +74,7 @@ int parse_tag_value ( char *buffer, char **ptag, char **pvalue )
|
|||||||
|
|
||||||
*ptag = tag;
|
*ptag = tag;
|
||||||
*pvalue = value;
|
*pvalue = value;
|
||||||
|
|
||||||
return bb_strlen( tag ) && bb_strlen( value );
|
return bb_strlen( tag ) && bb_strlen( value );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,16 +85,16 @@ int parse_tag_value ( char *buffer, char **ptag, char **pvalue )
|
|||||||
static char *reads ( int fd, char *buffer, size_t len )
|
static char *reads ( int fd, char *buffer, size_t len )
|
||||||
{
|
{
|
||||||
int n = read ( fd, buffer, len );
|
int n = read ( fd, buffer, len );
|
||||||
|
|
||||||
if ( n > 0 ) {
|
if ( n > 0 ) {
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
buffer [len-1] = 0;
|
buffer [len-1] = 0;
|
||||||
p = strchr ( buffer, '\n' );
|
p = strchr ( buffer, '\n' );
|
||||||
|
|
||||||
if ( p ) {
|
if ( p ) {
|
||||||
off_t offset;
|
off_t offset;
|
||||||
|
|
||||||
offset = lseek ( fd, 0L, SEEK_CUR ); // Get the current file descriptor offset
|
offset = lseek ( fd, 0L, SEEK_CUR ); // Get the current file descriptor offset
|
||||||
lseek ( fd, offset-n + (p-buffer) + 1, SEEK_SET ); // Set the file descriptor offset to right after the \n
|
lseek ( fd, offset-n + (p-buffer) + 1, SEEK_SET ); // Set the file descriptor offset to right after the \n
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ static char *reads ( int fd, char *buffer, size_t len )
|
|||||||
}
|
}
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -116,11 +116,11 @@ static struct dep_t *build_dep ( void )
|
|||||||
char buffer[256];
|
char buffer[256];
|
||||||
char *filename = buffer;
|
char *filename = buffer;
|
||||||
int continuation_line = 0;
|
int continuation_line = 0;
|
||||||
|
|
||||||
k_version = 0;
|
k_version = 0;
|
||||||
if ( uname ( &un ))
|
if ( uname ( &un ))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// check for buffer overflow in following code
|
// check for buffer overflow in following code
|
||||||
if ( bb_strlen ( un.release ) > ( sizeof( buffer ) - 64 )) {
|
if ( bb_strlen ( un.release ) > ( sizeof( buffer ) - 64 )) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -128,7 +128,7 @@ static struct dep_t *build_dep ( void )
|
|||||||
if (un.release[0] == '2') {
|
if (un.release[0] == '2') {
|
||||||
k_version = un.release[2] - '0';
|
k_version = un.release[2] - '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy ( filename, "/lib/modules/" );
|
strcpy ( filename, "/lib/modules/" );
|
||||||
strcat ( filename, un.release );
|
strcat ( filename, un.release );
|
||||||
strcat ( filename, "/modules.dep" );
|
strcat ( filename, "/modules.dep" );
|
||||||
@ -144,44 +144,44 @@ static struct dep_t *build_dep ( void )
|
|||||||
while ( reads ( fd, buffer, sizeof( buffer ))) {
|
while ( reads ( fd, buffer, sizeof( buffer ))) {
|
||||||
int l = bb_strlen ( buffer );
|
int l = bb_strlen ( buffer );
|
||||||
char *p = 0;
|
char *p = 0;
|
||||||
|
|
||||||
while ( isspace ( buffer [l-1] )) {
|
while ( isspace ( buffer [l-1] )) {
|
||||||
buffer [l-1] = 0;
|
buffer [l-1] = 0;
|
||||||
l--;
|
l--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( l == 0 ) {
|
if ( l == 0 ) {
|
||||||
continuation_line = 0;
|
continuation_line = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !continuation_line ) {
|
if ( !continuation_line ) {
|
||||||
char *col = strchr ( buffer, ':' );
|
char *col = strchr ( buffer, ':' );
|
||||||
|
|
||||||
if ( col ) {
|
if ( col ) {
|
||||||
char *mods;
|
char *mods;
|
||||||
char *mod;
|
char *mod;
|
||||||
int ext = 0;
|
int ext = 0;
|
||||||
|
|
||||||
*col = 0;
|
*col = 0;
|
||||||
mods = strrchr ( buffer, '/' );
|
mods = strrchr ( buffer, '/' );
|
||||||
|
|
||||||
if ( !mods )
|
if ( !mods )
|
||||||
mods = buffer;
|
mods = buffer;
|
||||||
else
|
else
|
||||||
mods++;
|
mods++;
|
||||||
|
|
||||||
#if defined(CONFIG_FEATURE_2_6_MODULES)
|
#if defined(CONFIG_FEATURE_2_6_MODULES)
|
||||||
if ((k_version > 4) && ( *(col-3) == '.' ) &&
|
if ((k_version > 4) && ( *(col-3) == '.' ) &&
|
||||||
( *(col-2) == 'k' ) && ( *(col-1) == 'o' ))
|
( *(col-2) == 'k' ) && ( *(col-1) == 'o' ))
|
||||||
ext = 3;
|
ext = 3;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
if (( *(col-2) == '.' ) && ( *(col-1) == 'o' ))
|
if (( *(col-2) == '.' ) && ( *(col-1) == 'o' ))
|
||||||
ext = 2;
|
ext = 2;
|
||||||
|
|
||||||
mod = bb_xstrndup ( mods, col - mods - ext );
|
mod = bb_xstrndup ( mods, col - mods - ext );
|
||||||
|
|
||||||
if ( !current ) {
|
if ( !current ) {
|
||||||
first = current = (struct dep_t *) xmalloc ( sizeof ( struct dep_t ));
|
first = current = (struct dep_t *) xmalloc ( sizeof ( struct dep_t ));
|
||||||
}
|
}
|
||||||
@ -195,9 +195,9 @@ static struct dep_t *build_dep ( void )
|
|||||||
current-> m_depcnt = 0;
|
current-> m_depcnt = 0;
|
||||||
current-> m_deparr = 0;
|
current-> m_deparr = 0;
|
||||||
current-> m_next = 0;
|
current-> m_next = 0;
|
||||||
|
|
||||||
//printf ( "%s:\n", mod );
|
//printf ( "%s:\n", mod );
|
||||||
|
|
||||||
p = col + 1;
|
p = col + 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -205,49 +205,49 @@ static struct dep_t *build_dep ( void )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
p = buffer;
|
p = buffer;
|
||||||
|
|
||||||
if ( p && *p ) {
|
if ( p && *p ) {
|
||||||
char *end = &buffer [l-1];
|
char *end = &buffer [l-1];
|
||||||
char *deps = strrchr ( end, '/' );
|
char *deps = strrchr ( end, '/' );
|
||||||
char *dep;
|
char *dep;
|
||||||
int ext = 0;
|
int ext = 0;
|
||||||
|
|
||||||
while ( isblank ( *end ) || ( *end == '\\' ))
|
while ( isblank ( *end ) || ( *end == '\\' ))
|
||||||
end--;
|
end--;
|
||||||
|
|
||||||
deps = strrchr ( p, '/' );
|
deps = strrchr ( p, '/' );
|
||||||
|
|
||||||
if ( !deps || ( deps < p )) {
|
if ( !deps || ( deps < p )) {
|
||||||
deps = p;
|
deps = p;
|
||||||
|
|
||||||
while ( isblank ( *deps ))
|
while ( isblank ( *deps ))
|
||||||
deps++;
|
deps++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
deps++;
|
deps++;
|
||||||
|
|
||||||
#if defined(CONFIG_FEATURE_2_6_MODULES)
|
#if defined(CONFIG_FEATURE_2_6_MODULES)
|
||||||
if ((k_version > 4) && ( *(end-2) == '.' ) && *(end-1) == 'k' &&
|
if ((k_version > 4) && ( *(end-2) == '.' ) && *(end-1) == 'k' &&
|
||||||
( *end == 'o' ))
|
( *end == 'o' ))
|
||||||
ext = 3;
|
ext = 3;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
if (( *(end-1) == '.' ) && ( *end == 'o' ))
|
if (( *(end-1) == '.' ) && ( *end == 'o' ))
|
||||||
ext = 2;
|
ext = 2;
|
||||||
|
|
||||||
/* Cope with blank lines */
|
/* Cope with blank lines */
|
||||||
if ((end-deps-ext+1) <= 0)
|
if ((end-deps-ext+1) <= 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
dep = bb_xstrndup ( deps, end - deps - ext + 1 );
|
dep = bb_xstrndup ( deps, end - deps - ext + 1 );
|
||||||
|
|
||||||
current-> m_depcnt++;
|
current-> m_depcnt++;
|
||||||
current-> m_deparr = (char **) xrealloc ( current-> m_deparr, sizeof ( char *) * current-> m_depcnt );
|
current-> m_deparr = (char **) xrealloc ( current-> m_deparr, sizeof ( char *) * current-> m_depcnt );
|
||||||
current-> m_deparr [current-> m_depcnt - 1] = dep;
|
current-> m_deparr [current-> m_depcnt - 1] = dep;
|
||||||
|
|
||||||
//printf ( " %d) %s\n", current-> m_depcnt, current-> m_deparr [current-> m_depcnt -1] );
|
//printf ( " %d) %s\n", current-> m_depcnt, current-> m_deparr [current-> m_depcnt -1] );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( buffer [l-1] == '\\' )
|
if ( buffer [l-1] == '\\' )
|
||||||
continuation_line = 1;
|
continuation_line = 1;
|
||||||
else
|
else
|
||||||
@ -260,35 +260,35 @@ static struct dep_t *build_dep ( void )
|
|||||||
if (( fd = open ( "/etc/modules.conf", O_RDONLY )) < 0 )
|
if (( fd = open ( "/etc/modules.conf", O_RDONLY )) < 0 )
|
||||||
if (( fd = open ( "/etc/conf.modules", O_RDONLY )) < 0 )
|
if (( fd = open ( "/etc/conf.modules", O_RDONLY )) < 0 )
|
||||||
return first;
|
return first;
|
||||||
|
|
||||||
continuation_line = 0;
|
continuation_line = 0;
|
||||||
while ( reads ( fd, buffer, sizeof( buffer ))) {
|
while ( reads ( fd, buffer, sizeof( buffer ))) {
|
||||||
int l;
|
int l;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
p = strchr ( buffer, '#' );
|
p = strchr ( buffer, '#' );
|
||||||
if ( p )
|
if ( p )
|
||||||
*p = 0;
|
*p = 0;
|
||||||
|
|
||||||
l = bb_strlen ( buffer );
|
l = bb_strlen ( buffer );
|
||||||
|
|
||||||
while ( l && isspace ( buffer [l-1] )) {
|
while ( l && isspace ( buffer [l-1] )) {
|
||||||
buffer [l-1] = 0;
|
buffer [l-1] = 0;
|
||||||
l--;
|
l--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( l == 0 ) {
|
if ( l == 0 ) {
|
||||||
continuation_line = 0;
|
continuation_line = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !continuation_line ) {
|
if ( !continuation_line ) {
|
||||||
if (( strncmp ( buffer, "alias", 5 ) == 0 ) && isspace ( buffer [5] )) {
|
if (( strncmp ( buffer, "alias", 5 ) == 0 ) && isspace ( buffer [5] )) {
|
||||||
char *alias, *mod;
|
char *alias, *mod;
|
||||||
|
|
||||||
if ( parse_tag_value ( buffer + 6, &alias, &mod )) {
|
if ( parse_tag_value ( buffer + 6, &alias, &mod )) {
|
||||||
// fprintf ( stderr, "ALIAS: '%s' -> '%s'\n", alias, mod );
|
// fprintf ( stderr, "ALIAS: '%s' -> '%s'\n", alias, mod );
|
||||||
|
|
||||||
if ( !current ) {
|
if ( !current ) {
|
||||||
first = current = (struct dep_t *) xmalloc ( sizeof ( struct dep_t ));
|
first = current = (struct dep_t *) xmalloc ( sizeof ( struct dep_t ));
|
||||||
}
|
}
|
||||||
@ -298,7 +298,7 @@ static struct dep_t *build_dep ( void )
|
|||||||
}
|
}
|
||||||
current-> m_module = bb_xstrdup ( alias );
|
current-> m_module = bb_xstrdup ( alias );
|
||||||
current-> m_isalias = 1;
|
current-> m_isalias = 1;
|
||||||
|
|
||||||
if (( strcmp ( alias, "off" ) == 0 ) || ( strcmp ( alias, "null" ) == 0 )) {
|
if (( strcmp ( alias, "off" ) == 0 ) || ( strcmp ( alias, "null" ) == 0 )) {
|
||||||
current-> m_depcnt = 0;
|
current-> m_depcnt = 0;
|
||||||
current-> m_deparr = 0;
|
current-> m_deparr = 0;
|
||||||
@ -313,10 +313,10 @@ static struct dep_t *build_dep ( void )
|
|||||||
}
|
}
|
||||||
else if (( strncmp ( buffer, "options", 7 ) == 0 ) && isspace ( buffer [7] )) {
|
else if (( strncmp ( buffer, "options", 7 ) == 0 ) && isspace ( buffer [7] )) {
|
||||||
char *mod, *opt;
|
char *mod, *opt;
|
||||||
|
|
||||||
if ( parse_tag_value ( buffer + 8, &mod, &opt )) {
|
if ( parse_tag_value ( buffer + 8, &mod, &opt )) {
|
||||||
struct dep_t *dt;
|
struct dep_t *dt;
|
||||||
|
|
||||||
for ( dt = first; dt; dt = dt-> m_next ) {
|
for ( dt = first; dt; dt = dt-> m_next ) {
|
||||||
if ( strcmp ( dt-> m_module, mod ) == 0 )
|
if ( strcmp ( dt-> m_module, mod ) == 0 )
|
||||||
break;
|
break;
|
||||||
@ -324,7 +324,7 @@ static struct dep_t *build_dep ( void )
|
|||||||
if ( dt ) {
|
if ( dt ) {
|
||||||
dt-> m_options = xrealloc ( dt-> m_options, bb_strlen( opt ) + 1 );
|
dt-> m_options = xrealloc ( dt-> m_options, bb_strlen( opt ) + 1 );
|
||||||
strcpy ( dt-> m_options, opt );
|
strcpy ( dt-> m_options, opt );
|
||||||
|
|
||||||
// fprintf ( stderr, "OPTION: '%s' -> '%s'\n", dt-> m_module, dt-> m_options );
|
// fprintf ( stderr, "OPTION: '%s' -> '%s'\n", dt-> m_module, dt-> m_options );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -332,7 +332,7 @@ static struct dep_t *build_dep ( void )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
close ( fd );
|
close ( fd );
|
||||||
|
|
||||||
return first;
|
return first;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -377,7 +377,7 @@ static int mod_process ( struct mod_list_t *list, int do_insert )
|
|||||||
if (already_loaded (list->m_module) != 0)
|
if (already_loaded (list->m_module) != 0)
|
||||||
snprintf ( lcmd, sizeof( lcmd ) - 1, "rmmod %s %s", do_syslog ? "-s" : "", list-> m_module );
|
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 );
|
||||||
if ( !show_only && *lcmd) {
|
if ( !show_only && *lcmd) {
|
||||||
@ -385,7 +385,7 @@ static int mod_process ( struct mod_list_t *list, int do_insert )
|
|||||||
if (do_insert) rc = rc2; /* only last module matters */
|
if (do_insert) rc = rc2; /* only last module matters */
|
||||||
else if (!rc2) rc = 0; /* success if remove any mod */
|
else if (!rc2) rc = 0; /* success if remove any mod */
|
||||||
}
|
}
|
||||||
|
|
||||||
list = do_insert ? list-> m_prev : list-> m_next;
|
list = do_insert ? list-> m_prev : list-> m_next;
|
||||||
}
|
}
|
||||||
return (show_only) ? 0 : rc;
|
return (show_only) ? 0 : rc;
|
||||||
@ -403,12 +403,12 @@ static void check_dep ( char *mod, struct mod_list_t **head, struct mod_list_t *
|
|||||||
|
|
||||||
#if defined(CONFIG_FEATURE_2_6_MODULES)
|
#if defined(CONFIG_FEATURE_2_6_MODULES)
|
||||||
if ((k_version > 4) && ( mod [lm-3] == '.' ) &&
|
if ((k_version > 4) && ( mod [lm-3] == '.' ) &&
|
||||||
( mod [lm-2] == 'k' ) && ( mod [lm-1] == 'o' ))
|
( mod [lm-2] == 'k' ) && ( mod [lm-1] == 'o' ))
|
||||||
mod [lm-3] = 0;
|
mod [lm-3] = 0;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
if (( mod [lm-2] == '.' ) && ( mod [lm-1] == 'o' ))
|
if (( mod [lm-2] == '.' ) && ( mod [lm-1] == 'o' ))
|
||||||
mod [lm-2] = 0;
|
mod [lm-2] = 0;
|
||||||
|
|
||||||
// check dependencies
|
// check dependencies
|
||||||
for ( dt = depend; dt; dt = dt-> m_next ) {
|
for ( dt = depend; dt; dt = dt-> m_next ) {
|
||||||
@ -417,12 +417,12 @@ static void check_dep ( char *mod, struct mod_list_t **head, struct mod_list_t *
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// resolve alias names
|
// resolve alias names
|
||||||
while ( dt && dt-> m_isalias ) {
|
while ( dt && dt-> m_isalias ) {
|
||||||
if ( dt-> m_depcnt == 1 ) {
|
if ( dt-> m_depcnt == 1 ) {
|
||||||
struct dep_t *adt;
|
struct dep_t *adt;
|
||||||
|
|
||||||
for ( adt = depend; adt; adt = adt-> m_next ) {
|
for ( adt = depend; adt; adt = adt-> m_next ) {
|
||||||
if ( strcmp ( adt-> m_module, dt-> m_deparr [0] ) == 0 )
|
if ( strcmp ( adt-> m_module, dt-> m_deparr [0] ) == 0 )
|
||||||
break;
|
break;
|
||||||
@ -439,7 +439,7 @@ static void check_dep ( char *mod, struct mod_list_t **head, struct mod_list_t *
|
|||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// search for duplicates
|
// search for duplicates
|
||||||
for ( find = *head; find; find = find-> m_next ) {
|
for ( find = *head; find; find = find-> m_next ) {
|
||||||
if ( !strcmp ( mod, find-> m_module )) {
|
if ( !strcmp ( mod, find-> m_module )) {
|
||||||
@ -449,12 +449,12 @@ static void check_dep ( char *mod, struct mod_list_t **head, struct mod_list_t *
|
|||||||
find-> m_prev-> m_next = find-> m_next;
|
find-> m_prev-> m_next = find-> m_next;
|
||||||
else
|
else
|
||||||
*head = find-> m_next;
|
*head = find-> m_next;
|
||||||
|
|
||||||
if ( find-> m_next )
|
if ( find-> m_next )
|
||||||
find-> m_next-> m_prev = find-> m_prev;
|
find-> m_next-> m_prev = find-> m_prev;
|
||||||
else
|
else
|
||||||
*tail = find-> m_prev;
|
*tail = find-> m_prev;
|
||||||
|
|
||||||
break; // there can be only one duplicate
|
break; // there can be only one duplicate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -474,10 +474,10 @@ static void check_dep ( char *mod, struct mod_list_t **head, struct mod_list_t *
|
|||||||
if ( !*head )
|
if ( !*head )
|
||||||
*head = find;
|
*head = find;
|
||||||
*tail = find;
|
*tail = find;
|
||||||
|
|
||||||
if ( dt ) {
|
if ( dt ) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for ( i = 0; i < dt-> m_depcnt; i++ )
|
for ( i = 0; i < dt-> m_depcnt; i++ )
|
||||||
check_dep ( dt-> m_deparr [i], head, tail );
|
check_dep ( dt-> m_deparr [i], head, tail );
|
||||||
}
|
}
|
||||||
@ -490,34 +490,34 @@ static int mod_insert ( char *mod, int argc, char **argv )
|
|||||||
struct mod_list_t *tail = 0;
|
struct mod_list_t *tail = 0;
|
||||||
struct mod_list_t *head = 0;
|
struct mod_list_t *head = 0;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
// get dep list for module mod
|
// get dep list for module mod
|
||||||
check_dep ( mod, &head, &tail );
|
check_dep ( mod, &head, &tail );
|
||||||
|
|
||||||
if ( head && tail ) {
|
if ( head && tail ) {
|
||||||
if ( argc ) {
|
if ( argc ) {
|
||||||
int i;
|
int i;
|
||||||
int l = 0;
|
int l = 0;
|
||||||
|
|
||||||
// append module args
|
// append module args
|
||||||
for ( i = 0; i < argc; i++ )
|
for ( i = 0; i < argc; i++ )
|
||||||
l += ( bb_strlen ( argv [i] ) + 1 );
|
l += ( bb_strlen ( argv [i] ) + 1 );
|
||||||
|
|
||||||
head-> m_options = xrealloc ( head-> m_options, l + 1 );
|
head-> m_options = xrealloc ( head-> m_options, l + 1 );
|
||||||
head-> m_options [0] = 0;
|
head-> m_options [0] = 0;
|
||||||
|
|
||||||
for ( i = 0; i < argc; i++ ) {
|
for ( i = 0; i < argc; i++ ) {
|
||||||
strcat ( head-> m_options, argv [i] );
|
strcat ( head-> m_options, argv [i] );
|
||||||
strcat ( head-> m_options, " " );
|
strcat ( head-> m_options, " " );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// process tail ---> head
|
// process tail ---> head
|
||||||
rc = mod_process ( tail, 1 );
|
rc = mod_process ( tail, 1 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
rc = 1;
|
rc = 1;
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -525,21 +525,21 @@ static int mod_remove ( char *mod )
|
|||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
static struct mod_list_t rm_a_dummy = { "-a", 0, 0 };
|
static struct mod_list_t rm_a_dummy = { "-a", 0, 0 };
|
||||||
|
|
||||||
struct mod_list_t *head = 0;
|
struct mod_list_t *head = 0;
|
||||||
struct mod_list_t *tail = 0;
|
struct mod_list_t *tail = 0;
|
||||||
|
|
||||||
if ( mod )
|
if ( mod )
|
||||||
check_dep ( mod, &head, &tail );
|
check_dep ( mod, &head, &tail );
|
||||||
else // autoclean
|
else // autoclean
|
||||||
head = tail = &rm_a_dummy;
|
head = tail = &rm_a_dummy;
|
||||||
|
|
||||||
if ( head && tail )
|
if ( head && tail )
|
||||||
rc = mod_process ( head, 0 ); // process head ---> tail
|
rc = mod_process ( head, 0 ); // process head ---> tail
|
||||||
else
|
else
|
||||||
rc = 1;
|
rc = 1;
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -553,67 +553,67 @@ extern int modprobe_main(int argc, char** argv)
|
|||||||
|
|
||||||
while ((opt = getopt(argc, argv, "acdklnqrst:vVC:")) != -1) {
|
while ((opt = getopt(argc, argv, "acdklnqrst:vVC:")) != -1) {
|
||||||
switch(opt) {
|
switch(opt) {
|
||||||
case 'c': // no config used
|
case 'c': // no config used
|
||||||
case 'l': // no pattern matching
|
case 'l': // no pattern matching
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
break;
|
break;
|
||||||
case 'C': // no config used
|
case 'C': // no config used
|
||||||
case 't': // no pattern matching
|
case 't': // no pattern matching
|
||||||
bb_error_msg_and_die("-t and -C not supported");
|
bb_error_msg_and_die("-t and -C not supported");
|
||||||
|
|
||||||
case 'a': // ignore
|
case 'a': // ignore
|
||||||
case 'd': // ignore
|
case 'd': // ignore
|
||||||
break;
|
break;
|
||||||
case 'k':
|
case 'k':
|
||||||
autoclean++;
|
autoclean++;
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
show_only++;
|
show_only++;
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
quiet++;
|
quiet++;
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
remove_opt++;
|
remove_opt++;
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
do_syslog++;
|
do_syslog++;
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
verbose++;
|
verbose++;
|
||||||
break;
|
break;
|
||||||
case 'V':
|
case 'V':
|
||||||
default:
|
default:
|
||||||
bb_show_usage();
|
bb_show_usage();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
depend = build_dep ( );
|
depend = build_dep ( );
|
||||||
|
|
||||||
if ( !depend )
|
if ( !depend )
|
||||||
bb_error_msg_and_die ( "could not parse modules.dep\n" );
|
bb_error_msg_and_die ( "could not parse modules.dep\n" );
|
||||||
|
|
||||||
if (remove_opt) {
|
if (remove_opt) {
|
||||||
int rc = EXIT_SUCCESS;
|
int rc = EXIT_SUCCESS;
|
||||||
do {
|
do {
|
||||||
if (mod_remove ( optind < argc ?
|
if (mod_remove ( optind < argc ?
|
||||||
bb_xstrdup (argv [optind]) : NULL )) {
|
bb_xstrdup (argv [optind]) : NULL )) {
|
||||||
bb_error_msg ("failed to remove module %s",
|
bb_error_msg ("failed to remove module %s",
|
||||||
argv [optind] );
|
argv [optind] );
|
||||||
rc = EXIT_FAILURE;
|
rc = EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
} while ( ++optind < argc );
|
} while ( ++optind < argc );
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optind >= argc)
|
if (optind >= argc)
|
||||||
bb_error_msg_and_die ( "No module or pattern provided\n" );
|
bb_error_msg_and_die ( "No module or pattern provided\n" );
|
||||||
|
|
||||||
if ( mod_insert ( bb_xstrdup ( argv [optind] ), argc - optind - 1, argv + optind + 1 ))
|
if ( mod_insert ( bb_xstrdup ( argv [optind] ), argc - optind - 1, argv + optind + 1 ))
|
||||||
bb_error_msg_and_die ( "failed to load module %s", argv [optind] );
|
bb_error_msg_and_die ( "failed to load module %s", argv [optind] );
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ extern int rmmod_main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (optind == argc)
|
if (optind == argc)
|
||||||
bb_show_usage();
|
bb_show_usage();
|
||||||
|
|
||||||
for (n = optind; n < argc; n++) {
|
for (n = optind; n < argc; n++) {
|
||||||
if (syscall(__NR_delete_module, argv[n], flags) < 0) {
|
if (syscall(__NR_delete_module, argv[n], flags) < 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user