{
ERR("TODO - config is missing in kmod.\n");
/*
- needs:
- struct kmod_list *kmod_get_config(struct kmod_ctx *ctx);
- kmod_config_get_type() {alias,options,blacklist,install,remove,softdeps}
- kmod_config_get_key()
- kmod_config_get_value()
- kmod_config_unref_list()
- */
+ * needs:
+ * struct kmod_list *kmod_get_config(struct kmod_ctx *ctx);
+ * kmod_config_get_type() {alias,options,blacklist,install,remove,softdeps}
+ * kmod_config_get_key()
+ * kmod_config_get_value()
+ * kmod_config_unref_list()
+ */
return -ENOENT;
}
return 0;
}
-static int command_do(struct kmod_module *module, const char *type, const char *command, const char *cmdline_opts)
+static int command_do(struct kmod_module *module, const char *type,
+ const char *command, const char *cmdline_opts)
{
const char *modname = kmod_module_get_name(module);
char *p, *cmd = NULL;
static int rmmod_do_dependencies(struct kmod_module *parent);
static int rmmod_do_soft_dependencies(struct kmod_module *mod, struct kmod_list *deps);
-static int rmmod_do_deps_list(struct kmod_module *parent, struct kmod_list *deps, unsigned stop_on_errors)
+static int rmmod_do_deps_list(struct kmod_module *parent,
+ struct kmod_list *deps,
+ unsigned stop_on_errors)
{
struct kmod_list *d;
int err = 0;
r = rmmod_do_dependencies(dm);
if (r < 0) {
WRN("could not remove dependencies of '%s': %s\n",
- dmname, strerror(-r));
+ dmname, strerror(-r));
goto dep_error;
}
r = kmod_module_get_softdeps(dm, &pre, &post);
if (r < 0) {
WRN("could not get softdeps of '%s': %s\n",
- dmname, strerror(-r));
+ dmname, strerror(-r));
goto dep_done;
}
r = rmmod_do_soft_dependencies(dm, post);
if (r < 0) {
WRN("could not remove post soft softdeps of '%s': %s\n",
- dmname, strerror(-r));
+ dmname, strerror(-r));
goto dep_error;
}
r = command_do(dm, "remove", cmd, NULL);
if (r < 0) {
WRN("failed to execute remove command of '%s': "
- "%s\n", dmname, strerror(-r));
+ "%s\n", dmname, strerror(-r));
goto dep_error;
} else
goto dep_done;
r = kmod_module_get_refcnt(dm);
if (r < 0) {
WRN("could not get module '%s' refcnt: %s\n",
- dmname, strerror(-r));
+ dmname, strerror(-r));
goto dep_error;
} else if (r > 0 && !ignore_loaded) {
LOG("Module %s is in use.\n", dmname);
r = kmod_module_remove_module(dm, 0);
if (r < 0) {
WRN("could not remove '%s': %s\n",
- dmname, strerror(-r));
+ dmname, strerror(-r));
goto dep_error;
}
}
r = rmmod_do_soft_dependencies(dm, pre);
if (r < 0) {
WRN("could not remove pre softdeps of '%s': %s\n",
- dmname, strerror(-r));
+ dmname, strerror(-r));
goto dep_error;
}
kmod_module_unref_list(pre);
return err;
}
-static int rmmod_do_soft_dependencies(struct kmod_module *mod, struct kmod_list *deps)
+static int rmmod_do_soft_dependencies(struct kmod_module *mod,
+ struct kmod_list *deps)
{
return rmmod_do_deps_list(mod, deps, 0);
}
err = kmod_module_get_softdeps(mod, &pre, &post);
if (err < 0) {
WRN("could not get softdeps of '%s': %s\n",
- modname, strerror(-err));
+ modname, strerror(-err));
return err;
}
err = rmmod_do_soft_dependencies(mod, post);
if (err < 0) {
WRN("could not remove post softdeps of '%s': %s\n",
- modname, strerror(-err));
+ modname, strerror(-err));
goto error;
}
err = rmmod_do_soft_dependencies(mod, pre);
if (err < 0) {
WRN("could not remove pre softdeps of '%s': %s\n",
- modname, strerror(-err));
+ modname, strerror(-err));
goto error;
}
}
}
static int insmod_do_dependencies(struct kmod_module *parent);
-static int insmod_do_soft_dependencies(struct kmod_module *mod, struct kmod_list *deps);
+static int insmod_do_soft_dependencies(struct kmod_module *mod,
+ struct kmod_list *deps);
-static int insmod_do_deps_list(struct kmod_module *parent, struct kmod_list *deps, unsigned stop_on_errors)
+static int insmod_do_deps_list(struct kmod_module *parent,
+ struct kmod_list *deps,
+ unsigned stop_on_errors)
{
struct kmod_list *d;
int err = 0;
r = insmod_do_dependencies(dm);
if (r < 0) {
WRN("could not insert dependencies of '%s': %s\n",
- dmname, strerror(-r));
+ dmname, strerror(-r));
goto dep_error;
}
r = kmod_module_get_softdeps(dm, &pre, &post);
if (r < 0) {
WRN("could not get softdeps of '%s': %s\n",
- dmname, strerror(-r));
+ dmname, strerror(-r));
goto dep_done;
}
r = insmod_do_soft_dependencies(dm, pre);
if (r < 0) {
WRN("could not insert pre softdeps of '%s': %s\n",
- dmname, strerror(-r));
+ dmname, strerror(-r));
goto dep_error;
}
r = command_do(dm, "install", cmd, NULL);
if (r < 0) {
WRN("failed to execute install command of '%s':"
- " %s\n", dmname, strerror(-r));
+ " %s\n", dmname, strerror(-r));
goto dep_error;
} else
goto dep_done;
opts = kmod_module_get_options(dm);
SHOW("insmod %s %s\n",
- kmod_module_get_path(dm), opts ? opts : "");
+ kmod_module_get_path(dm), opts ? opts : "");
if (!dry_run) {
int flags = 0;
r = insmod_do_soft_dependencies(dm, post);
if (r < 0) {
WRN("could not insert post softdeps of '%s': %s\n",
- dmname, strerror(-r));
+ dmname, strerror(-r));
goto dep_error;
}
return err;
}
-static int insmod_do_soft_dependencies(struct kmod_module *mod, struct kmod_list *deps)
+static int insmod_do_soft_dependencies(struct kmod_module *mod,
+ struct kmod_list *deps)
{
return insmod_do_deps_list(mod, deps, 0);
}
err = kmod_module_get_softdeps(mod, &pre, &post);
if (err < 0) {
WRN("could not get softdeps of '%s': %s\n",
- modname, strerror(-err));
+ modname, strerror(-err));
return err;
}
err = insmod_do_soft_dependencies(mod, pre);
if (err < 0) {
WRN("could not insert pre softdeps of '%s': %s\n",
- modname, strerror(-err));
+ modname, strerror(-err));
goto error;
}
if (state == KMOD_MODULE_BUILTIN) {
if (first_time) {
LOG("Module %s already in kernel (builtin).\n",
- modname);
+ modname);
return -EEXIST;
}
return 0;
err = kmod_module_insert_module(mod, flags, opts);
switch (err) {
case -EEXIST:
- /* we checked for EEXIST with an earlier call to retrieve the initstate,
- * but to avoid a race condition, we don't make any assumptions and
- * handle the error again here */
+ /*
+ * We checked for EEXIST with an earlier call to
+ * retrieve the initstate, but to avoid a race
+ * condition, we don't make any assumptions and handle
+ * the error again here
+ */
if (!first_time)
err = 0;
else
err = insmod_do_soft_dependencies(mod, post);
if (err < 0) {
WRN("could not insert post softdeps of '%s': %s\n",
- modname, strerror(-err));
+ modname, strerror(-err));
goto error;
}
}
return err;
}
-static int insmod_path(struct kmod_ctx *ctx, const char *path, const char *extra_options)
+static int insmod_path(struct kmod_ctx *ctx, const char *path,
+ const char *extra_options)
{
struct kmod_module *mod;
int err;
return err;
}
-static int insmod_alias(struct kmod_ctx *ctx, const char *alias, const char *extra_options)
+static int insmod_alias(struct kmod_ctx *ctx, const char *alias,
+ const char *extra_options)
{
struct kmod_list *l, *list = NULL;
int err;
return err;
}
-static int insmod(struct kmod_ctx *ctx, const char *name, const char *extra_options)
+static int insmod(struct kmod_ctx *ctx, const char *name,
+ const char *extra_options)
{
struct stat st;
if (stat(name, &st) == 0)
}
static void log_syslog(void *data, int priority, const char *file, int line,
- const char *fn, const char *format,
- va_list args)
+ const char *fn, const char *format, va_list args)
{
char *str, buf[32];
const char *prioname;
case '?':
goto cmdline_failed;
default:
- fprintf(stderr,
- "Error: unexpected getopt_long() value '%c'.\n",
- c);
+ fprintf(stderr, "Error: unexpected getopt_long() value '%c'.\n",
+ c);
goto cmdline_failed;
}
}
if (list_type != NULL) {
fputs("Error: -t (--type) only supported with -l (--list).\n",
- stderr);
+ stderr);
goto cmdline_failed;
}
}
kversion = u.release;
}
- snprintf(dirname_buf, sizeof(dirname_buf), "%s" ROOTPREFIX "/lib/modules/%s",
- root, kversion);
+ snprintf(dirname_buf, sizeof(dirname_buf),
+ "%s" ROOTPREFIX "/lib/modules/%s", root,
+ kversion);
dirname = dirname_buf;
}
if (argv != orig_argv)
free(argv);
+
free(config_paths);
return err >= 0 ? EXIT_SUCCESS : EXIT_FAILURE;