summaryrefslogtreecommitdiff
path: root/modutils
diff options
context:
space:
mode:
Diffstat (limited to 'modutils')
-rw-r--r--modutils/insmod.c54
-rw-r--r--modutils/modprobe.c35
2 files changed, 24 insertions, 65 deletions
diff --git a/modutils/insmod.c b/modutils/insmod.c
index 3113f74..be41e44 100644
--- a/modutils/insmod.c
+++ b/modutils/insmod.c
@@ -59,17 +59,6 @@
*/
#include "busybox.h"
-#include <stdlib.h>
-#include <stdio.h>
-#include <stddef.h>
-#include <errno.h>
-#include <unistd.h>
-#include <dirent.h>
-#include <ctype.h>
-#include <assert.h>
-#include <string.h>
-#include <getopt.h>
-#include <fcntl.h>
#include <sys/utsname.h>
#if !defined(CONFIG_FEATURE_2_4_MODULES) && \
@@ -804,12 +793,12 @@ static int check_module_name_match(const char *filename, struct stat *statbuf,
if (fullname[0] == '\0')
return (FALSE);
else {
- char *tmp, *tmp1 = bb_xstrdup(filename);
+ char *tmp, *tmp1 = xstrdup(filename);
tmp = bb_get_last_path_component(tmp1);
if (strcmp(tmp, fullname) == 0) {
free(tmp1);
/* Stop searching if we find a match */
- m_filename = bb_xstrdup(filename);
+ m_filename = xstrdup(filename);
return (FALSE);
}
free(tmp1);
@@ -893,7 +882,6 @@ arch_apply_relocation(struct obj_file *f,
* (which is .got) similar to branch,
* but is full 32 bits relative */
- assert(got != 0);
*loc += got - dot;
break;
@@ -902,7 +890,6 @@ arch_apply_relocation(struct obj_file *f,
goto bb_use_plt;
case R_ARM_GOTOFF: /* address relative to the got */
- assert(got != 0);
*loc += v - got;
break;
@@ -972,7 +959,6 @@ arch_apply_relocation(struct obj_file *f,
break;
case R_386_GOTPC:
- assert(got != 0);
*loc += got - dot;
break;
@@ -980,7 +966,6 @@ arch_apply_relocation(struct obj_file *f,
goto bb_use_got;
case R_386_GOTOFF:
- assert(got != 0);
*loc += v - got;
break;
@@ -1102,7 +1087,6 @@ arch_apply_relocation(struct obj_file *f,
# ifdef R_68K_GOTOFF
case R_68K_GOTOFF:
- assert(got != 0);
*loc += v - got;
break;
# endif
@@ -1157,9 +1141,6 @@ arch_apply_relocation(struct obj_file *f,
struct mips_hi16 *next;
unsigned long insn;
- /* The value for the HI16 had best be the same. */
- assert(v == l->value);
-
/* Do the HI16 relocation. Note that we actually don't
need to know anything about the LO16 itself, except where
to find the low 16 bits of the addend needed by the LO16. */
@@ -1408,9 +1389,7 @@ arch_apply_relocation(struct obj_file *f,
case R_390_PLT32:
case R_390_PLT16DBL:
/* find the plt entry and initialize it. */
- assert(isym != NULL);
pe = (struct arch_single_entry *) &isym->pltent;
- assert(pe->allocated);
if (pe->inited == 0) {
ip = (unsigned long *)(ifile->plt->contents + pe->offset);
ip[0] = 0x0d105810; /* basr 1,0; lg 1,10(1); br 1 */
@@ -1440,15 +1419,12 @@ arch_apply_relocation(struct obj_file *f,
break;
case R_390_GOTPC:
- assert(got != 0);
*(unsigned long *) loc += got - dot;
break;
case R_390_GOT12:
case R_390_GOT16:
case R_390_GOT32:
- assert(isym != NULL);
- assert(got != 0);
if (!isym->gotent.inited)
{
isym->gotent.inited = 1;
@@ -1466,7 +1442,6 @@ arch_apply_relocation(struct obj_file *f,
# define R_390_GOTOFF32 R_390_GOTOFF
# endif
case R_390_GOTOFF32:
- assert(got != 0);
*loc += v - got;
break;
@@ -1497,7 +1472,6 @@ arch_apply_relocation(struct obj_file *f,
break;
case R_SH_GOTPC:
- assert(got != 0);
*loc = got - dot + rel->r_addend;
break;
@@ -1505,7 +1479,6 @@ arch_apply_relocation(struct obj_file *f,
goto bb_use_got;
case R_SH_GOTOFF:
- assert(got != 0);
*loc = v - got;
break;
@@ -1627,7 +1600,6 @@ arch_apply_relocation(struct obj_file *f,
case R_X86_64_GOTPCREL:
goto bb_use_got;
# if 0
- assert(isym != NULL);
if (!isym->gotent.reloc_done)
{
isym->gotent.reloc_done = 1;
@@ -1655,12 +1627,10 @@ arch_apply_relocation(struct obj_file *f,
bb_use_plt:
/* find the plt entry and initialize it if necessary */
- assert(isym != NULL);
#if defined(CONFIG_USE_PLT_LIST)
for (pe = isym->pltent; pe != NULL && pe->addend != rel->r_addend;)
pe = pe->next;
- assert(pe != NULL);
#else
pe = &isym->pltent;
#endif
@@ -1734,7 +1704,6 @@ bb_use_plt:
#if defined(CONFIG_USE_GOT_ENTRIES)
bb_use_got:
- assert(isym != NULL);
/* needs an entry in the .got: set it, once */
if (!isym->gotent.inited) {
isym->gotent.inited = 1;
@@ -1814,7 +1783,6 @@ static struct obj_section *arch_xsect_init(struct obj_file *f, char *name,
} else {
myrelsec = obj_create_alloced_section(f, name,
size, offset);
- assert(myrelsec);
}
return myrelsec;
@@ -3778,14 +3746,14 @@ add_ksymoops_symbols(struct obj_file *f, const char *filename,
};
if (realpath(filename, real)) {
- absolute_filename = bb_xstrdup(real);
+ absolute_filename = xstrdup(real);
}
else {
int save_errno = errno;
bb_error_msg("cannot get realpath for %s", filename);
errno = save_errno;
perror("");
- absolute_filename = bb_xstrdup(filename);
+ absolute_filename = xstrdup(filename);
}
lm_name = strlen(m_name);
@@ -4022,7 +3990,7 @@ int insmod_main( int argc, char **argv)
break;
case 'o': /* name the output module */
free(m_name);
- m_name = bb_xstrdup(optarg);
+ m_name = xstrdup(optarg);
break;
case 'L': /* Stub warning */
/* This is needed for compatibility with modprobe.
@@ -4045,7 +4013,7 @@ int insmod_main( int argc, char **argv)
}
/* Grab the module name */
- tmp1 = bb_xstrdup(argv[optind]);
+ tmp1 = xstrdup(argv[optind]);
tmp = basename(tmp1);
len = strlen(tmp);
@@ -4071,10 +4039,10 @@ int insmod_main( int argc, char **argv)
#if defined(CONFIG_FEATURE_2_6_MODULES)
if (k_version > 4)
- m_fullName = bb_xasprintf("%s.ko", tmp);
+ m_fullName = xasprintf("%s.ko", tmp);
else
#endif
- m_fullName = bb_xasprintf("%s.o", tmp);
+ m_fullName = xasprintf("%s.o", tmp);
if (!m_name) {
m_name = tmp;
@@ -4132,7 +4100,7 @@ int insmod_main( int argc, char **argv)
bb_error_msg_and_die("%s: no module by that name found", m_fullName);
}
} else
- m_filename = bb_xstrdup(argv[optind]);
+ m_filename = xstrdup(argv[optind]);
if (flag_verbose)
printf("Using %s\n", m_filename);
@@ -4334,7 +4302,7 @@ int insmod_ng_main( int argc, char **argv)
struct stat st;
unsigned long len;
void *map;
- char *filename, *options = bb_xstrdup("");
+ char *filename, *options = xstrdup("");
filename = argv[1];
if (!filename) {
@@ -4356,7 +4324,7 @@ int insmod_ng_main( int argc, char **argv)
strcat(options, " ");
}
- fd = bb_xopen3(filename, O_RDONLY, 0);
+ fd = xopen3(filename, O_RDONLY, 0);
fstat(fd, &st);
len = st.st_size;
diff --git a/modutils/modprobe.c b/modutils/modprobe.c
index b11e58d..5a94c7c 100644
--- a/modutils/modprobe.c
+++ b/modutils/modprobe.c
@@ -13,15 +13,6 @@
#include "busybox.h"
#include <sys/utsname.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <getopt.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <syslog.h>
-#include <string.h>
-#include <ctype.h>
-#include <fcntl.h>
#include <fnmatch.h>
struct 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 )
ol = opt_list = xmalloc( sizeof( struct mod_opt_t ) );
}
- ol-> m_opt_val = bb_xstrdup( opt );
+ ol-> m_opt_val = xstrdup( opt );
ol-> m_next = NULL;
return opt_list;
@@ -160,7 +151,7 @@ static struct mod_opt_t *append_option( struct mod_opt_t *opt_list, char *opt )
* dst: pointer to where to store the parsed argument
* return value: the pointer to the first char after the parsed argument,
* NULL if there was no argument parsed (only trailing spaces).
- * Note that memory is allocated with bb_xstrdup when a new argument was
+ * Note that memory is allocated with xstrdup when a new argument was
* parsed. Don't forget to free it!
*/
#define ARG_EMPTY 0x00
@@ -185,7 +176,7 @@ static char *parse_command_string( char *src, char **dst )
/* Reached the start of an argument
* By the way, we duplicate a little too much
* here but what is too much is freed later. */
- *dst = tmp_str = bb_xstrdup( src );
+ *dst = tmp_str = xstrdup( src );
/* Get to the end of that argument */
while( ( *tmp_str != '\0' )
&& ( ( *tmp_str != ' ' )
@@ -309,7 +300,7 @@ static void include_conf ( struct dep_t **first, struct dep_t **current, char *b
(*current)-> m_next = (struct dep_t *) xcalloc ( 1, sizeof ( struct dep_t ));
(*current) = (*current)-> m_next;
}
- (*current)-> m_name = bb_xstrdup ( alias );
+ (*current)-> m_name = xstrdup ( alias );
(*current)-> m_isalias = 1;
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
else {
(*current)-> m_depcnt = 1;
(*current)-> m_deparr = xmalloc ( 1 * sizeof( char * ));
- (*current)-> m_deparr[0] = bb_xstrdup ( mod );
+ (*current)-> m_deparr[0] = xstrdup ( mod );
}
(*current)-> m_next = 0;
}
@@ -388,7 +379,7 @@ static struct dep_t *build_dep ( void )
k_version = un.release[2] - '0';
}
- filename = bb_xasprintf("/lib/modules/%s/modules.dep", un.release );
+ filename = xasprintf("/lib/modules/%s/modules.dep", un.release );
fd = open ( filename, O_RDONLY );
if (ENABLE_FEATURE_CLEAN_UP)
free(filename);
@@ -447,7 +438,7 @@ static struct dep_t *build_dep ( void )
if (( *(col-2) == '.' ) && ( *(col-1) == 'o' ))
dot = col - 2;
- mod = bb_xstrndup ( mods, dot - mods );
+ mod = xstrndup ( mods, dot - mods );
/* enqueue new module */
if ( !current ) {
@@ -458,7 +449,7 @@ static struct dep_t *build_dep ( void )
current = current-> m_next;
}
current-> m_name = mod;
- current-> m_path = bb_xstrdup(modpath);
+ current-> m_path = xstrdup(modpath);
current-> m_options = NULL;
current-> m_isalias = 0;
current-> m_depcnt = 0;
@@ -525,7 +516,7 @@ static struct dep_t *build_dep ( void )
/* Cope with blank lines */
if ((next-deps-ext+1) <= 0)
continue;
- dep = bb_xstrndup ( deps, next - deps - ext + 1 );
+ dep = xstrndup ( deps, next - deps - ext + 1 );
/* Add the new dependable module name */
current-> m_depcnt++;
@@ -562,7 +553,7 @@ static struct dep_t *build_dep ( void )
/* Only 2.6 has a modules.alias file */
if (ENABLE_FEATURE_2_6_MODULES) {
/* Parse kernel-declared aliases */
- filename = bb_xasprintf("/lib/modules/%s/modules.alias", un.release);
+ filename = xasprintf("/lib/modules/%s/modules.alias", un.release);
if ((fd = open ( filename, O_RDONLY )) < 0) {
/* Ok, that didn't work. Fall back to looking in /lib/modules */
fd = open ( "/lib/modules/modules.alias", O_RDONLY );
@@ -687,7 +678,7 @@ static int mod_process ( struct mod_list_t *list, int do_insert )
printf("%s module %s\n", do_insert?"Loading":"Unloading", list-> m_name );
}
if (!show_only) {
- int rc2 = wait4pid(bb_spawn(argv));
+ int rc2 = wait4pid(spawn(argv));
if (do_insert) {
rc = rc2; /* only last module matters */
@@ -724,8 +715,8 @@ static int check_pattern( const char* pat_src, const char* mod_src ) {
char* mod;
char* p;
- pat = bb_xstrdup (pat_src);
- mod = bb_xstrdup (mod_src);
+ pat = xstrdup (pat_src);
+ mod = xstrdup (mod_src);
for (p = pat; (p = strchr(p, '-')); *p++ = '_' );
for (p = mod; (p = strchr(p, '-')); *p++ = '_' );