struct dep_t { /* one-way list of dependency rules */
/* a dependency rule */
- char * m_name; /* the module name*/
- char * m_path; /* the module file path */
- struct mod_opt_t * m_options; /* the module options */
+ char * m_name; /* the module name*/
+ char * m_path; /* the module file path */
+ struct mod_opt_t * m_options; /* the module options */
- int m_isalias : 1; /* the module is an alias */
- int m_isblacklisted : 1;
- int m_reserved : 14; /* stuffin' */
+ unsigned int m_isalias :1; /* the module is an alias */
+ unsigned int m_isblacklisted:1; /* the module is blacklisted */
+ unsigned int m_reserved :14; /* stuffin' */
- int m_depcnt : 16; /* the number of dependable module(s) */
- char ** m_deparr; /* the list of dependable module(s) */
+ unsigned int m_depcnt :16; /* the number of dependable module(s) */
+ char ** m_deparr; /* the list of dependable module(s) */
- struct dep_t * m_next; /* the next dependency rule */
+ struct dep_t * m_next; /* the next dependency rule */
};
struct mod_list_t { /* two-way list of modules to process */
#endif /* ENABLE_FEATURE_MODPROBE_MULTIPLE_OPTIONS */
static int is_conf_command(char *buffer, const char *command)
-{
+{
int len = strlen(command);
return ((strstr(buffer, command) == buffer) &&
- isspace(buffer[len]));
+ isspace(buffer[len]));
}
/*
include_conf(first, current, buffer, buflen, fdi);
close(fdi);
}
- } else if (ENABLE_FEATURE_MODPROBE_BLACKLIST &&
+ } else if (ENABLE_FEATURE_MODPROBE_BLACKLIST &&
(is_conf_command(buffer, "blacklist"))) {
char *mod;
struct dep_t *dt;
mod = skip_whitespace(buffer + 10);
for (dt = *first; dt; dt = dt->m_next) {
- if (dt->m_isalias && strcmp(dt->m_deparr[0], mod) == 0)
+ if (strcmp(dt->m_name, mod) == 0)
break;
}
if (dt)
k_version = un.release[2] - '0';
}
- filename = xasprintf("/lib/modules/%s/modules.dep", un.release);
+ filename = xasprintf(CONFIG_DEFAULT_MODULES_DIR"/%s/"CONFIG_DEFAULT_DEPMOD_FILE, un.release);
fd = open(filename, O_RDONLY);
if (ENABLE_FEATURE_CLEAN_UP)
free(filename);
if (fd < 0) {
/* Ok, that didn't work. Fall back to looking in /lib/modules */
- fd = open("/lib/modules/modules.dep", O_RDONLY);
+ fd = open(CONFIG_DEFAULT_MODULES_DIR"/"CONFIG_DEFAULT_DEPMOD_FILE, O_RDONLY);
if (fd < 0) {
- bb_error_msg_and_die("cannot parse modules.dep");
+ bb_error_msg_and_die("cannot parse " CONFIG_DEFAULT_DEPMOD_FILE);
}
}
/* It's a dep description continuation */
p = line_buffer;
- while (p && *p && isblank(*p))
- p++;
-
/* p points to the first dependable module; if NULL, no dependable module */
- if (p && *p) {
+ if (p && (p = skip_whitespace(p))[0] != '\0') {
char *end = &line_buffer[l-1];
const char *deps;
char *dep;
/* find the beginning of the module file name */
deps = bb_basename(p);
- if (deps == p) {
- while (isblank(*deps))
- deps++;
- }
+ if (deps == p)
+ deps = skip_whitespace(deps);
/* find the end of the module name in the file name */
if (ENABLE_FEATURE_2_6_MODULES
dep = xstrndup(deps, next - deps - ext + 1);
/* Add the new dependable module name */
- current->m_depcnt++;
- current->m_deparr = xrealloc(current->m_deparr,
- sizeof(char *) * current->m_depcnt);
- current->m_deparr[current->m_depcnt - 1] = dep;
+ current->m_deparr = xrealloc_vector(current->m_deparr, 2, current->m_depcnt);
+ current->m_deparr[current->m_depcnt++] = dep;
p = next + 2;
} while (next < end);
/* Only 2.6 has a modules.alias file */
if (ENABLE_FEATURE_2_6_MODULES) {
/* Parse kernel-declared module aliases */
- filename = xasprintf("/lib/modules/%s/modules.alias", un.release);
+ filename = xasprintf(CONFIG_DEFAULT_MODULES_DIR"/%s/modules.alias", un.release);
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);
+ fd = open(CONFIG_DEFAULT_MODULES_DIR"/modules.alias", O_RDONLY);
}
if (ENABLE_FEATURE_CLEAN_UP)
free(filename);
}
/* Parse kernel-declared symbol aliases */
- filename = xasprintf("/lib/modules/%s/modules.symbols", un.release);
+ filename = xasprintf(CONFIG_DEFAULT_MODULES_DIR"/%s/modules.symbols", un.release);
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.symbols", O_RDONLY);
+ fd = open(CONFIG_DEFAULT_MODULES_DIR"/modules.symbols", O_RDONLY);
}
if (ENABLE_FEATURE_CLEAN_UP)
free(filename);
// resolve alias names
while (dt->m_isalias) {
- if (dt->m_depcnt == 1 && !(ENABLE_FEATURE_MODPROBE_BLACKLIST &&
- dt->m_isblacklisted)) {
+ if (dt->m_depcnt == 1) {
struct dep_t *adt;
for (adt = depend; adt; adt = adt->m_next) {
- if (check_pattern(adt->m_name, dt->m_deparr[0]) == 0)
+ if (check_pattern(adt->m_name, dt->m_deparr[0]) == 0 &&
+ !(ENABLE_FEATURE_MODPROBE_BLACKLIST &&
+ adt->m_isblacklisted))
break;
}
if (adt) {
depend = build_dep();
if (!depend)
- bb_error_msg_and_die("cannot parse modules.dep");
+ bb_error_msg_and_die("cannot parse "CONFIG_DEFAULT_DEPMOD_FILE);
if (remove_opt) {
do {
/* argv[optind] can be NULL here */
if (mod_remove(argv[optind])) {
- bb_error_msg("failed to remove module %s",
+ bb_error_msg("failed to %s module %s", "remove",
argv[optind]);
rc = EXIT_FAILURE;
}
bb_error_msg_and_die("no module or pattern provided");
if (mod_insert(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 %s module %s", "load", argv[optind]);
}
/* Here would be a good place to free up memory allocated during the dependencies build. */