udev-builtin-kmod.c revision b45ce692de0372957f41a74ba274cec2661487be
/*
* load kernel modules
*
* Copyright (C) 2011 Kay Sievers <kay.sievers@vrfy.org>
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <libkmod.h>
#include "udev.h"
static int command_do(struct kmod_module *module, const char *type, const char *command, const char *cmdline_opts)
{
int ret = 0;
if (cmdline_opts == NULL)
cmdline_opts = "";
return -ENOMEM;
if (s == NULL) {
return -ENOMEM;
}
s[slen] = '\0';
cmd = s;
}
unsetenv("MODPROBE_MODULE");
//LOG("Error running %s command for %s\n", type, modname);
if (ret != -1)
}
end:
return ret;
}
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;
kmod_list_foreach(d, deps) {
int state;
int r;
r = insmod_do_dependencies(dm);
if (r < 0) {
//WRN("could not insert dependencies of '%s': %s\n", dmname, strerror(-r));
goto dep_error;
}
if (r < 0) {
//WRN("could not get softdeps of '%s': %s\n", dmname, strerror(-r));
goto dep_done;
}
if (r < 0) {
//WRN("could not insert pre softdeps of '%s': %s\n", dmname, strerror(-r));
goto dep_error;
}
if (state == KMOD_MODULE_LIVE ||
state == KMOD_MODULE_COMING ||
goto dep_done;
if (cmd) {
if (r < 0) {
//WRN("failed to execute install command of '%s':" " %s\n", dmname, strerror(-r));
goto dep_error;
} else
goto dep_done;
}
if (r < 0) {
//WRN("could not insert '%s': %s\n", dmname, strerror(-r));
goto dep_error;
}
if (r < 0) {
//WRN("could not insert post softdeps of '%s': %s\n", dmname, strerror(-r));
goto dep_error;
}
continue;
err = r;
if (stop_on_errors)
break;
else
continue;
}
return err;
}
{
}
{
return err;
}
{
const char *cmd;
int state;
int err;
if (err < 0) {
//WRN("could not get softdeps of '%s': %s\n", modname, strerror(-err));
return err;
}
if (err < 0) {
//WRN("could not insert pre softdeps of '%s': %s\n", modname, strerror(-err));
goto error;
}
goto done;
}
return 0;
/*
* anymore. So if we can't get module's path, it's because it was
* really intended to be a module and it doesn't exist
*/
//LOG("Module %s not found.\n", modname);
return -ENOENT;
}
if (err < 0)
return err;
if (conf_opts || extra_opts) {
else if (extra_opts == NULL)
goto error;
}
}
err = 0;
done:
if (err < 0) {
//WRN("could not insert post softdeps of '%s': %s\n", modname, strerror(-err));
goto error;
}
return err;
}
{
struct kmod_module *mod;
int err;
if (err < 0) {
//LOG("Module %s not found.\n", path);
return err;
}
return err;
}
{
int err;
if (err < 0)
return err;
//LOG("Module %s not found.\n", alias);
return err;
}
if (err < 0) {
//LOG("Could not filter alias list!\n");
return err;
}
kmod_list_foreach(l, list) {
if (err < 0)
break;
}
return err;
}
{
else
}
{
int i;
if (!ctx)
return EXIT_FAILURE;
if (argc < 3) {
return EXIT_FAILURE;
}
for (i = 2; argv[i]; i++) {
}
return EXIT_SUCCESS;
}
{
if (!ctx)
return -ENOMEM;
return 0;
}
{
return 0;
}
const struct udev_builtin udev_builtin_kmod = {
.name = "kmod",
.cmd = builtin_kmod,
.help = "kernel module loader",
.run_once = false,
};