modprobe: reformat to match bbox style
This commit is contained in:
parent
82f9e28513
commit
cf70433173
@ -7,9 +7,6 @@
|
||||
* 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 "libbb.h"
|
||||
@ -27,7 +24,7 @@ int get_linux_version_code(void)
|
||||
|
||||
if (uname(&name) == -1) {
|
||||
bb_perror_msg("cannot get system information");
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
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. */
|
||||
*dst = tmp_str = xstrdup(src);
|
||||
/* Get to the end of that argument */
|
||||
while( ( *tmp_str != '\0' )
|
||||
&& ( ( *tmp_str != ' ' )
|
||||
|| ( opt_status & ( ARG_IN_DQUOTES | ARG_IN_SQUOTES ) ) ) ) {
|
||||
while (*tmp_str != '\0'
|
||||
&& (*tmp_str != ' ' || (opt_status & (ARG_IN_DQUOTES | ARG_IN_SQUOTES)))
|
||||
) {
|
||||
switch (*tmp_str) {
|
||||
case '\'':
|
||||
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)) {
|
||||
/* handle alias as a module dependent on the aliased module */
|
||||
if (!*current) {
|
||||
(*first) = (*current) = (struct dep_t *) xzalloc (sizeof ( struct dep_t ));
|
||||
(*first) = (*current) = xzalloc(sizeof(struct dep_t));
|
||||
}
|
||||
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)->m_name = xstrdup(alias);
|
||||
@ -338,10 +338,10 @@ static struct dep_t *build_dep ( void )
|
||||
int continuation_line = 0;
|
||||
int k_version;
|
||||
|
||||
k_version = 0;
|
||||
if (uname(&un))
|
||||
bb_error_msg_and_die("can't determine kernel version");
|
||||
|
||||
k_version = 0;
|
||||
if (un.release[0] == '2') {
|
||||
k_version = un.release[2] - '0';
|
||||
}
|
||||
@ -352,7 +352,8 @@ static struct dep_t *build_dep ( void )
|
||||
free(filename);
|
||||
if (fd < 0) {
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
@ -409,10 +410,10 @@ static struct dep_t *build_dep ( void )
|
||||
|
||||
/* enqueue new module */
|
||||
if (!current) {
|
||||
first = current = (struct dep_t *) xmalloc ( sizeof ( struct dep_t ));
|
||||
first = current = xmalloc(sizeof(struct dep_t));
|
||||
}
|
||||
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->m_name = mod;
|
||||
@ -447,12 +448,10 @@ static struct dep_t *build_dep ( void )
|
||||
while (isblank(*end) || (*end == '\\'))
|
||||
end--;
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
/* search the end of the dependency */
|
||||
next = strchr(p, ' ');
|
||||
if (next)
|
||||
{
|
||||
if (next) {
|
||||
*next = 0;
|
||||
next--;
|
||||
}
|
||||
@ -467,14 +466,13 @@ static struct dep_t *build_dep ( void )
|
||||
|
||||
while (isblank(*deps))
|
||||
deps++;
|
||||
}
|
||||
else
|
||||
} else
|
||||
deps++;
|
||||
|
||||
/* find the end of the module name in the file name */
|
||||
if ( ENABLE_FEATURE_2_6_MODULES &&
|
||||
(k_version > 4) && ( *(next-2) == '.' ) &&
|
||||
( *(next-1) == 'k' ) && ( *next == 'o' ) )
|
||||
if (ENABLE_FEATURE_2_6_MODULES
|
||||
&& (k_version > 4) && (*(next-2) == '.')
|
||||
&& (*(next-1) == 'k') && (*next == 'o'))
|
||||
ext = 3;
|
||||
else
|
||||
if ((*(next-1) == '.') && (*next == 'o'))
|
||||
@ -487,7 +485,7 @@ static struct dep_t *build_dep ( void )
|
||||
|
||||
/* Add the new dependable module name */
|
||||
current->m_depcnt++;
|
||||
current-> m_deparr = (char **) xrealloc ( current-> m_deparr,
|
||||
current->m_deparr = xrealloc(current->m_deparr,
|
||||
sizeof(char *) * current->m_depcnt);
|
||||
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) {
|
||||
/* Parse kernel-declared aliases */
|
||||
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 */
|
||||
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
|
||||
* problem. */
|
||||
/* 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 (already_loaded(list->m_name) != 1) {
|
||||
argv[argc++] = "insmod";
|
||||
@ -622,7 +621,7 @@ static int mod_process ( struct mod_list_t *list, int do_insert )
|
||||
while (opts) {
|
||||
/* Add one more option */
|
||||
argc++;
|
||||
argv = (char**) xrealloc( argv, ( argc + 1 ) * sizeof( char* ) );
|
||||
argv = xrealloc(argv,(argc + 1)* sizeof(char*));
|
||||
argv[argc-1] = opts->m_opt_val;
|
||||
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 */
|
||||
}
|
||||
}
|
||||
if( ENABLE_FEATURE_CLEAN_UP )
|
||||
if (ENABLE_FEATURE_CLEAN_UP) {
|
||||
/* the last value in the array has index == argc, but
|
||||
* it is the terminating NULL, so we must not free it. */
|
||||
while (argc_malloc < argc) {
|
||||
free(argv[argc_malloc++]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ENABLE_FEATURE_CLEAN_UP) {
|
||||
free(argv);
|
||||
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
|
||||
find = (struct mod_list_t *) xmalloc ( sizeof(struct mod_list_t));
|
||||
find = xmalloc(sizeof(struct mod_list_t));
|
||||
find->m_name = mod;
|
||||
find->m_path = path;
|
||||
find->m_options = opt;
|
||||
@ -872,9 +872,9 @@ int modprobe_main(int argc, char** argv)
|
||||
opt_complementary = "?V-:q-v:v-q";
|
||||
main_opts = getopt32(argc, argv, "acdklnqrst:vVC:",
|
||||
&unused, &unused);
|
||||
if((main_opts & (DUMP_CONF_EXIT | LIST_ALL)))
|
||||
if (main_opts & (DUMP_CONF_EXIT | LIST_ALL))
|
||||
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");
|
||||
|
||||
depend = build_dep();
|
||||
|
Loading…
Reference in New Issue
Block a user