kmod-setup.c revision 1b09f548c7f303b486b5b1321c06336bff72ada4
/*-*- 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>
#ifdef HAVE_KMOD
#include <libkmod.h>
#endif
#include "macro.h"
#include "capability.h"
#include "bus-util.h"
#include "kmod-setup.h"
#ifdef HAVE_KMOD
static void systemd_kmod_log(
void *data,
int priority,
const char *fn,
const char *format,
/* library logging is enabled at debug only */
}
#endif
int kmod_setup(void) {
#ifdef HAVE_KMOD
static const struct {
const char *module;
const char *path;
bool warn_if_unavailable:1;
bool warn_if_module:1;
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 */
#ifdef HAVE_LIBIPTC
/* netfilter is needed by networkd, nspawn among others, and cannot be autoloaded */
#endif
};
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_if_module)
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 (ctx)
#endif
return 0;
}