aboutsummaryrefslogtreecommitdiff
path: root/modutils/modprobe.c
diff options
context:
space:
mode:
Diffstat (limited to 'modutils/modprobe.c')
-rw-r--r--modutils/modprobe.c35
1 files changed, 13 insertions, 22 deletions
diff --git a/modutils/modprobe.c b/modutils/modprobe.c
index b11e58d55..5a94c7c92 100644
--- a/modutils/modprobe.c
+++ b/modutils/modprobe.c
@@ -13,15 +13,6 @@
13 13
14#include "busybox.h" 14#include "busybox.h"
15#include <sys/utsname.h> 15#include <sys/utsname.h>
16#include <sys/types.h>
17#include <sys/wait.h>
18#include <getopt.h>
19#include <stdlib.h>
20#include <unistd.h>
21#include <syslog.h>
22#include <string.h>
23#include <ctype.h>
24#include <fcntl.h>
25#include <fnmatch.h> 16#include <fnmatch.h>
26 17
27struct mod_opt_t { /* one-way list of options to pass to a module */ 18struct mod_opt_t { /* one-way list of options to pass to a module */
@@ -148,7 +139,7 @@ static struct mod_opt_t *append_option( struct mod_opt_t *opt_list, char *opt )
148 ol = opt_list = xmalloc( sizeof( struct mod_opt_t ) ); 139 ol = opt_list = xmalloc( sizeof( struct mod_opt_t ) );
149 } 140 }
150 141
151 ol-> m_opt_val = bb_xstrdup( opt ); 142 ol-> m_opt_val = xstrdup( opt );
152 ol-> m_next = NULL; 143 ol-> m_next = NULL;
153 144
154 return opt_list; 145 return opt_list;
@@ -160,7 +151,7 @@ static struct mod_opt_t *append_option( struct mod_opt_t *opt_list, char *opt )
160 * dst: pointer to where to store the parsed argument 151 * dst: pointer to where to store the parsed argument
161 * return value: the pointer to the first char after the parsed argument, 152 * return value: the pointer to the first char after the parsed argument,
162 * NULL if there was no argument parsed (only trailing spaces). 153 * NULL if there was no argument parsed (only trailing spaces).
163 * Note that memory is allocated with bb_xstrdup when a new argument was 154 * Note that memory is allocated with xstrdup when a new argument was
164 * parsed. Don't forget to free it! 155 * parsed. Don't forget to free it!
165 */ 156 */
166#define ARG_EMPTY 0x00 157#define ARG_EMPTY 0x00
@@ -185,7 +176,7 @@ static char *parse_command_string( char *src, char **dst )
185 /* Reached the start of an argument 176 /* Reached the start of an argument
186 * By the way, we duplicate a little too much 177 * By the way, we duplicate a little too much
187 * here but what is too much is freed later. */ 178 * here but what is too much is freed later. */
188 *dst = tmp_str = bb_xstrdup( src ); 179 *dst = tmp_str = xstrdup( src );
189 /* Get to the end of that argument */ 180 /* Get to the end of that argument */
190 while( ( *tmp_str != '\0' ) 181 while( ( *tmp_str != '\0' )
191 && ( ( *tmp_str != ' ' ) 182 && ( ( *tmp_str != ' ' )
@@ -309,7 +300,7 @@ static void include_conf ( struct dep_t **first, struct dep_t **current, char *b
309 (*current)-> m_next = (struct dep_t *) xcalloc ( 1, sizeof ( struct dep_t )); 300 (*current)-> m_next = (struct dep_t *) xcalloc ( 1, sizeof ( struct dep_t ));
310 (*current) = (*current)-> m_next; 301 (*current) = (*current)-> m_next;
311 } 302 }
312 (*current)-> m_name = bb_xstrdup ( alias ); 303 (*current)-> m_name = xstrdup ( alias );
313 (*current)-> m_isalias = 1; 304 (*current)-> m_isalias = 1;
314 305
315 if (( strcmp ( mod, "off" ) == 0 ) || ( strcmp ( mod, "null" ) == 0 )) { 306 if (( strcmp ( mod, "off" ) == 0 ) || ( strcmp ( mod, "null" ) == 0 )) {
@@ -319,7 +310,7 @@ static void include_conf ( struct dep_t **first, struct dep_t **current, char *b
319 else { 310 else {
320 (*current)-> m_depcnt = 1; 311 (*current)-> m_depcnt = 1;
321 (*current)-> m_deparr = xmalloc ( 1 * sizeof( char * )); 312 (*current)-> m_deparr = xmalloc ( 1 * sizeof( char * ));
322 (*current)-> m_deparr[0] = bb_xstrdup ( mod ); 313 (*current)-> m_deparr[0] = xstrdup ( mod );
323 } 314 }
324 (*current)-> m_next = 0; 315 (*current)-> m_next = 0;
325 } 316 }
@@ -388,7 +379,7 @@ static struct dep_t *build_dep ( void )
388 k_version = un.release[2] - '0'; 379 k_version = un.release[2] - '0';
389 } 380 }
390 381
391 filename = bb_xasprintf("/lib/modules/%s/modules.dep", un.release ); 382 filename = xasprintf("/lib/modules/%s/modules.dep", un.release );
392 fd = open ( filename, O_RDONLY ); 383 fd = open ( filename, O_RDONLY );
393 if (ENABLE_FEATURE_CLEAN_UP) 384 if (ENABLE_FEATURE_CLEAN_UP)
394 free(filename); 385 free(filename);
@@ -447,7 +438,7 @@ static struct dep_t *build_dep ( void )
447 if (( *(col-2) == '.' ) && ( *(col-1) == 'o' )) 438 if (( *(col-2) == '.' ) && ( *(col-1) == 'o' ))
448 dot = col - 2; 439 dot = col - 2;
449 440
450 mod = bb_xstrndup ( mods, dot - mods ); 441 mod = xstrndup ( mods, dot - mods );
451 442
452 /* enqueue new module */ 443 /* enqueue new module */
453 if ( !current ) { 444 if ( !current ) {
@@ -458,7 +449,7 @@ static struct dep_t *build_dep ( void )
458 current = current-> m_next; 449 current = current-> m_next;
459 } 450 }
460 current-> m_name = mod; 451 current-> m_name = mod;
461 current-> m_path = bb_xstrdup(modpath); 452 current-> m_path = xstrdup(modpath);
462 current-> m_options = NULL; 453 current-> m_options = NULL;
463 current-> m_isalias = 0; 454 current-> m_isalias = 0;
464 current-> m_depcnt = 0; 455 current-> m_depcnt = 0;
@@ -525,7 +516,7 @@ static struct dep_t *build_dep ( void )
525 /* Cope with blank lines */ 516 /* Cope with blank lines */
526 if ((next-deps-ext+1) <= 0) 517 if ((next-deps-ext+1) <= 0)
527 continue; 518 continue;
528 dep = bb_xstrndup ( deps, next - deps - ext + 1 ); 519 dep = xstrndup ( deps, next - deps - ext + 1 );
529 520
530 /* Add the new dependable module name */ 521 /* Add the new dependable module name */
531 current-> m_depcnt++; 522 current-> m_depcnt++;
@@ -562,7 +553,7 @@ static struct dep_t *build_dep ( void )
562 /* Only 2.6 has a modules.alias file */ 553 /* Only 2.6 has a modules.alias file */
563 if (ENABLE_FEATURE_2_6_MODULES) { 554 if (ENABLE_FEATURE_2_6_MODULES) {
564 /* Parse kernel-declared aliases */ 555 /* Parse kernel-declared aliases */
565 filename = bb_xasprintf("/lib/modules/%s/modules.alias", un.release); 556 filename = xasprintf("/lib/modules/%s/modules.alias", un.release);
566 if ((fd = open ( filename, O_RDONLY )) < 0) { 557 if ((fd = open ( filename, O_RDONLY )) < 0) {
567 /* Ok, that didn't work. Fall back to looking in /lib/modules */ 558 /* Ok, that didn't work. Fall back to looking in /lib/modules */
568 fd = open ( "/lib/modules/modules.alias", O_RDONLY ); 559 fd = open ( "/lib/modules/modules.alias", O_RDONLY );
@@ -687,7 +678,7 @@ static int mod_process ( struct mod_list_t *list, int do_insert )
687 printf("%s module %s\n", do_insert?"Loading":"Unloading", list-> m_name ); 678 printf("%s module %s\n", do_insert?"Loading":"Unloading", list-> m_name );
688 } 679 }
689 if (!show_only) { 680 if (!show_only) {
690 int rc2 = wait4pid(bb_spawn(argv)); 681 int rc2 = wait4pid(spawn(argv));
691 682
692 if (do_insert) { 683 if (do_insert) {
693 rc = rc2; /* only last module matters */ 684 rc = rc2; /* only last module matters */
@@ -724,8 +715,8 @@ static int check_pattern( const char* pat_src, const char* mod_src ) {
724 char* mod; 715 char* mod;
725 char* p; 716 char* p;
726 717
727 pat = bb_xstrdup (pat_src); 718 pat = xstrdup (pat_src);
728 mod = bb_xstrdup (mod_src); 719 mod = xstrdup (mod_src);
729 720
730 for (p = pat; (p = strchr(p, '-')); *p++ = '_' ); 721 for (p = pat; (p = strchr(p, '-')); *p++ = '_' );
731 for (p = mod; (p = strchr(p, '-')); *p++ = '_' ); 722 for (p = mod; (p = strchr(p, '-')); *p++ = '_' );