modprobe: reformat to match bbox style
This commit is contained in:
@ -7,9 +7,6 @@
|
|||||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <sys/utsname.h> /* for uname(2) */
|
#include <sys/utsname.h> /* for uname(2) */
|
||||||
|
|
||||||
#include "libbb.h"
|
#include "libbb.h"
|
||||||
@ -27,7 +24,7 @@ int get_linux_version_code(void)
|
|||||||
|
|
||||||
if (uname(&name) == -1) {
|
if (uname(&name) == -1) {
|
||||||
bb_perror_msg("cannot get system information");
|
bb_perror_msg("cannot get system information");
|
||||||
return (0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
s = name.release;
|
s = name.release;
|
||||||
|
@ -147,9 +147,9 @@ static char *parse_command_string( char *src, char **dst )
|
|||||||
* here but what is too much is freed later. */
|
* here but what is too much is freed later. */
|
||||||
*dst = tmp_str = xstrdup(src);
|
*dst = tmp_str = xstrdup(src);
|
||||||
/* Get to the end of that argument */
|
/* Get to the end of that argument */
|
||||||
while( ( *tmp_str != '\0' )
|
while (*tmp_str != '\0'
|
||||||
&& ( ( *tmp_str != ' ' )
|
&& (*tmp_str != ' ' || (opt_status & (ARG_IN_DQUOTES | ARG_IN_SQUOTES)))
|
||||||
|| ( opt_status & ( ARG_IN_DQUOTES | ARG_IN_SQUOTES ) ) ) ) {
|
) {
|
||||||
switch (*tmp_str) {
|
switch (*tmp_str) {
|
||||||
case '\'':
|
case '\'':
|
||||||
if (opt_status & ARG_IN_DQUOTES) {
|
if (opt_status & ARG_IN_DQUOTES) {
|
||||||
@ -263,10 +263,10 @@ static void include_conf ( struct dep_t **first, struct dep_t **current, char *b
|
|||||||
if (parse_tag_value(buffer + 6, &alias, &mod)) {
|
if (parse_tag_value(buffer + 6, &alias, &mod)) {
|
||||||
/* handle alias as a module dependent on the aliased module */
|
/* handle alias as a module dependent on the aliased module */
|
||||||
if (!*current) {
|
if (!*current) {
|
||||||
(*first) = (*current) = (struct dep_t *) xzalloc (sizeof ( struct dep_t ));
|
(*first) = (*current) = xzalloc(sizeof(struct dep_t));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
(*current)-> m_next = (struct dep_t *) xzalloc (sizeof ( struct dep_t ));
|
(*current)->m_next = xzalloc(sizeof(struct dep_t));
|
||||||
(*current) = (*current)->m_next;
|
(*current) = (*current)->m_next;
|
||||||
}
|
}
|
||||||
(*current)->m_name = xstrdup(alias);
|
(*current)->m_name = xstrdup(alias);
|
||||||
@ -338,10 +338,10 @@ static struct dep_t *build_dep ( void )
|
|||||||
int continuation_line = 0;
|
int continuation_line = 0;
|
||||||
int k_version;
|
int k_version;
|
||||||
|
|
||||||
k_version = 0;
|
|
||||||
if (uname(&un))
|
if (uname(&un))
|
||||||
bb_error_msg_and_die("can't determine kernel version");
|
bb_error_msg_and_die("can't determine kernel version");
|
||||||
|
|
||||||
|
k_version = 0;
|
||||||
if (un.release[0] == '2') {
|
if (un.release[0] == '2') {
|
||||||
k_version = un.release[2] - '0';
|
k_version = un.release[2] - '0';
|
||||||
}
|
}
|
||||||
@ -352,7 +352,8 @@ static struct dep_t *build_dep ( void )
|
|||||||
free(filename);
|
free(filename);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
/* Ok, that didn't work. Fall back to looking in /lib/modules */
|
/* Ok, that didn't work. Fall back to looking in /lib/modules */
|
||||||
if (( fd = open ( "/lib/modules/modules.dep", O_RDONLY )) < 0 ) {
|
fd = open("/lib/modules/modules.dep", O_RDONLY);
|
||||||
|
if (fd < 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -409,10 +410,10 @@ static struct dep_t *build_dep ( void )
|
|||||||
|
|
||||||
/* enqueue new module */
|
/* enqueue new module */
|
||||||
if (!current) {
|
if (!current) {
|
||||||
first = current = (struct dep_t *) xmalloc ( sizeof ( struct dep_t ));
|
first = current = xmalloc(sizeof(struct dep_t));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
current-> m_next = (struct dep_t *) xmalloc ( sizeof ( struct dep_t ));
|
current->m_next = xmalloc(sizeof(struct dep_t));
|
||||||
current = current->m_next;
|
current = current->m_next;
|
||||||
}
|
}
|
||||||
current->m_name = mod;
|
current->m_name = mod;
|
||||||
@ -447,12 +448,10 @@ static struct dep_t *build_dep ( void )
|
|||||||
while (isblank(*end) || (*end == '\\'))
|
while (isblank(*end) || (*end == '\\'))
|
||||||
end--;
|
end--;
|
||||||
|
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
/* search the end of the dependency */
|
/* search the end of the dependency */
|
||||||
next = strchr(p, ' ');
|
next = strchr(p, ' ');
|
||||||
if (next)
|
if (next) {
|
||||||
{
|
|
||||||
*next = 0;
|
*next = 0;
|
||||||
next--;
|
next--;
|
||||||
}
|
}
|
||||||
@ -467,14 +466,13 @@ static struct dep_t *build_dep ( void )
|
|||||||
|
|
||||||
while (isblank(*deps))
|
while (isblank(*deps))
|
||||||
deps++;
|
deps++;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
deps++;
|
deps++;
|
||||||
|
|
||||||
/* find the end of the module name in the file name */
|
/* find the end of the module name in the file name */
|
||||||
if ( ENABLE_FEATURE_2_6_MODULES &&
|
if (ENABLE_FEATURE_2_6_MODULES
|
||||||
(k_version > 4) && ( *(next-2) == '.' ) &&
|
&& (k_version > 4) && (*(next-2) == '.')
|
||||||
( *(next-1) == 'k' ) && ( *next == 'o' ) )
|
&& (*(next-1) == 'k') && (*next == 'o'))
|
||||||
ext = 3;
|
ext = 3;
|
||||||
else
|
else
|
||||||
if ((*(next-1) == '.') && (*next == 'o'))
|
if ((*(next-1) == '.') && (*next == 'o'))
|
||||||
@ -487,7 +485,7 @@ static struct dep_t *build_dep ( void )
|
|||||||
|
|
||||||
/* Add the new dependable module name */
|
/* Add the new dependable module name */
|
||||||
current->m_depcnt++;
|
current->m_depcnt++;
|
||||||
current-> m_deparr = (char **) xrealloc ( current-> m_deparr,
|
current->m_deparr = xrealloc(current->m_deparr,
|
||||||
sizeof(char *) * current->m_depcnt);
|
sizeof(char *) * current->m_depcnt);
|
||||||
current->m_deparr[current->m_depcnt - 1] = dep;
|
current->m_deparr[current->m_depcnt - 1] = dep;
|
||||||
|
|
||||||
@ -521,7 +519,8 @@ static struct dep_t *build_dep ( void )
|
|||||||
if (ENABLE_FEATURE_2_6_MODULES) {
|
if (ENABLE_FEATURE_2_6_MODULES) {
|
||||||
/* Parse kernel-declared aliases */
|
/* Parse kernel-declared aliases */
|
||||||
filename = xasprintf("/lib/modules/%s/modules.alias", un.release);
|
filename = xasprintf("/lib/modules/%s/modules.alias", un.release);
|
||||||
if ((fd = open ( filename, O_RDONLY )) < 0) {
|
fd = open(filename, O_RDONLY);
|
||||||
|
if (fd < 0) {
|
||||||
/* Ok, that didn't work. Fall back to looking in /lib/modules */
|
/* Ok, that didn't work. Fall back to looking in /lib/modules */
|
||||||
fd = open("/lib/modules/modules.alias", O_RDONLY);
|
fd = open("/lib/modules/modules.alias", O_RDONLY);
|
||||||
}
|
}
|
||||||
@ -601,7 +600,7 @@ static int mod_process ( struct mod_list_t *list, int do_insert )
|
|||||||
* would not load because there is no more memory, so there's no
|
* would not load because there is no more memory, so there's no
|
||||||
* problem. */
|
* problem. */
|
||||||
/* enough for minimal insmod (5 args + NULL) or rmmod (3 args + NULL) */
|
/* enough for minimal insmod (5 args + NULL) or rmmod (3 args + NULL) */
|
||||||
argv = (char**) malloc( 6 * sizeof( char* ) );
|
argv = xmalloc(6 * sizeof(char*));
|
||||||
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";
|
||||||
@ -622,7 +621,7 @@ static int mod_process ( struct mod_list_t *list, int do_insert )
|
|||||||
while (opts) {
|
while (opts) {
|
||||||
/* Add one more option */
|
/* Add one more option */
|
||||||
argc++;
|
argc++;
|
||||||
argv = (char**) xrealloc( argv, ( argc + 1 ) * sizeof( char* ) );
|
argv = xrealloc(argv,(argc + 1)* sizeof(char*));
|
||||||
argv[argc-1] = opts->m_opt_val;
|
argv[argc-1] = opts->m_opt_val;
|
||||||
opts = opts->m_next;
|
opts = opts->m_next;
|
||||||
}
|
}
|
||||||
@ -654,13 +653,14 @@ static int mod_process ( struct mod_list_t *list, int do_insert )
|
|||||||
rc = 0; /* success if remove any mod */
|
rc = 0; /* success if remove any mod */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( ENABLE_FEATURE_CLEAN_UP )
|
if (ENABLE_FEATURE_CLEAN_UP) {
|
||||||
/* the last value in the array has index == argc, but
|
/* the last value in the array has index == argc, but
|
||||||
* it is the terminating NULL, so we must not free it. */
|
* it is the terminating NULL, so we must not free it. */
|
||||||
while (argc_malloc < argc) {
|
while (argc_malloc < argc) {
|
||||||
free(argv[argc_malloc++]);
|
free(argv[argc_malloc++]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (ENABLE_FEATURE_CLEAN_UP) {
|
if (ENABLE_FEATURE_CLEAN_UP) {
|
||||||
free(argv);
|
free(argv);
|
||||||
argv = NULL;
|
argv = NULL;
|
||||||
@ -783,7 +783,7 @@ static void check_dep ( char *mod, struct mod_list_t **head, struct mod_list_t *
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!find) { // did not find a duplicate
|
if (!find) { // did not find a duplicate
|
||||||
find = (struct mod_list_t *) xmalloc ( sizeof(struct mod_list_t));
|
find = xmalloc(sizeof(struct mod_list_t));
|
||||||
find->m_name = mod;
|
find->m_name = mod;
|
||||||
find->m_path = path;
|
find->m_path = path;
|
||||||
find->m_options = opt;
|
find->m_options = opt;
|
||||||
@ -872,9 +872,9 @@ int modprobe_main(int argc, char** argv)
|
|||||||
opt_complementary = "?V-:q-v:v-q";
|
opt_complementary = "?V-:q-v:v-q";
|
||||||
main_opts = getopt32(argc, argv, "acdklnqrst:vVC:",
|
main_opts = getopt32(argc, argv, "acdklnqrst:vVC:",
|
||||||
&unused, &unused);
|
&unused, &unused);
|
||||||
if((main_opts & (DUMP_CONF_EXIT | LIST_ALL)))
|
if (main_opts & (DUMP_CONF_EXIT | LIST_ALL))
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
if((main_opts & (RESTRICT_DIR | CONFIG_FILE)))
|
if (main_opts & (RESTRICT_DIR | CONFIG_FILE))
|
||||||
bb_error_msg_and_die("-t and -C not supported");
|
bb_error_msg_and_die("-t and -C not supported");
|
||||||
|
|
||||||
depend = build_dep();
|
depend = build_dep();
|
||||||
|
Reference in New Issue
Block a user