kmod-setup.c revision 63cc4c3138fd0ce9cc97884373a2dd8959a13ee9
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2010 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <libkmod.h>
#include "macro.h"
#include "execute.h"
#include "capability.h"
#include "kmod-setup.h"
static void systemd_kmod_log(
void *data,
int priority,
const char *fn,
const char *format,
/* library logging is enabled at debug only */
}
static bool cmdline_check_kdbus(void) {
if (proc_cmdline(&line) < 0)
return false;
}
int kmod_setup(void) {
static const struct {
const char *module;
const char *path;
bool warn;
bool (*condition_fn)(void);
} kmod_table[] = {
/* auto-loading on use doesn't work before udev is up */
/* early configure of ::1 on the loopback device */
/* this should never be a module */
/* IPC is needed before we bring up any other services */
};
unsigned int i;
int r;
if (have_effective_cap(CAP_SYS_MODULE) == 0)
return 0;
for (i = 0; i < ELEMENTSOF(kmod_table); i++) {
struct kmod_module *mod;
continue;
continue;
if (kmod_table[i].warn)
log_debug("Your kernel apparently lacks built-in %s support. Might be "
"a good idea to compile it in. We'll now try to work around "
if (!ctx) {
if (!ctx)
return log_oom();
}
if (r < 0) {
continue;
}
if (r == 0)
else if (r == KMOD_PROBE_APPLY_BLACKLIST)
else if (kmod_table[i].warn)
}
if (ctx)
return 0;
}