aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Masters <jcm@jonmasters.org>2010-03-09 03:41:00 -0500
committerJon Masters <jcm@jonmasters.org>2010-03-09 03:41:00 -0500
commitb9066171143de709e29b7d7a7682fb479dc6d140 (patch)
tree5a29aa16922f8e53b041ed9a06f5cc8a840cf6d8
parent7453ea25030854a4566a5b73917604ffc4cba03f (diff)
parent66876e3ee43d52f1b41c56e5bab542b7c205b91b (diff)
downloadmodule-init-tools-dev-old.tar.gz
Merge commit '66876e3ee43d52f1b41c56e5bab542b7c205b91b' into devdev-old
Conflicts: modprobe.c Signed-off-by: Jon Masters <jcm@jonmasters.org>
-rw-r--r--modprobe.c102
1 files changed, 45 insertions, 57 deletions
diff --git a/modprobe.c b/modprobe.c
index dab8e56..8b5dba9 100644
--- a/modprobe.c
+++ b/modprobe.c
@@ -1312,14 +1312,14 @@ out:
int do_modprobe(const char *modname,
const char *newname,
const char *cmdline_opts,
- const char *configname,
+ const struct modprobe_conf *conf,
const char *dirname,
errfn_t error,
modprobe_flags_t flags);
static void do_softdep(const struct module_softdep *softdep,
const char *cmdline_opts,
- const char *configname,
+ const struct modprobe_conf *conf,
const char *dirname,
errfn_t error,
modprobe_flags_t flags)
@@ -1348,13 +1348,13 @@ static void do_softdep(const struct module_softdep *softdep,
j = (flags & mit_remove) ? pre_modnames->cnt-1 - i : i;
do_modprobe(pre_modnames->str[j], NULL, "",
- configname, dirname, warn, flags);
+ conf, dirname, warn, flags);
}
/* Modprobe main module, passing cmdline_opts, ignoring softdep */
do_modprobe(softdep->modname, NULL, cmdline_opts,
- configname, dirname, warn, flags | mit_ignore_commands);
+ conf, dirname, warn, flags | mit_ignore_commands);
/* Modprobe post_modnames */
@@ -1362,7 +1362,7 @@ static void do_softdep(const struct module_softdep *softdep,
/* Reverse module order if removing. */
j = (flags & mit_remove) ? post_modnames->cnt-1 - i : i;
- do_modprobe(post_modnames->str[j], NULL, "", configname,
+ do_modprobe(post_modnames->str[j], NULL, "", conf,
dirname, warn, flags);
}
}
@@ -1371,11 +1371,8 @@ static void do_softdep(const struct module_softdep *softdep,
static int insmod(struct list_head *list,
const char *optstring,
const char *newname,
- const struct module_options *options,
- const struct module_softdep *softdeps,
- const struct module_command *commands,
const char *cmdline_opts,
- const char *configname,
+ const struct modprobe_conf *conf,
const char *dirname,
errfn_t error,
modprobe_flags_t flags)
@@ -1398,8 +1395,7 @@ static int insmod(struct list_head *list,
f &= ~mit_first_time;
f &= ~mit_ignore_commands;
if ((rc = insmod(list, "", NULL,
- options, softdeps, commands, "",
- configname, dirname, warn, f)) != 0)
+ "", conf, dirname, warn, f)) != 0)
{
error("Error inserting %s (%s): %s\n",
mod->modname, mod->filename,
@@ -1418,14 +1414,14 @@ static int insmod(struct list_head *list,
goto out;
}
- softdep = find_softdep(mod->modname, softdeps);
+ softdep = find_softdep(mod->modname, conf->softdeps);
if (softdep && !(flags & mit_ignore_commands)) {
- do_softdep(softdep, cmdline_opts, configname, dirname,
+ do_softdep(softdep, cmdline_opts, conf, dirname,
error, flags & (mit_remove | mit_dry_run));
goto out;
}
- command = find_command(mod->modname, commands);
+ command = find_command(mod->modname, conf->commands);
if (command && !(flags & mit_ignore_commands)) {
if (already_loaded == -1) {
warn("/sys/module/ not present or too old,"
@@ -1455,7 +1451,7 @@ static int insmod(struct list_head *list,
clear_magic(module);
/* Config file might have given more options */
- opts = add_extra_options(mod->modname, optstring, options);
+ opts = add_extra_options(mod->modname, optstring, conf->options);
info("insmod %s %s\n", mod->filename, opts);
@@ -1489,10 +1485,8 @@ static int insmod(struct list_head *list,
/* Do recursive removal. */
static void rmmod(struct list_head *list,
const char *name,
- struct module_softdep *softdeps,
- struct module_command *commands,
const char *cmdline_opts,
- const char *configname,
+ const struct modprobe_conf *conf,
const char *dirname,
errfn_t error,
modprobe_flags_t flags)
@@ -1516,14 +1510,14 @@ static void rmmod(struct list_head *list,
/* Even if renamed, find commands/softdeps to orig. name. */
- softdep = find_softdep(mod->modname, softdeps);
+ softdep = find_softdep(mod->modname, conf->softdeps);
if (softdep && !(flags & mit_ignore_commands)) {
- do_softdep(softdep, cmdline_opts, configname, dirname,
+ do_softdep(softdep, cmdline_opts, conf, dirname,
error, flags & (mit_remove | mit_dry_run));
goto remove_rest;
}
- command = find_command(mod->modname, commands);
+ command = find_command(mod->modname, conf->commands);
if (command && !(flags & mit_ignore_commands)) {
if (exists == -1) {
warn("/sys/module/ not present or too old,"
@@ -1564,8 +1558,7 @@ static void rmmod(struct list_head *list,
flags &= ~mit_ignore_commands;
flags |= mit_quiet_inuse;
- rmmod(list, NULL, softdeps, commands, "",
- configname, dirname, warn, flags);
+ rmmod(list, NULL, "", conf, dirname, warn, flags);
}
free_module(mod);
return;
@@ -1580,11 +1573,8 @@ static int handle_module(const char *modname,
struct list_head *todo_list,
const char *newname,
const char *options,
- struct module_options *modoptions,
- struct module_softdep *softdeps,
- struct module_command *commands,
const char *cmdline_opts,
- const char *configname,
+ const struct modprobe_conf *conf,
const char *dirname,
errfn_t error,
modprobe_flags_t flags)
@@ -1596,14 +1586,14 @@ static int handle_module(const char *modname,
/* The dependencies have to be real modules, but
handle case where the first is completely bogus. */
- softdep = find_softdep(modname, softdeps);
+ softdep = find_softdep(modname, conf->softdeps);
if (softdep && !(flags & mit_ignore_commands)) {
- do_softdep(softdep, cmdline_opts, configname, dirname,
+ do_softdep(softdep, cmdline_opts, conf, dirname,
error, flags & (mit_remove | mit_dry_run));
return 0;
}
- command = find_command(modname, commands);
+ command = find_command(modname, conf->commands);
if (command && !(flags & mit_ignore_commands)) {
do_command(modname, command, flags & mit_dry_run, error,
(flags & mit_remove) ? "remove":"install", cmdline_opts);
@@ -1615,13 +1605,12 @@ static int handle_module(const char *modname,
return 1;
}
- if (flags & mit_remove)
- rmmod(todo_list, newname, softdeps, commands, cmdline_opts,
- configname, dirname, error, flags);
- else
- insmod(todo_list, options, newname,
- modoptions, softdeps, commands, cmdline_opts,
- configname, dirname, error, flags);
+ if (flags & mit_remove) {
+ rmmod(todo_list, newname, cmdline_opts,
+ conf, dirname, error, flags);
+ } else
+ insmod(todo_list, NOFAIL(strdup(options)), newname,
+ cmdline_opts, conf, dirname, error, flags);
return 0;
}
@@ -1646,13 +1635,12 @@ int handle_builtin_module(const char *modname,
int do_modprobe(const char *modulename,
const char *newname,
const char *cmdline_opts,
- const char *configname,
+ const struct modprobe_conf *conf,
const char *dirname,
errfn_t error,
modprobe_flags_t flags)
{
char *modname;
- struct modprobe_conf conf = {};
struct module_alias *matching_aliases;
LIST_HEAD(list);
int failed = 0;
@@ -1660,13 +1648,7 @@ int do_modprobe(const char *modulename,
/* Convert name we are looking for */
modname = underscores(NOFAIL(strdup(modulename)));
- /* Read aliases, options etc. */
- parse_toplevel_config(configname, &conf, 0, flags & mit_remove);
-
- /* Read module options from kernel command line */
- parse_kcmdline(0, &conf.options);
-
- matching_aliases = find_aliases(conf.aliases, modname);
+ matching_aliases = find_aliases(conf->aliases, modname);
/* No luck? Try symbol names, if starts with symbol:. */
if (!matching_aliases && strstarts(modname, "symbol:")) {
@@ -1682,8 +1664,8 @@ int do_modprobe(const char *modulename,
/* We only use canned aliases as last resort. */
if (list_empty(&list)
- && !find_softdep(modname, conf.softdeps)
- && !find_command(modname, conf.commands))
+ && !find_softdep(modname, conf->softdeps)
+ && !find_command(modname, conf->commands))
{
char *aliasfilename;
@@ -1701,7 +1683,7 @@ int do_modprobe(const char *modulename,
}
}
- apply_blacklist(&matching_aliases, conf.blacklist);
+ apply_blacklist(&matching_aliases, conf->blacklist);
if(flags & mit_resolve_alias) {
struct module_alias *aliases = matching_aliases;
@@ -1720,13 +1702,12 @@ int do_modprobe(const char *modulename,
/* Add the options for this alias. */
char *opts;
opts = add_extra_options(modname,
- cmdline_opts, conf.options);
+ cmdline_opts, conf->options);
read_depends(dirname, aliases->module, &list);
failed |= handle_module(aliases->module,
- &list, newname, opts, conf.options,
- conf.softdeps, conf.commands, cmdline_opts,
- configname, dirname, err, flags);
+ &list, newname, opts, cmdline_opts,
+ conf, dirname, err, flags);
aliases = aliases->next;
free(opts);
@@ -1734,12 +1715,11 @@ int do_modprobe(const char *modulename,
}
} else {
if (flags & mit_use_blacklist
- && find_blacklist(modname, conf.blacklist))
+ && find_blacklist(modname, conf->blacklist))
goto out;
failed |= handle_module(modname, &list, newname, cmdline_opts,
- conf.options, conf.softdeps, conf.commands, cmdline_opts,
- configname, dirname, error, flags);
+ cmdline_opts, conf, dirname, error, flags);
}
out:
@@ -1794,6 +1774,7 @@ int main(int argc, char *argv[])
errfn_t error = fatal;
int failed = 0;
modprobe_flags_t flags = 0;
+ struct modprobe_conf conf = {};
recursion_depth = 0;
@@ -1909,6 +1890,12 @@ int main(int argc, char *argv[])
if (type)
fatal("-t only supported with -l");
+ /* Read aliases, options etc. */
+ parse_toplevel_config(configname, &conf, dump_config, flags & mit_remove);
+
+ /* Read module options from kernel command line */
+ parse_kcmdline(1, &conf.options);
+
if (dump_config) {
char *aliasfilename, *symfilename;
struct modprobe_conf conf = {};
@@ -1941,7 +1928,7 @@ int main(int argc, char *argv[])
dump_modversions(modname, error);
else
failed |= do_modprobe(modname, newname, cmdline_opts,
- configname, dirname, error, flags);
+ &conf, dirname, error, flags);
}
@@ -1950,6 +1937,7 @@ out:
closelog();
free(dirname);
free(cmdline_opts);
+ /* Don't bother to free conf */
exit(failed);
}