[-]
[+]
|
Changed |
_service:tar_git:kmod.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:kmod.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -1,3 +1,3 @@
<services>
- <service name="tar_git"><param name="branch">master</param><param name="url">https://github.com/maui-mer-packages/kmod.git</param></service>
+ <service name="tar_git"><param name="branch">master</param><param name="url">https://github.com/maui-packages/kmod.git</param></service>
</services>
\ No newline at end of file
|
|
Deleted |
_service:tar_git:kmod-16.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/install-cmd-loop/lib/modules/4.4.4/kernel/sound/core/snd-pcm.ko.gz
^
|
|
Deleted |
_service:tar_git:kmod-16.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/install-cmd-loop/lib/modules/4.4.4/kernel/sound/core/snd.ko.gz
^
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/.gitignore
^
|
@@ -3,8 +3,8 @@
/*.md5sum
.deps/
.libs/
-Makefile
-Makefile.in
+/Makefile
+/Makefile.in
/aclocal.m4
/autom4te.cache/
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/Makefile.am
^
|
@@ -6,7 +6,8 @@
DISTCLEAN_LOCAL_HOOKS =
EXTRA_DIST =
-CLEANFILES =
+CLEANFILES = $(BUILT_FILES)
+BUILT_FILES =
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
AM_MAKEFLAGS = --no-print-directory
@@ -37,7 +38,7 @@
$(SED_PROCESS)
LIBKMOD_CURRENT=4
-LIBKMOD_REVISION=6
+LIBKMOD_REVISION=7
LIBKMOD_AGE=2
noinst_LTLIBRARIES = libkmod/libkmod-util.la
@@ -125,6 +126,70 @@
endif
# ------------------------------------------------------------------------------
+# PYTHON BINDINGS
+# ------------------------------------------------------------------------------
+
+CYTHON_FLAGS_VERBOSE_ =
+CYTHON_FLAGS_VERBOSE_0 =
+CYTHON_FLAGS_VERBOSE_1 = -v
+CYTHON_FLAGS = $(CYTHON_FLAGS_VERBOSE_$(V))
+AM_V_CYTHON = $(am__v_CYTHON_$(V))
+am__v_CYTHON_ = $(am__v_CYTHON_$(AM_DEFAULT_VERBOSITY))
+am__v_CYTHON_0 = @echo " CYTHON " $@;
+
+.pyx.c:
+ $(AM_V_CYTHON)$(CYTHON) -o $@ $<
+
+%.py: %.py.in Makefile
+ $(SED_PROCESS)
+
+# Remove some warnings for generated code
+PYTHON_NOWARN = -Wno-redundant-decls -Wno-shadow -Wno-strict-aliasing
+
+CPYTHON_MODULE_CFLAGS = $(AM_CFLAGS) -DCPYTHON_COMPILING_IN_PYPY=0 \
+ $(PYTHON_NOWARN) $(PYTHON_CFLAGS) \
+ -fvisibility=default
+CPYTHON_MODULE_LDFLAGS = $(AM_LDFLAGS) -module -avoid-version -shared
+
+if BUILD_PYTHON
+pkgpyexec_LTLIBRARIES = libkmod/python/kmod/kmod.la \
+ libkmod/python/kmod/list.la \
+ libkmod/python/kmod/module.la \
+ libkmod/python/kmod/_util.la
+
+libkmod_python_kmod_kmod_la_SOURCES = libkmod/python/kmod/kmod.c
+libkmod_python_kmod_kmod_la_CFLAGS = $(CPYTHON_MODULE_CFLAGS)
+libkmod_python_kmod_kmod_la_LDFLAGS = $(CPYTHON_MODULE_LDFLAGS)
+libkmod_python_kmod_kmod_la_LIBADD = $(PYTHON_LIBS) libkmod/libkmod.la
+
+libkmod_python_kmod_list_la_SOURCES = libkmod/python/kmod/list.c
+libkmod_python_kmod_list_la_CFLAGS = $(CPYTHON_MODULE_CFLAGS)
+libkmod_python_kmod_list_la_LDFLAGS = $(CPYTHON_MODULE_LDFLAGS)
+libkmod_python_kmod_list_la_LIBADD = $(PYTHON_LIBS) libkmod/libkmod.la
+
+libkmod_python_kmod_module_la_SOURCES = libkmod/python/kmod/module.c
+libkmod_python_kmod_module_la_CFLAGS = $(CPYTHON_MODULE_CFLAGS)
+libkmod_python_kmod_module_la_LDFLAGS = $(CPYTHON_MODULE_LDFLAGS)
+libkmod_python_kmod_module_la_LIBADD = $(PYTHON_LIBS) libkmod/libkmod.la
+
+libkmod_python_kmod__util_la_SOURCES = libkmod/python/kmod/_util.c
+libkmod_python_kmod__util_la_CFLAGS = $(CPYTHON_MODULE_CFLAGS)
+libkmod_python_kmod__util_la_LDFLAGS = $(CPYTHON_MODULE_LDFLAGS)
+libkmod_python_kmod__util_la_LIBADD = $(PYTHON_LIBS) libkmod/libkmod.la
+
+BUILT_FILES += $(libkmod_python_kmod_kmod_la_SOURCES) \
+ $(libkmod_python_kmod_list_la_SOURCES) \
+ $(libkmod_python_kmod_module_la_SOURCES) \
+ $(libkmod_python_kmod__util_la_SOURCES)
+
+dist_pkgpyexec_PYTHON = libkmod/python/kmod/error.py \
+ libkmod/python/kmod/__init__.py \
+ libkmod/python/kmod/version.py
+
+BUILT_FILES += libkmod/python/kmod/version.py
+
+endif
+# ------------------------------------------------------------------------------
# TESTSUITE
# ------------------------------------------------------------------------------
@@ -148,7 +213,14 @@
TESTSUITE_OVERRIDE_LIBS_LDFLAGS = avoid-version -module -shared -export-dynamic \
-rpath /nowhere -ldl
-check-am: rootfs
+check-sysconfdir:
+ $(AM_V_at)if test "$(sysconfdir)" != "/etc" -a "$(sysconfdir)" != "/etc/"; then \
+ echo "warning: Some tests will fail without --sysconfdir=/etc" >&2; \
+ fi
+.PHONY: check-sysconfdir
+
+check-am: rootfs check-sysconfdir
+
check_LTLIBRARIES = $(TESTSUITE_OVERRIDE_LIBS)
@@ -211,7 +283,8 @@
DISTCLEAN_LOCAL_HOOKS += testsuite-distclean
EXTRA_DIST += testsuite/rootfs-pristine
-DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc --sysconfdir=/etc --with-zlib \
+DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc --enable-python --sysconfdir=/etc \
+ --with-zlib \
--with-bashcompletiondir=$$dc_install_base/$(bashcompletiondir)
distclean-local: $(DISTCLEAN_LOCAL_HOOKS)
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/NEWS
^
|
@@ -1,3 +1,33 @@
+kmod 17
+=======
+
+- Bug fixes:
+ - Fix matching a "." in kernel cmdline, making garbage in the command
+ line be parsed as kmod options
+ - Fix man pages to clarify we don't fallback to parsing modules.dep
+ but instead we depend on modules.dep.bin (generated by depmod) to
+ be present
+ - Fix ELF parsing on 32 bit systems assigning the wrong class.
+ - Fix partial matches of search directives in depmod. Previously having
+ a line in depmod.conf such as "search foo foobar built-in" would cause
+ unpretictable results because foo is a partial match of foobar as well.
+ - Fix unaligned access in modinfo when getting the signature from a
+ module
+ - Make sure softdeps are treated as optional dependencies
+
+- New features:
+ - Accept special files given to "-C" switch in modprobe. This way it's
+ possible to skip system configuration with "modprobe -C /dev/null"
+ - Do not require xsltproc on released tarballs
+ - Don't use Werror anymore
+ - Add experimental python bindings, merged from python-kmod repository
+ (https://github.com/agrover/python-kmod)
+ - Parse softdeps exported by the kernel as
+ /lib/modules/`uname -r`/modules.softdep
+
+- Improvements to testsuite:
+ - Check the list of loaded modules after a test
+
kmod 16
=======
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/bootstrap
^
|
@@ -11,7 +11,7 @@
--sysconfdir=/etc \
--libdir=$(libdir /usr/lib)"
-hackargs="--enable-debug --with-xz --with-zlib"
+hackargs="--enable-debug --enable-python --with-xz --with-zlib"
cat <<EOC
@@ -24,6 +24,6 @@
If you are debugging or hacking on kmod, consider configuring
like below:
-./configure CFLAGS="-g -O2 -Werror" $args $hackargs
+./configure CFLAGS="-g -O2" $args $hackargs
EOC
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/bootstrap-configure
^
|
@@ -1,4 +1,4 @@
#!/bin/sh
. ./bootstrap && \
- exec ./configure CFLAGS="-g -O2 -Werror" $args $hackargs "$@"
+ exec ./configure CFLAGS="-g -O2" $args $hackargs "$@"
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/configure.ac
^
|
@@ -1,6 +1,6 @@
AC_PREREQ(2.60)
AC_INIT([kmod],
- [16],
+ [17],
[linux-modules@vger.kernel.org],
[kmod],
[http://git.kernel.org/?p=utils/kernel/kmod/kmod.git])
@@ -36,6 +36,7 @@
AC_PROG_SED
AC_PROG_MKDIR_P
PKG_PROG_PKG_CONFIG
+AC_PATH_PROG([XSLTPROC], [xsltproc])
#####################################################################
@@ -111,10 +112,6 @@
AS_HELP_STRING([--disable-manpages], [disable manpages @<:@default=enabled@:>@]),
[], enable_manpages=yes)
AM_CONDITIONAL([BUILD_MANPAGES], [test "x$enable_manpages" = "xyes"])
-AC_PATH_PROG([XSLTPROC], [xsltproc], [no])
-AS_IF([test "x$XSLTPROC" = "xno" && test "x$enable_manpages" = "xyes"], [
- AC_MSG_ERROR([xsltproc command not found, try ./configure --disable-manpages])
-])
AC_ARG_ENABLE([logging],
AS_HELP_STRING([--disable-logging], [disable system logging @<:@default=enabled@:>@]),
@@ -130,6 +127,24 @@
AC_DEFINE(ENABLE_DEBUG, [1], [Debug messages.])
])
+AC_ARG_ENABLE([python],
+ AS_HELP_STRING([--enable-python], [enable Python libkmod bindings @<:@default=disabled@:>@]),
+ [], [enable_python=no])
+AS_IF([test "x$enable_python" = "xyes"], [
+ AM_PATH_PYTHON(,,[:])
+ AC_PATH_PROG([CYTHON], [cython], [:])
+
+ PKG_CHECK_MODULES([PYTHON], [python-${PYTHON_VERSION}],
+ [have_python=yes],
+ [PKG_CHECK_MODULES([PYTHON], [python],
+ [have_python=yes],
+ [have_python=no])])
+
+ AS_IF([test "x$have_python" = xno],
+ [AC_MSG_ERROR([*** python support requested but libraries not found])])
+])
+AM_CONDITIONAL([BUILD_PYTHON], [test "x$enable_python" = "xyes"])
+
m4_ifdef([GTK_DOC_CHECK], [
GTK_DOC_CHECK([1.14],[--flavour no-tmpl-flat])
], [
@@ -167,7 +182,7 @@
-Wmissing-noreturn \
-Wshadow \
-Wendif-labels \
- -Wstrict-aliasing=2 \
+ -Wstrict-aliasing=3 \
-Wwrite-strings \
-Wno-long-long \
-Wno-overlength-strings \
@@ -225,6 +240,7 @@
ldflags: ${with_ldflags} ${LDFLAGS}
tools: ${enable_tools}
+ python bindings: ${enable_python}
logging: ${enable_logging}
compression: xz=${with_xz} zlib=${with_zlib}
debug: ${enable_debug}
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/libkmod/Makefile
^
|
@@ -0,0 +1,13 @@
+# Copyright 2010 Lennart Poettering
+#
+# This file has been copied from systemd. It is a dirty trick to simplify
+# compilation when CWD is not the root of the source tree. This file is not
+# intended to be distributed. So, don't touch it, even better ignore it!
+
+all:
+ $(MAKE) -C ..
+
+clean:
+ $(MAKE) -C .. clean
+
+.PHONY: all clean
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/libkmod/docs/.gitignore
^
|
@@ -10,3 +10,5 @@
xml
html
gtk-doc.make
+Makefile
+Makefile.in
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/libkmod/libkmod-config.c
^
|
@@ -523,7 +523,7 @@
{
char buf[KCMD_LINE_SIZE];
int fd, err;
- char *p, *modname, *param = NULL, *value = NULL;
+ char *p, *modname, *param = NULL, *value = NULL, is_module = 1;
fd = open("/proc/cmdline", O_RDONLY|O_CLOEXEC);
if (fd < 0) {
@@ -544,9 +544,11 @@
switch (*p) {
case ' ':
*p = '\0';
- kcmdline_parse_result(config, modname, param, value);
+ if (is_module)
+ kcmdline_parse_result(config, modname, param, value);
param = value = NULL;
modname = p + 1;
+ is_module = 1;
break;
case '.':
if (param == NULL) {
@@ -557,12 +559,15 @@
case '=':
if (param != NULL)
value = p + 1;
+ else
+ is_module = 0;
break;
}
}
*p = '\0';
- kcmdline_parse_result(config, modname, param, value);
+ if (is_module)
+ kcmdline_parse_result(config, modname, param, value);
return 0;
}
@@ -813,13 +818,9 @@
*path_stamp = stat_mstamp(&st);
- if (S_ISREG(st.st_mode)) {
+ if (!S_ISDIR(st.st_mode)) {
conf_files_insert_sorted(ctx, list, path, NULL);
return 0;
- } else if (!S_ISDIR(st.st_mode)) {
- ERR(ctx, "unsupported file mode %s: %#x\n",
- path, st.st_mode);
- return -EINVAL;
}
d = opendir(path);
@@ -847,6 +848,8 @@
struct kmod_list *path_list = NULL;
size_t i;
+ conf_files_insert_sorted(ctx, &list, kmod_get_dirname(ctx), "modules.softdep");
+
for (i = 0; config_paths[i] != NULL; i++) {
const char *path = config_paths[i];
unsigned long long path_stamp = 0;
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/libkmod/libkmod-elf.c
^
|
@@ -516,7 +516,7 @@
assert_cc(sizeof(struct kmod_modversion64) ==
sizeof(struct kmod_modversion32));
- if (elf->class == KMOD_ELF_32)
+ if (elf->class & KMOD_ELF_32)
offcrc = sizeof(uint32_t);
else
offcrc = sizeof(uint64_t);
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/libkmod/libkmod-internal.h
^
|
@@ -93,6 +93,7 @@
int kmod_lookup_alias_from_builtin_file(struct kmod_ctx *ctx, const char *name, struct kmod_list **list) __attribute__((nonnull(1, 2, 3)));
int kmod_lookup_alias_from_commands(struct kmod_ctx *ctx, const char *name, struct kmod_list **list) __attribute__((nonnull(1, 2, 3)));
void kmod_set_modules_visited(struct kmod_ctx *ctx, bool visited) __attribute__((nonnull((1))));
+void kmod_set_modules_required(struct kmod_ctx *ctx, bool required) __attribute__((nonnull((1))));
char *kmod_search_moddep(struct kmod_ctx *ctx, const char *name) __attribute__((nonnull(1,2)));
@@ -142,6 +143,7 @@
void kmod_module_set_remove_commands(struct kmod_module *mod, const char *cmd) __attribute__((nonnull(1)));
void kmod_module_set_visited(struct kmod_module *mod, bool visited) __attribute__((nonnull(1)));
void kmod_module_set_builtin(struct kmod_module *mod, bool builtin) __attribute__((nonnull((1))));
+void kmod_module_set_required(struct kmod_module *mod, bool required) __attribute__((nonnull(1)));
/* libkmod-hash.c */
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/libkmod/libkmod-module.c
^
|
@@ -35,7 +35,6 @@
#include <sys/mman.h>
#include <sys/syscall.h>
#include <sys/wait.h>
-#include <string.h>
#include <fnmatch.h>
#ifdef HAVE_LINUX_MODULE_H
@@ -88,6 +87,13 @@
bool ignorecmd : 1;
/*
+ * set by kmod_module_get_probe_list: indicates whether this is the
+ * module the user asked for or its dependency, or whether this
+ * is a softdep only
+ */
+ bool required : 1;
+
+ /*
* if module was created by searching the modules.builtin file, this
* is set. There's nothing much useful one can do with such a
* "module", except knowing it's builtin.
@@ -209,6 +215,11 @@
mod->builtin = builtin;
}
+void kmod_module_set_required(struct kmod_module *mod, bool required)
+{
+ mod->required = required;
+}
+
/*
* Memory layout with alias:
*
@@ -791,8 +802,7 @@
int err;
const void *mem;
off_t size;
- struct kmod_file *file;
- struct kmod_elf *elf = NULL;
+ struct kmod_elf *elf;
const char *path;
const char *args = options ? options : "";
@@ -805,13 +815,13 @@
return -ENOSYS;
}
- file = kmod_file_open(mod->ctx, path);
- if (file == NULL) {
+ mod->file = kmod_file_open(mod->ctx, path);
+ if (mod->file == NULL) {
err = -errno;
return err;
}
- if (kmod_file_get_direct(file)) {
+ if (kmod_file_get_direct(mod->file)) {
unsigned int kernel_flags = 0;
if (flags & KMOD_INSERT_FORCE_VERMAGIC)
@@ -819,19 +829,16 @@
if (flags & KMOD_INSERT_FORCE_MODVERSION)
kernel_flags |= MODULE_INIT_IGNORE_MODVERSIONS;
- err = finit_module(kmod_file_get_fd(file), args, kernel_flags);
+ err = finit_module(kmod_file_get_fd(mod->file), args, kernel_flags);
if (err == 0 || errno != ENOSYS)
goto init_finished;
}
- size = kmod_file_get_size(file);
- mem = kmod_file_get_contents(file);
-
if (flags & (KMOD_INSERT_FORCE_VERMAGIC | KMOD_INSERT_FORCE_MODVERSION)) {
- elf = kmod_elf_new(mem, size);
+ elf = kmod_file_get_elf(mod->file);
if (elf == NULL) {
err = -errno;
- goto elf_failed;
+ return err;
}
if (flags & KMOD_INSERT_FORCE_MODVERSION) {
@@ -847,7 +854,10 @@
}
mem = kmod_elf_get_memory(elf);
+ } else {
+ mem = kmod_file_get_contents(mod->file);
}
+ size = kmod_file_get_size(mod->file);
err = init_module(mem, size, args);
init_finished:
@@ -855,12 +865,6 @@
err = -errno;
INFO(mod->ctx, "Failed to insert module '%s': %m\n", path);
}
-
- if (elf != NULL)
- kmod_elf_unref(elf);
-elf_failed:
- kmod_file_unref(file);
-
return err;
}
@@ -1041,6 +1045,7 @@
}
static int __kmod_module_get_probe_list(struct kmod_module *mod,
+ bool required,
bool ignorecmd,
struct kmod_list **list);
@@ -1060,7 +1065,7 @@
kmod_list_foreach(l, pre) {
struct kmod_module *m = l->data;
- err = __kmod_module_get_probe_list(m, false, list);
+ err = __kmod_module_get_probe_list(m, false, false, list);
if (err < 0)
goto fail;
}
@@ -1076,7 +1081,7 @@
kmod_list_foreach(l, post) {
struct kmod_module *m = l->data;
- err = __kmod_module_get_probe_list(m, false, list);
+ err = __kmod_module_get_probe_list(m, false, false, list);
if (err < 0)
goto fail;
}
@@ -1090,6 +1095,7 @@
/* re-entrant */
static int __kmod_module_get_probe_list(struct kmod_module *mod,
+ bool required,
bool ignorecmd,
struct kmod_list **list)
{
@@ -1104,6 +1110,19 @@
mod->visited = true;
dep = kmod_module_get_dependencies(mod);
+ if (required) {
+ /*
+ * Called from kmod_module_probe_insert_module(); set the
+ * ->required flag on mod and all its dependencies before
+ * they are possibly visited through some softdeps.
+ */
+ mod->required = true;
+ kmod_list_foreach(l, dep) {
+ struct kmod_module *m = l->data;
+ m->required = true;
+ }
+ }
+
kmod_list_foreach(l, dep) {
struct kmod_module *m = l->data;
err = __kmod_module_fill_softdep(m, list);
@@ -1141,8 +1160,9 @@
* Make sure we don't get screwed by previous calls to this function
*/
kmod_set_modules_visited(mod->ctx, false);
+ kmod_set_modules_required(mod->ctx, false);
- err = __kmod_module_get_probe_list(mod, ignorecmd, list);
+ err = __kmod_module_get_probe_list(mod, true, ignorecmd, list);
if (err < 0) {
kmod_module_unref_list(*list);
*list = NULL;
@@ -1303,8 +1323,12 @@
(flags & KMOD_PROBE_FAIL_ON_LOADED))
break;
- if (err == -EEXIST)
+ /*
+ * Ignore errors from softdeps
+ */
+ if (err == -EEXIST || !m->required)
err = 0;
+
else if (err < 0)
break;
}
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/libkmod/libkmod-signature.c
^
|
@@ -121,7 +121,7 @@
modsig->hash >= PKEY_HASH__LAST ||
modsig->id_type >= PKEY_ID_TYPE__LAST)
return false;
- sig_len = be32toh(modsig->sig_len);
+ sig_len = be32toh(get_unaligned(&modsig->sig_len));
if (size < (off_t)(modsig->signer_len + modsig->key_id_len + sig_len))
return false;
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/libkmod/libkmod.c
^
|
@@ -720,6 +720,16 @@
kmod_module_set_visited((struct kmod_module *)v, visited);
}
+void kmod_set_modules_required(struct kmod_ctx *ctx, bool required)
+{
+ struct hash_iter iter;
+ const void *v;
+
+ hash_iter_init(ctx->modules_by_name, &iter);
+ while (hash_iter_next(&iter, NULL, &v))
+ kmod_module_set_required((struct kmod_module *)v, required);
+}
+
static bool is_cache_invalid(const char *path, unsigned long long stamp)
{
struct stat st;
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/libkmod/python/.gitignore
^
|
@@ -0,0 +1,6 @@
+__pycache__
+dist
+*.c
+*.pyc
+*.so
+kmod/version.py
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/libkmod/python/README
^
|
@@ -0,0 +1,23 @@
+python-kmod
+===========
+
+Python bindings for kmod/libkmod
+
+python-kmod is a Python wrapper module for libkmod, exposing common
+module operations: listing installed modules, modprobe, and rmmod.
+It is at:
+
+Example (python invoked as root)
+--------------------------------
+
+::
+
+ >>> import kmod
+ >>> km = kmod.Kmod()
+ >>> [(m.name, m.size) for m in km.loaded()]
+ [(u'nfs', 407706),
+ (u'nfs_acl', 12741)
+ ...
+ (u'virtio_blk', 17549)]
+ >>> km.modprobe("btrfs")
+ >>> km.rmmod("btrfs")
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/libkmod/python/kmod/__init__.py
^
|
@@ -0,0 +1,24 @@
+# Copyright (C) 2012 W. Trevor King <wking@tremily.us>
+#
+# This file is part of python-kmod.
+#
+# python-kmod is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License version 2.1 as published
+# by the Free Software Foundation.
+#
+# python-kmod 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 python-kmod. If not, see <http://www.gnu.org/licenses/>.
+
+"Libkmod -- Python interface to kmod API."
+
+from .version import __version__
+try:
+ from .kmod import Kmod
+except ImportError:
+ # this is a non-Linux platform
+ pass
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/libkmod/python/kmod/_libkmod_h.pxd
^
|
@@ -0,0 +1,113 @@
+# Copyright (C) 2012 W. Trevor King <wking@tremily.us>
+#
+# This file is part of python-kmod.
+#
+# python-kmod is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License version 2.1 as published
+# by the Free Software Foundation.
+#
+# python-kmod 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 python-kmod. If not, see <http://www.gnu.org/licenses/>.
+
+cimport libc.stdint as _stdint
+
+
+cdef extern from *:
+ ctypedef char* const_char_ptr 'const char *'
+ ctypedef char* const_char_const_ptr 'const char const *'
+ ctypedef void* const_void_ptr 'const void *'
+
+
+cdef extern from 'stdbool.h':
+ ctypedef struct bool:
+ pass
+
+
+cdef extern from 'libkmod.h':
+ # library user context - reads the config and system
+ # environment, user variables, allows custom logging
+ cdef struct kmod_ctx:
+ pass
+
+ kmod_ctx *kmod_new(
+ const_char_ptr dirname, const_char_const_ptr config_paths)
+ kmod_ctx *kmod_ref(kmod_ctx *ctx)
+ kmod_ctx *kmod_unref(kmod_ctx *ctx)
+
+ # Management of libkmod's resources
+ int kmod_load_resources(kmod_ctx *ctx)
+ void kmod_unload_resources(kmod_ctx *ctx)
+
+ # access to kmod generated lists
+ cdef struct kmod_list:
+ pass
+ ctypedef kmod_list* const_kmod_list_ptr 'const struct kmod_list *'
+ kmod_list *kmod_list_next(
+ const_kmod_list_ptr list, const_kmod_list_ptr curr)
+ kmod_list *kmod_list_prev(
+ const_kmod_list_ptr list, const_kmod_list_ptr curr)
+ kmod_list *kmod_list_last(const_kmod_list_ptr list)
+
+ # Operate on kernel modules
+ cdef struct kmod_module:
+ pass
+ ctypedef kmod_module* const_kmod_module_ptr 'const struct kmod_module *'
+ int kmod_module_new_from_name(
+ kmod_ctx *ctx, const_char_ptr name, kmod_module **mod)
+ int kmod_module_new_from_lookup(
+ kmod_ctx *ctx, const_char_ptr given_alias, kmod_list **list)
+ int kmod_module_new_from_loaded(kmod_ctx *ctx, kmod_list **list)
+
+ kmod_module *kmod_module_ref(kmod_module *mod)
+ kmod_module *kmod_module_unref(kmod_module *mod)
+ int kmod_module_unref_list(kmod_list *list)
+ kmod_module *kmod_module_get_module(kmod_list *entry)
+
+ # Flags to kmod_module_probe_insert_module
+ # codes below can be used in return value, too
+ enum: KMOD_PROBE_APPLY_BLACKLIST
+
+ #ctypedef int (*install_callback_t)(
+ # kmod_module *m, const_char_ptr cmdline, const_void_ptr data)
+ #ctypedef void (*print_action_callback_t)(
+ # kmod_module *m, bool install, const_char_ptr options)
+
+ int kmod_module_remove_module(
+ kmod_module *mod, unsigned int flags)
+ int kmod_module_insert_module(
+ kmod_module *mod, unsigned int flags, const_char_ptr options)
+ int kmod_module_probe_insert_module(
+ kmod_module *mod, unsigned int flags, const_char_ptr extra_options,
+ int (*run_install)(
+ kmod_module *m, const_char_ptr cmdline, void *data),
+ const_void_ptr data,
+ void (*print_action)(
+ kmod_module *m, bool install, const_char_ptr options),
+ )
+
+ const_char_ptr kmod_module_get_name(const_kmod_module_ptr mod)
+ const_char_ptr kmod_module_get_path(const_kmod_module_ptr mod)
+ const_char_ptr kmod_module_get_options(const_kmod_module_ptr mod)
+ const_char_ptr kmod_module_get_install_commands(const_kmod_module_ptr mod)
+ const_char_ptr kmod_module_get_remove_commands(const_kmod_module_ptr mod)
+
+ # Information regarding "live information" from module's state, as
+ # returned by kernel
+ int kmod_module_get_refcnt(const_kmod_module_ptr mod)
+ long kmod_module_get_size(const_kmod_module_ptr mod)
+
+ # Information retrieved from ELF headers and section
+ int kmod_module_get_info(const_kmod_module_ptr mod, kmod_list **list)
+ const_char_ptr kmod_module_info_get_key(const_kmod_list_ptr entry)
+ const_char_ptr kmod_module_info_get_value(const_kmod_list_ptr entry)
+ void kmod_module_info_free_list(kmod_list *list)
+
+ int kmod_module_get_versions(const_kmod_module_ptr mod, kmod_list **list)
+ const_char_ptr kmod_module_version_get_symbol(const_kmod_list_ptr entry)
+ _stdint.uint64_t kmod_module_version_get_crc(const_kmod_list_ptr entry)
+ void kmod_module_versions_free_list(kmod_list *list)
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/libkmod/python/kmod/_util.pxd
^
|
@@ -0,0 +1,20 @@
+# Copyright (C) 2012 W. Trevor King <wking@tremily.us>
+#
+# This file is part of python-kmod.
+#
+# python-kmod is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License version 2.1 as published
+# by the Free Software Foundation.
+#
+# python-kmod 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 python-kmod. If not, see <http://www.gnu.org/licenses/>.
+
+cimport _libkmod_h
+
+
+cdef object char_ptr_to_str(_libkmod_h.const_char_ptr bytes)
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/libkmod/python/kmod/_util.pyx
^
|
@@ -0,0 +1,28 @@
+# Copyright (C) 2012 W. Trevor King <wking@tremily.us>
+#
+# This file is part of python-kmod.
+#
+# python-kmod is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License version 2.1 as published
+# by the Free Software Foundation.
+#
+# python-kmod 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 python-kmod. If not, see <http://www.gnu.org/licenses/>.
+
+import sys as _sys
+
+cimport _libkmod_h
+
+
+cdef object char_ptr_to_str(_libkmod_h.const_char_ptr char_ptr):
+ if char_ptr is NULL:
+ return None
+ if _sys.version_info >= (3,): # Python 3
+ return str(char_ptr, 'ascii')
+ # Python 2
+ return unicode(char_ptr, 'ascii')
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/libkmod/python/kmod/error.py
^
|
@@ -0,0 +1,18 @@
+# Copyright (C) 2012 W. Trevor King <wking@tremily.us>
+#
+# This file is part of python-kmod.
+#
+# python-kmod is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License version 2.1 as published
+# by the Free Software Foundation.
+#
+# python-kmod 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 python-kmod. If not, see <http://www.gnu.org/licenses/>.
+
+class KmodError (Exception):
+ pass
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/libkmod/python/kmod/kmod.pxd
^
|
@@ -0,0 +1,22 @@
+# Copyright (C) 2012 W. Trevor King <wking@tremily.us>
+#
+# This file is part of python-kmod.
+#
+# python-kmod is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License version 2.1 as published
+# by the Free Software Foundation.
+#
+# python-kmod 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 python-kmod. If not, see <http://www.gnu.org/licenses/>.
+
+cimport _libkmod_h
+
+
+cdef class Kmod (object):
+ cdef _libkmod_h.kmod_ctx *_kmod_ctx
+ cdef object mod_dir
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/libkmod/python/kmod/kmod.pyx
^
|
@@ -0,0 +1,125 @@
+# Copyright (C) 2012 Red Hat, Inc.
+# W. Trevor King <wking@tremily.us>
+#
+# This file is part of python-kmod.
+#
+# python-kmod is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License version 2.1 as published
+# by the Free Software Foundation.
+#
+# python-kmod 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 python-kmod. If not, see <http://www.gnu.org/licenses/>.
+
+"Define the Kmod class"
+
+cimport cython as _cython
+cimport _libkmod_h
+from error import KmodError as _KmodError
+cimport module as _module
+import module as _module
+cimport list as _list
+import list as _list
+
+
+cdef class Kmod (object):
+ "Wrap a struct kmod_ctx* item"
+ def __cinit__(self):
+ self._kmod_ctx = NULL
+ self.mod_dir = None
+
+ def __dealloc__(self):
+ self._cleanup()
+
+ def __init__(self, mod_dir=None):
+ self.set_mod_dir(mod_dir=mod_dir)
+
+ def set_mod_dir(self, mod_dir=None):
+ self.mod_dir = mod_dir
+ self._setup()
+
+ def _setup(self):
+ cdef char *mod_dir = NULL
+ self._cleanup()
+ if self.mod_dir:
+ mod_dir = self.mod_dir
+ self._kmod_ctx = _libkmod_h.kmod_new(mod_dir, NULL);
+ if self._kmod_ctx is NULL:
+ raise _KmodError('Could not initialize')
+ _libkmod_h.kmod_load_resources(self._kmod_ctx)
+
+ def _cleanup(self):
+ if self._kmod_ctx is not NULL:
+ _libkmod_h.kmod_unload_resources(self._kmod_ctx);
+ self._kmod_ctx = NULL
+
+ def loaded(self):
+ "iterate through currently loaded modules"
+ cdef _list.ModList ml = _list.ModList()
+ cdef _list.ModListItem mli
+ err = _libkmod_h.kmod_module_new_from_loaded(self._kmod_ctx, &ml.list)
+ if err < 0:
+ raise _KmodError('Could not get loaded modules')
+ for item in ml:
+ mli = <_list.ModListItem> item
+ mod = _module.Module()
+ mod.from_mod_list_item(item)
+ yield mod
+
+ def lookup(self, alias_name, flags=_libkmod_h.KMOD_PROBE_APPLY_BLACKLIST):
+ "iterate through modules matching `alias_name`"
+ cdef _list.ModList ml = _list.ModList()
+ cdef _list.ModListItem mli
+ if hasattr(alias_name, 'encode'):
+ alias_name = alias_name.encode('ascii')
+ err = _libkmod_h.kmod_module_new_from_lookup(
+ self._kmod_ctx, alias_name, &ml.list)
+ if err < 0:
+ raise _KmodError('Could not modprobe')
+ for item in ml:
+ mli = <_list.ModListItem> item
+ mod = _module.Module()
+ mod.from_mod_list_item(item)
+ yield mod
+
+ @_cython.always_allow_keywords(True)
+ def module_from_name(self, name):
+ cdef _module.Module mod = _module.Module()
+ if hasattr(name, 'encode'):
+ name = name.encode('ascii')
+ err = _libkmod_h.kmod_module_new_from_name(
+ self._kmod_ctx, name, &mod.module)
+ if err < 0:
+ raise _KmodError('Could not get module')
+ return mod
+
+ def list(self):
+ "iterate through currently loaded modules and sizes"
+ for mod in self.loaded():
+ yield (mod.name, mod.size)
+
+ def modprobe(self, name, quiet=False, *args, **kwargs):
+ """
+ Load a module (or alias) and all modules on which it depends.
+ The 'quiet' option defaults to False; set to True to mimic the behavior
+ of the '--quiet' commandline option.
+ """
+ mods = list(self.lookup(alias_name=name))
+
+ if not mods and not quiet:
+ raise _KmodError('Could not modprobe %s' % name)
+
+ for mod in mods:
+ mod.insert(*args, **kwargs)
+
+ def rmmod(self, module_name, *args, **kwargs):
+ """
+ remove module from current tree
+ e.g. km.rmmod("thinkpad_acpi")
+ """
+ mod = self.module_from_name(name=module_name)
+ mod.remove(*args, **kwargs)
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/libkmod/python/kmod/list.pxd
^
|
@@ -0,0 +1,25 @@
+# Copyright (C) 2012 W. Trevor King <wking@tremily.us>
+#
+# This file is part of python-kmod.
+#
+# python-kmod is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License version 2.1 as published
+# by the Free Software Foundation.
+#
+# python-kmod 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 python-kmod. If not, see <http://www.gnu.org/licenses/>.
+
+cimport _libkmod_h
+
+
+cdef class ModListItem (object):
+ cdef _libkmod_h.kmod_list *list
+
+
+cdef class ModList (ModListItem):
+ cdef _libkmod_h.kmod_list *_next
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/libkmod/python/kmod/list.pyx
^
|
@@ -0,0 +1,45 @@
+# Copyright (C) 2012 W. Trevor King <wking@tremily.us>
+#
+# This file is part of python-kmod.
+#
+# python-kmod is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License version 2.1 as published
+# by the Free Software Foundation.
+#
+# python-kmod 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 python-kmod. If not, see <http://www.gnu.org/licenses/>.
+
+cimport _libkmod_h
+
+
+cdef class ModListItem (object):
+ "Wrap a struct kmod_list* list item"
+ def __cinit__(self):
+ self.list = NULL
+
+
+cdef class ModList (ModListItem):
+ "Wrap a struct kmod_list* list with iteration"
+ def __cinit__(self):
+ self._next = NULL
+
+ def __dealloc__(self):
+ if self.list is not NULL:
+ _libkmod_h.kmod_module_unref_list(self.list)
+
+ def __iter__(self):
+ self._next = self.list
+ return self
+
+ def __next__(self):
+ if self._next is NULL:
+ raise StopIteration()
+ mli = ModListItem()
+ mli.list = self._next
+ self._next = _libkmod_h.kmod_list_next(self.list, self._next)
+ return mli
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/libkmod/python/kmod/module.pxd
^
|
@@ -0,0 +1,24 @@
+# Copyright (C) 2012 W. Trevor King <wking@tremily.us>
+#
+# This file is part of python-kmod.
+#
+# python-kmod is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License version 2.1 as published
+# by the Free Software Foundation.
+#
+# python-kmod 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 python-kmod. If not, see <http://www.gnu.org/licenses/>.
+
+cimport _libkmod_h
+cimport list as _list
+
+
+cdef class Module (object):
+ cdef _libkmod_h.kmod_module *module
+
+ cpdef from_mod_list_item(self, _list.ModListItem item)
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/libkmod/python/kmod/module.pyx
^
|
@@ -0,0 +1,158 @@
+# Copyright (C) 2012 W. Trevor King <wking@tremily.us>
+#
+# This file is part of python-kmod.
+#
+# python-kmod is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License version 2.1 as published
+# by the Free Software Foundation.
+#
+# python-kmod 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 python-kmod. If not, see <http://www.gnu.org/licenses/>.
+
+import collections as _collections
+
+cimport libc.errno as _errno
+
+cimport _libkmod_h
+from error import KmodError as _KmodError
+cimport list as _list
+import list as _list
+cimport _util
+import _util
+
+
+cdef class Module (object):
+ "Wrap a struct kmod_module* item"
+ def __cinit__(self):
+ self.module = NULL
+
+ def __dealloc__(self):
+ self._cleanup()
+
+ def _cleanup(self):
+ if self.module is not NULL:
+ _libkmod_h.kmod_module_unref(self.module)
+ self.module = NULL
+
+ cpdef from_mod_list_item(self, _list.ModListItem item):
+ self._cleanup()
+ self.module = _libkmod_h.kmod_module_get_module(item.list)
+
+ def _name_get(self):
+ return _util.char_ptr_to_str(
+ _libkmod_h.kmod_module_get_name(self.module))
+ name = property(fget=_name_get)
+
+ def _path_get(self):
+ return _util.char_ptr_to_str(
+ _libkmod_h.kmod_module_get_path(self.module))
+ path = property(fget=_path_get)
+
+ def _options_get(self):
+ return _util.char_ptr_to_str(
+ _libkmod_h.kmod_module_get_options(self.module))
+ options = property(fget=_options_get)
+
+ def _install_commands_get(self):
+ return _util.char_ptr_to_str(
+ _libkmod_h.kmod_module_get_install_commands(self.module))
+ install_commands = property(fget=_install_commands_get)
+
+ def _remove_commands_get(self):
+ return _util.char_ptr_to_str(
+ _libkmod_h.kmod_module_get_remove_commands(self.module))
+ remove_commands = property(fget=_remove_commands_get)
+
+ def _refcnt_get(self):
+ return _libkmod_h.kmod_module_get_refcnt(self.module)
+ refcnt = property(fget=_refcnt_get)
+
+ def _size_get(self):
+ return _libkmod_h.kmod_module_get_size(self.module)
+ size = property(fget=_size_get)
+
+ def _info_get(self):
+ cdef _list.ModList ml = _list.ModList()
+ cdef _list.ModListItem mli
+ err = _libkmod_h.kmod_module_get_info(self.module, &ml.list)
+ if err < 0:
+ raise _KmodError('Could not get info')
+ info = _collections.OrderedDict()
+ try:
+ for item in ml:
+ mli = <_list.ModListItem> item
+ key = _util.char_ptr_to_str(
+ _libkmod_h.kmod_module_info_get_key(mli.list))
+ value = _util.char_ptr_to_str(
+ _libkmod_h.kmod_module_info_get_value(mli.list))
+ info[key] = value
+ finally:
+ _libkmod_h.kmod_module_info_free_list(ml.list)
+ ml.list = NULL
+ return info
+ info = property(fget=_info_get)
+
+ def _versions_get(self):
+ cdef _list.ModList ml = _list.ModList()
+ cdef _list.ModListItem mli
+ err = _libkmod_h.kmod_module_get_versions(self.module, &ml.list)
+ if err < 0:
+ raise _KmodError('Could not get versions')
+ try:
+ for item in ml:
+ mli = <_list.ModListItem> item
+ symbol = _util.char_ptr_to_str(
+ _libkmod_h.kmod_module_version_get_symbol(mli.list))
+ crc = _libkmod_h.kmod_module_version_get_crc(mli.list)
+ yield {'symbol': symbol, 'crc': crc}
+ finally:
+ _libkmod_h.kmod_module_versions_free_list(ml.list)
+ ml.list = NULL
+ versions = property(fget=_versions_get)
+
+ def insert(self, flags=0, extra_options=None, install_callback=None,
+ data=None, print_action_callback=None):
+ """
+ insert module to current tree.
+ e.g.
+ km = kmod.Kmod()
+ tp = km.module_from_name("thinkpad_acpi")
+ tp.insert(extra_options='fan_control=1')
+ """
+ cdef char *opt = NULL
+ #cdef _libkmod_h.install_callback_t install = NULL
+ cdef int (*install)(
+ _libkmod_h.kmod_module *, _libkmod_h.const_char_ptr, void *)
+ install = NULL
+ cdef void *d = NULL
+ #cdef _libkmod_h.print_action_callback_t print_action = NULL
+ cdef void (*print_action)(
+ _libkmod_h.kmod_module *, _libkmod_h.bool,
+ _libkmod_h.const_char_ptr)
+ print_action = NULL
+ if extra_options:
+ opt = extra_options
+ # TODO: convert callbacks and data from Python object to C types
+ err = _libkmod_h.kmod_module_probe_insert_module(
+ self.module, flags, opt, install, d, print_action)
+ if err == -_errno.EEXIST:
+ raise _KmodError('Module already loaded')
+ elif err < 0:
+ raise _KmodError('Could not load module')
+
+ def remove(self, flags=0):
+ """
+ remove module from current tree
+ e.g.
+ km = kmod.Kmod()
+ tp = km.module_from_name("thinkpad_acpi")
+ tp.remove()
+ """
+ err = _libkmod_h.kmod_module_remove_module(self.module, flags)
+ if err < 0:
+ raise _KmodError('Could not remove module')
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/libkmod/python/kmod/version.py.in
^
|
@@ -0,0 +1,17 @@
+# Copyright (C) 2012 W. Trevor King <wking@tremily.us>
+#
+# This file is part of python-kmod.
+#
+# python-kmod is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License version 2.1 as published
+# by the Free Software Foundation.
+#
+# python-kmod 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 python-kmod. If not, see <http://www.gnu.org/licenses/>.
+
+__version__ = '@VERSION@'
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/man/.gitignore
^
|
@@ -1,2 +1,4 @@
*.5
*.8
+Makefile
+Makefile.in
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/man/depmod.d.xml
^
|
@@ -23,7 +23,7 @@
<contrib>Developer</contrib>
<firstname>Lucas</firstname>
<surname>De Marchi</surname>
- <email>lucas.demarchi@profusion.mobi</email>
+ <email>lucas.de.marchi@gmail.com</email>
</author>
</authorgroup>
</refentryinfo>
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/man/depmod.xml
^
|
@@ -24,7 +24,7 @@
<contrib>Developer</contrib>
<firstname>Lucas</firstname>
<surname>De Marchi</surname>
- <email>lucas.demarchi@profusion.mobi</email>
+ <email>lucas.de.marchi@gmail.com</email>
</author>
</authorgroup>
</refentryinfo>
@@ -93,9 +93,11 @@
<command>depmod</command> will output a file named
<filename>modules.devname</filename> if modules supply special device
names (devname) that should be populated in /dev on boot (by a utility
- such as udev). </para> <para> If a <replaceable>version</replaceable> is
- provided, then that kernel version's module directory is used rather than
- the current kernel version (as returned by <command>uname -r</command>).
+ such as systemd-tmpfiles).
+ </para>
+ <para> If a <replaceable>version</replaceable> is provided, then that kernel
+ version's module directory is used rather than the current kernel version
+ (as returned by <command>uname -r</command>).
</para>
</refsect1>
<refsect1><title>OPTIONS</title>
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/man/insmod.xml
^
|
@@ -18,7 +18,7 @@
<contrib>Developer</contrib>
<firstname>Lucas</firstname>
<surname>De Marchi</surname>
- <email>lucas.demarchi@profusion.mobi</email>
+ <email>lucas.de.marchi@gmail.com</email>
</author>
</authorgroup>
</refentryinfo>
@@ -75,7 +75,7 @@
</citerefentry>,
<citerefentry>
<refentrytitle>lsmod</refentrytitle><manvolnum>8</manvolnum>
- </citerefentry>
+ </citerefentry>,
<citerefentry>
<refentrytitle>modinfo</refentrytitle><manvolnum>8</manvolnum>
</citerefentry>
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/man/lsmod.xml
^
|
@@ -18,7 +18,7 @@
<contrib>Developer</contrib>
<firstname>Lucas</firstname>
<surname>De Marchi</surname>
- <email>lucas.demarchi@profusion.mobi</email>
+ <email>lucas.de.marchi@gmail.com</email>
</author>
</authorgroup>
</refentryinfo>
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/man/modinfo.xml
^
|
@@ -18,7 +18,7 @@
<contrib>Developer</contrib>
<firstname>Lucas</firstname>
<surname>De Marchi</surname>
- <email>lucas.demarchi@profusion.mobi</email>
+ <email>lucas.de.marchi@gmail.com</email>
</author>
</authorgroup>
</refentryinfo>
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/man/modprobe.d.xml
^
|
@@ -23,7 +23,7 @@
<contrib>Developer</contrib>
<firstname>Lucas</firstname>
<surname>De Marchi</surname>
- <email>lucas.demarchi@profusion.mobi</email>
+ <email>lucas.de.marchi@gmail.com</email>
</author>
</authorgroup>
</refentryinfo>
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/man/modprobe.xml
^
|
@@ -24,7 +24,7 @@
<contrib>Developer</contrib>
<firstname>Lucas</firstname>
<surname>De Marchi</surname>
- <email>lucas.demarchi@profusion.mobi</email>
+ <email>lucas.de.marchi@gmail.com</email>
</author>
</authorgroup>
</refentryinfo>
@@ -101,8 +101,7 @@
</para>
<para>
<command>modprobe</command> expects an up-to-date
- <filename>modules.dep.bin</filename> file (or fallback human
- readable <filename>modules.dep</filename> file), as generated
+ <filename>modules.dep.bin</filename> file as generated
by the corresponding <command>depmod</command> utility shipped
along with <command>modprobe</command> (see
<citerefentry><refentrytitle>depmod</refentrytitle><manvolnum>8</manvolnum>
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/man/modules.dep.xml
^
|
@@ -17,7 +17,7 @@
<contrib>Developer</contrib>
<firstname>Lucas</firstname>
<surname>De Marchi</surname>
- <email>lucas.demarchi@profusion.mobi</email>
+ <email>lucas.de.marchi@gmail.com</email>
</author>
</authorgroup>
</refentryinfo>
@@ -40,16 +40,17 @@
<refsect1><title>DESCRIPTION</title>
<para>
- The <filename>modules.dep.bin</filename> as generated by
- module-init-tools <command>depmod</command>, lists the dependencies for
+ <filename>modules.dep.bin</filename> is a binary file generated by
+ <command>depmod</command> listing the dependencies for
every module in the directories under
- <filename>/lib/modules/</filename><replaceable>version</replaceable>,
- where <filename>modules.dep.bin</filename> (or the human readable version
- <filename>modules.dep</filename>) is also located. It is used by
- utilities such as <command>modprobe</command>. The binary version will be
- used by default, if it was generated by a compatible version of
- <command>depmod</command>, with fallback to the generic
- <filename>modules.dep</filename>.
+ <filename>/lib/modules/</filename><replaceable>version</replaceable>.
+ It is used by kmod tools such as <command>modprobe</command> and
+ libkmod.
+ </para>
+ <para>
+ Its text counterpar is located in the same directory with the name
+ <filename>modules.dep</filename>. The text version is maintained only
+ for easy of reading by humans and is in no way used by any kmod tool.
</para>
<para>
These files are not intended for editing or use by any additional
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/man/rmmod.xml
^
|
@@ -18,7 +18,7 @@
<contrib>Developer</contrib>
<firstname>Lucas</firstname>
<surname>De Marchi</surname>
- <email>lucas.demarchi@profusion.mobi</email>
+ <email>lucas.de.marchi@gmail.com</email>
</author>
</authorgroup>
</refentryinfo>
@@ -39,7 +39,6 @@
<cmdsynopsis>
<command>rmmod</command>
<arg><option>-f</option></arg>
- <arg><option>-w</option></arg>
<arg><option>-s</option></arg>
<arg><option>-v</option></arg>
<arg><replaceable>modulename</replaceable></arg>
@@ -93,22 +92,6 @@
</para>
</listitem>
</varlistentry>
- <varlistentry>
- <term><option>-w</option> <option>--wait</option>
- </term>
- <listitem>
- <para>
- Normally, <command>rmmod</command> will refuse to unload modules
- which are in use. With this option, <command>rmmod</command> will
- isolate the module, and wait until the module is no longer used.
- Nothing new will be able to use the module, but it's up to you to
- make sure the current users eventually finish with it. See
- <citerefentry>
- <refentrytitle>lsmod</refentrytitle><manvolnum>8</manvolnum>
- </citerefentry>) for information on usage counts.
- </para>
- </listitem>
- </varlistentry>
<varlistentry>
<term>
<option>-s</option>
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/Makefile
^
|
@@ -0,0 +1,15 @@
+# Copyright 2010 Lennart Poettering
+#
+# This file has been copied from systemd. It is a dirty trick to simplify
+# compilation when CWD is not the root of the source tree. This file is not
+# intended to be distributed. So, don't touch it, even better ignore it!
+
+all:
+ $(MAKE) -C .. check
+check:
+ $(MAKE) -C .. check
+
+clean:
+ $(MAKE) -C .. clean
+
+.PHONY: all clean check
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/init_module.c
^
|
@@ -37,6 +37,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/syscall.h>
+#include <sys/utsname.h>
#include <unistd.h>
/* kmod_elf_get_section() is not exported, we need the private header */
@@ -280,6 +281,25 @@
return err;
}
+static int check_kernel_version(int major, int minor)
+{
+ struct utsname u;
+ const char *p;
+ int maj = 0, min = 0;
+
+ if (uname(&u) < 0)
+ return false;
+ for (p = u.release; *p >= '0' && *p <= '9'; p++)
+ maj = maj * 10 + *p - '0';
+ if (*p == '.')
+ for (p++; *p >= '0' && *p <= '9'; p++)
+ min = min * 10 + *p - '0';
+ if (maj > major || (maj == major && min >= minor))
+ return true;
+ return false;
+}
+
+
TS_EXPORT int finit_module(const int fd, const char *args, const int flags);
int finit_module(const int fd, const char *args, const int flags)
@@ -289,6 +309,10 @@
unsigned long len;
struct stat st;
+ if (!check_kernel_version(3, 8)) {
+ errno = ENOSYS;
+ return -1;
+ }
if (fstat(fd, &st) < 0)
return -1;
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-depmod/search-order-same-prefix/etc/depmod.d/search.conf
^
|
@@ -0,0 +1 @@
+search foobar foo built-in
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-depmod/search-order-same-prefix/lib/modules/4.4.4/correct-modules.dep
^
|
@@ -0,0 +1 @@
+foobar/md5.ko:
|
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-depmod/search-order-same-prefix/lib/modules/4.4.4/foo/md5.ko
^
|
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-depmod/search-order-same-prefix/lib/modules/4.4.4/foobar/md5.ko
^
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-depmod/search-order-simple/etc/depmod.d/search.conf
^
|
@@ -0,0 +1 @@
+search updates built-in
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-depmod/search-order-simple/lib/modules/4.4.4/correct-modules.dep
^
|
@@ -0,0 +1 @@
+updates/md5.ko:
|
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-depmod/search-order-simple/lib/modules/4.4.4/kernel/crypto/md5.ko
^
|
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-depmod/search-order-simple/lib/modules/4.4.4/updates/md5.ko
^
|
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/force/lib/modules/4.4.4/kernel/drivers/input/mouse/psmouse.ko
^
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/force/lib/modules/4.4.4/modules.alias
^
|
@@ -0,0 +1,3 @@
+# Aliases extracted from modules themselves.
+alias serio:ty05pr*id*ex* psmouse
+alias serio:ty01pr*id*ex* psmouse
|
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/force/lib/modules/4.4.4/modules.alias.bin
^
|
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/force/lib/modules/4.4.4/modules.builtin.bin
^
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/force/lib/modules/4.4.4/modules.dep
^
|
@@ -0,0 +1 @@
+kernel/drivers/input/mouse/psmouse.ko:
|
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/force/lib/modules/4.4.4/modules.dep.bin
^
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/force/lib/modules/4.4.4/modules.devname
^
|
@@ -0,0 +1 @@
+# Device nodes to trigger on-demand module loading.
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/force/lib/modules/4.4.4/modules.softdep
^
|
@@ -0,0 +1,2 @@
+# Soft dependencies extracted from modules themselves.
+# Copy, with a .conf extension, to /etc/modprobe.d to use it with modprobe.
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/force/lib/modules/4.4.4/modules.symbols
^
|
@@ -0,0 +1 @@
+# Aliases for symbols, used by symbol_request().
|
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/force/lib/modules/4.4.4/modules.symbols.bin
^
|
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/force/proc/modules
^
|
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/install-cmd-loop/lib/modules/4.4.4/kernel/sound/core/snd-pcm.ko
^
|
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/install-cmd-loop/lib/modules/4.4.4/kernel/sound/core/snd.ko
^
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/install-cmd-loop/lib/modules/4.4.4/modules.dep
^
|
@@ -1,2 +1,2 @@
-kernel/sound/core/snd.ko.gz:
-kernel/sound/core/snd-pcm.ko.gz: kernel/sound/core/snd.ko.gz
+kernel/sound/core/snd.ko:
+kernel/sound/core/snd-pcm.ko: kernel/sound/core/snd.ko
|
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/install-cmd-loop/lib/modules/4.4.4/modules.dep.bin
^
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/install-cmd-loop/lib/modules/4.4.4/modules.softdep
^
|
@@ -1,2 +1 @@
# Soft dependencies extracted from modules themselves.
-# Copy, with a .conf extension, to /etc/modprobe.d to use it with modprobe.
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline2/correct.txt
^
|
@@ -0,0 +1,5 @@
+options psmouse foo
+options psmouse bar=1
+
+# End of configuration files. Dumping indexes now:
+
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline2/proc/cmdline
^
|
@@ -0,0 +1 @@
+psmouse.foo psmouse.bar=1 quiet rw
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline3/correct.txt
^
|
@@ -0,0 +1,5 @@
+options psmouse foo
+options psmouse bar=1
+
+# End of configuration files. Dumping indexes now:
+
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline3/proc/cmdline
^
|
@@ -0,0 +1 @@
+BOOT_IMAGE=/boot/vmlinuz-3.12.12-57.g5f654cf-default initrd=\initramfs-linux.img psmouse.foo psmouse.bar=1 root=/dev/sda2 rootfstype=ext4 add_efi_memmap quiet rw
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline4/correct.txt
^
|
@@ -0,0 +1,4 @@
+options testmodule testparam=1.5G
+
+# End of configuration files. Dumping indexes now:
+
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline4/proc/cmdline
^
|
@@ -0,0 +1 @@
+testmodule.testparam=1.5G
|
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/oldkernel-force/lib/modules/3.3.3/kernel/drivers/input/mouse/psmouse.ko
^
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/oldkernel-force/lib/modules/3.3.3/modules.alias
^
|
@@ -0,0 +1,3 @@
+# Aliases extracted from modules themselves.
+alias serio:ty05pr*id*ex* psmouse
+alias serio:ty01pr*id*ex* psmouse
|
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/oldkernel-force/lib/modules/3.3.3/modules.alias.bin
^
|
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/oldkernel-force/lib/modules/3.3.3/modules.builtin.bin
^
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/oldkernel-force/lib/modules/3.3.3/modules.dep
^
|
@@ -0,0 +1 @@
+kernel/drivers/input/mouse/psmouse.ko:
|
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/oldkernel-force/lib/modules/3.3.3/modules.dep.bin
^
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/oldkernel-force/lib/modules/3.3.3/modules.devname
^
|
@@ -0,0 +1 @@
+# Device nodes to trigger on-demand module loading.
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/oldkernel-force/lib/modules/3.3.3/modules.softdep
^
|
@@ -0,0 +1,2 @@
+# Soft dependencies extracted from modules themselves.
+# Copy, with a .conf extension, to /etc/modprobe.d to use it with modprobe.
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/oldkernel-force/lib/modules/3.3.3/modules.symbols
^
|
@@ -0,0 +1 @@
+# Aliases for symbols, used by symbol_request().
|
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/oldkernel-force/lib/modules/3.3.3/modules.symbols.bin
^
|
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/oldkernel-force/proc/modules
^
|
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/oldkernel/lib/modules/3.3.3/kernel/drivers/input/mouse/psmouse.ko
^
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/oldkernel/lib/modules/3.3.3/modules.alias
^
|
@@ -0,0 +1,3 @@
+# Aliases extracted from modules themselves.
+alias serio:ty05pr*id*ex* psmouse
+alias serio:ty01pr*id*ex* psmouse
|
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/oldkernel/lib/modules/3.3.3/modules.alias.bin
^
|
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/oldkernel/lib/modules/3.3.3/modules.builtin.bin
^
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/oldkernel/lib/modules/3.3.3/modules.dep
^
|
@@ -0,0 +1 @@
+kernel/drivers/input/mouse/psmouse.ko:
|
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/oldkernel/lib/modules/3.3.3/modules.dep.bin
^
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/oldkernel/lib/modules/3.3.3/modules.devname
^
|
@@ -0,0 +1 @@
+# Device nodes to trigger on-demand module loading.
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/oldkernel/lib/modules/3.3.3/modules.softdep
^
|
@@ -0,0 +1,2 @@
+# Soft dependencies extracted from modules themselves.
+# Copy, with a .conf extension, to /etc/modprobe.d to use it with modprobe.
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/oldkernel/lib/modules/3.3.3/modules.symbols
^
|
@@ -0,0 +1 @@
+# Aliases for symbols, used by symbol_request().
|
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/oldkernel/lib/modules/3.3.3/modules.symbols.bin
^
|
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/rootfs-pristine/test-modprobe/oldkernel/proc/modules
^
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/test-depmod.c
^
|
@@ -54,9 +54,65 @@
},
});
+#define SEARCH_ORDER_SIMPLE_ROOTFS TESTSUITE_ROOTFS "test-depmod/search-order-simple"
+static noreturn int depmod_search_order_simple(const struct test *t)
+{
+ const char *progname = ABS_TOP_BUILDDIR "/tools/depmod";
+ const char *const args[] = {
+ progname,
+ NULL,
+ };
+
+ test_spawn_prog(progname, args);
+ exit(EXIT_FAILURE);
+}
+static DEFINE_TEST(depmod_search_order_simple,
+ .description = "check if depmod honor search order in config",
+ .config = {
+ [TC_UNAME_R] = "4.4.4",
+ [TC_ROOTFS] = SEARCH_ORDER_SIMPLE_ROOTFS,
+ },
+ .output = {
+ .files = (const struct keyval[]) {
+ { SEARCH_ORDER_SIMPLE_ROOTFS "/lib/modules/4.4.4/correct-modules.dep",
+ SEARCH_ORDER_SIMPLE_ROOTFS "/lib/modules/4.4.4/modules.dep" },
+ { }
+ },
+ });
+
+#define SEARCH_ORDER_SAME_PREFIX_ROOTFS TESTSUITE_ROOTFS "test-depmod/search-order-same-prefix"
+static noreturn int depmod_search_order_same_prefix(const struct test *t)
+{
+ const char *progname = ABS_TOP_BUILDDIR "/tools/depmod";
+ const char *const args[] = {
+ progname,
+ NULL,
+ };
+
+ test_spawn_prog(progname, args);
+ exit(EXIT_FAILURE);
+}
+static DEFINE_TEST(depmod_search_order_same_prefix,
+ .description = "check if depmod honor search order in config with same prefix",
+ .config = {
+ [TC_UNAME_R] = "4.4.4",
+ [TC_ROOTFS] = SEARCH_ORDER_SAME_PREFIX_ROOTFS,
+ },
+ .output = {
+ .files = (const struct keyval[]) {
+ { SEARCH_ORDER_SAME_PREFIX_ROOTFS "/lib/modules/4.4.4/correct-modules.dep",
+ SEARCH_ORDER_SAME_PREFIX_ROOTFS "/lib/modules/4.4.4/modules.dep" },
+ { }
+ },
+ });
+
static const struct test *tests[] = {
+#ifdef ENABLE_ZLIB
&sdepmod_modules_order_for_compressed,
+#endif
+ &sdepmod_search_order_simple,
+ &sdepmod_search_order_same_prefix,
NULL,
};
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/test-init.c
^
|
@@ -74,6 +74,7 @@
[TC_ROOTFS] = TESTSUITE_ROOTFS "test-init/",
[TC_INIT_MODULE_RETCODES] = "bla:1:20",
},
+ .modules_loaded = "ext4",
.need_spawn = true);
static noreturn int test_remove(const struct test *t)
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/test-modprobe.c
^
|
@@ -91,7 +91,9 @@
},
.output = {
.out = TESTSUITE_ROOTFS "test-modprobe/show-depends/correct-psmouse.txt",
- });
+ },
+ .modules_loaded = "",
+ );
static noreturn int modprobe_builtin(const struct test *t)
@@ -131,7 +133,9 @@
[TC_UNAME_R] = "4.4.4",
[TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/softdep-loop",
[TC_INIT_MODULE_RETCODES] = "",
- });
+ },
+ .modules_loaded = "btusb,bluetooth",
+ );
static noreturn int modprobe_install_cmd_loop(const struct test *t)
{
@@ -156,6 +160,7 @@
{ "MODPROBE", ABS_TOP_BUILDDIR "/tools/modprobe" },
{ }
},
+ .modules_loaded = "snd,snd-pcm",
);
static noreturn int modprobe_param_kcmdline(const struct test *t)
@@ -171,14 +176,154 @@
exit(EXIT_FAILURE);
}
static DEFINE_TEST(modprobe_param_kcmdline,
- .description = "check if params are parsed correctly from kcmdline",
+ .description = "check if params from kcmdline are passed in fact passed to (f)init_module call",
.config = {
[TC_UNAME_R] = "4.4.4",
[TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline",
},
.output = {
.out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline/correct.txt",
- });
+ },
+ .modules_loaded = "",
+ );
+
+static noreturn int modprobe_param_kcmdline2(const struct test *t)
+{
+ const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe";
+ const char *const args[] = {
+ progname,
+ "-c",
+ NULL,
+ };
+
+ test_spawn_prog(progname, args);
+ exit(EXIT_FAILURE);
+}
+static DEFINE_TEST(modprobe_param_kcmdline2,
+ .description = "check if params with no value are parsed correctly from kcmdline",
+ .config = {
+ [TC_UNAME_R] = "4.4.4",
+ [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline2",
+ },
+ .output = {
+ .out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline2/correct.txt",
+ },
+ .modules_loaded = "",
+ );
+
+static noreturn int modprobe_param_kcmdline3(const struct test *t)
+{
+ const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe";
+ const char *const args[] = {
+ progname,
+ "-c",
+ NULL,
+ };
+
+ test_spawn_prog(progname, args);
+ exit(EXIT_FAILURE);
+}
+static DEFINE_TEST(modprobe_param_kcmdline3,
+ .description = "check if unrelated strings in kcmdline are correctly ignored",
+ .config = {
+ [TC_UNAME_R] = "4.4.4",
+ [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline3",
+ },
+ .output = {
+ .out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline3/correct.txt",
+ },
+ .modules_loaded = "",
+ );
+
+static noreturn int modprobe_param_kcmdline4(const struct test *t)
+{
+ const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe";
+ const char *const args[] = {
+ progname,
+ "-c",
+ NULL,
+ };
+
+ test_spawn_prog(progname, args);
+ exit(EXIT_FAILURE);
+}
+static DEFINE_TEST(modprobe_param_kcmdline4,
+ .description = "check if unrelated strings in kcmdline are correctly ignored",
+ .config = {
+ [TC_UNAME_R] = "4.4.4",
+ [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline4",
+ },
+ .output = {
+ .out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline4/correct.txt",
+ },
+ .modules_loaded = "",
+ );
+
+static noreturn int modprobe_force(const struct test *t)
+{
+ const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe";
+ const char *const args[] = {
+ progname,
+ "--force", "psmouse",
+ NULL,
+ };
+
+ test_spawn_prog(progname, args);
+ exit(EXIT_FAILURE);
+}
+static DEFINE_TEST(modprobe_force,
+ .description = "check modprobe --force",
+ .config = {
+ [TC_UNAME_R] = "4.4.4",
+ [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/force",
+ [TC_INIT_MODULE_RETCODES] = "",
+ },
+ .modules_loaded = "psmouse",
+ );
+
+static noreturn int modprobe_oldkernel(const struct test *t)
+{
+ const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe";
+ const char *const args[] = {
+ progname,
+ "psmouse",
+ NULL,
+ };
+
+ test_spawn_prog(progname, args);
+ exit(EXIT_FAILURE);
+}
+static DEFINE_TEST(modprobe_oldkernel,
+ .description = "check modprobe --force",
+ .config = {
+ [TC_UNAME_R] = "3.3.3",
+ [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/oldkernel",
+ [TC_INIT_MODULE_RETCODES] = "",
+ },
+ .modules_loaded = "psmouse",
+ );
+
+static noreturn int modprobe_oldkernel_force(const struct test *t)
+{
+ const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe";
+ const char *const args[] = {
+ progname,
+ "--force", "psmouse",
+ NULL,
+ };
+
+ test_spawn_prog(progname, args);
+ exit(EXIT_FAILURE);
+}
+static DEFINE_TEST(modprobe_oldkernel_force,
+ .description = "check modprobe --force",
+ .config = {
+ [TC_UNAME_R] = "3.3.3",
+ [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/oldkernel-force",
+ [TC_INIT_MODULE_RETCODES] = "",
+ },
+ .modules_loaded = "psmouse",
+ );
static const struct test *tests[] = {
@@ -189,6 +334,12 @@
&smodprobe_softdep_loop,
&smodprobe_install_cmd_loop,
&smodprobe_param_kcmdline,
+ &smodprobe_param_kcmdline2,
+ &smodprobe_param_kcmdline3,
+ &smodprobe_param_kcmdline4,
+ &smodprobe_force,
+ &smodprobe_oldkernel,
+ &smodprobe_oldkernel_force,
NULL,
};
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/testsuite.c
^
|
@@ -20,6 +20,7 @@
#include <fcntl.h>
#include <getopt.h>
#include <limits.h>
+#include <dirent.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
@@ -528,12 +529,189 @@
return true;
}
+static int cmp_modnames(const void *m1, const void *m2)
+{
+ const char *s1 = *(char *const *)m1;
+ const char *s2 = *(char *const *)m2;
+ int i;
+
+ for (i = 0; s1[i] || s2[i]; i++) {
+ char c1 = s1[i], c2 = s2[i];
+ if (c1 == '-')
+ c1 = '_';
+ if (c2 == '-')
+ c2 = '_';
+ if (c1 != c2)
+ return c1 - c2;
+ }
+ return 0;
+}
+
+/*
+ * Store the expected module names in buf and return a list of pointers to
+ * them.
+ */
+static const char **read_expected_modules(const struct test *t,
+ char **buf, int *count)
+{
+ const char **res;
+ int len;
+ int i;
+ char *p;
+
+ if (t->modules_loaded[0] == '\0') {
+ *count = 0;
+ *buf = NULL;
+ return NULL;
+ }
+ *buf = strdup(t->modules_loaded);
+ if (!*buf) {
+ *count = -1;
+ return NULL;
+ }
+ len = 1;
+ for (p = *buf; *p; p++)
+ if (*p == ',')
+ len++;
+ res = malloc(sizeof(char *) * len);
+ if (!res) {
+ perror("malloc");
+ *count = -1;
+ free(*buf);
+ *buf = NULL;
+ return NULL;
+ }
+ i = 0;
+ res[i++] = *buf;
+ for (p = *buf; i < len; p++)
+ if (*p == ',') {
+ *p = '\0';
+ res[i++] = p + 1;
+ }
+ *count = len;
+ return res;
+}
+
+static char **read_loaded_modules(const struct test *t, char **buf, int *count)
+{
+ char dirname[PATH_MAX];
+ DIR *dir;
+ struct dirent *dirent;
+ int i;
+ int len = 0, bufsz;
+ char **res = NULL;
+ char *p;
+ const char *rootfs = t->config[TC_ROOTFS] ? t->config[TC_ROOTFS] : "";
+
+ /* Store the entries in /sys/module to res */
+ if (snprintf(dirname, sizeof(dirname), "%s/sys/module", rootfs)
+ >= (int)sizeof(dirname)) {
+ ERR("rootfs path too long: %s\n", rootfs);
+ *buf = NULL;
+ len = -1;
+ goto out;
+ }
+ dir = opendir(dirname);
+ /* not an error, simply return empty list */
+ if (!dir) {
+ *buf = NULL;
+ goto out;
+ }
+ bufsz = 0;
+ while ((dirent = readdir(dir))) {
+ if (dirent->d_name[0] == '.')
+ continue;
+ len++;
+ bufsz += strlen(dirent->d_name) + 1;
+ }
+ res = malloc(sizeof(char *) * len);
+ if (!res) {
+ perror("malloc");
+ len = -1;
+ goto out_dir;
+ }
+ *buf = malloc(bufsz);
+ if (!*buf) {
+ perror("malloc");
+ free(res);
+ res = NULL;
+ len = -1;
+ goto out_dir;
+ }
+ rewinddir(dir);
+ i = 0;
+ p = *buf;
+ while ((dirent = readdir(dir))) {
+ int size;
+
+ if (dirent->d_name[0] == '.')
+ continue;
+ size = strlen(dirent->d_name) + 1;
+ memcpy(p, dirent->d_name, size);
+ res[i++] = p;
+ p += size;
+ }
+out_dir:
+ closedir(dir);
+out:
+ *count = len;
+ return res;
+}
+
+static int check_loaded_modules(const struct test *t)
+{
+ int l1, l2, i1, i2;
+ const char **a1;
+ char **a2;
+ char *buf1, *buf2;
+ int err = false;
+
+ a1 = read_expected_modules(t, &buf1, &l1);
+ if (l1 < 0)
+ return err;
+ a2 = read_loaded_modules(t, &buf2, &l2);
+ if (l2 < 0)
+ goto out_a1;
+ qsort(a1, l1, sizeof(char *), cmp_modnames);
+ qsort(a2, l2, sizeof(char *), cmp_modnames);
+ i1 = i2 = 0;
+ err = true;
+ while (i1 < l1 || i2 < l2) {
+ int cmp;
+
+ if (i1 >= l1)
+ cmp = 1;
+ else if (i2 >= l2)
+ cmp = -1;
+ else
+ cmp = cmp_modnames(&a1[i1], &a2[i2]);
+ if (cmp == 0) {
+ i1++;
+ i2++;
+ } else if (cmp < 0) {
+ err = false;
+ ERR("module %s not loaded\n", a1[i1]);
+ i1++;
+ } else {
+ err = false;
+ ERR("module %s is loaded but should not be \n", a2[i2]);
+ i2++;
+ }
+ }
+ free(a2);
+ free(buf2);
+out_a1:
+ free(a1);
+ free(buf1);
+ return err;
+}
+
static inline int test_run_parent(const struct test *t, int fdout[2],
int fderr[2], int fdmonitor[2], pid_t child)
{
pid_t pid;
int err;
- bool matchout;
+ bool matchout, match_modules;
/* Close write-fds */
if (t->output.out != NULL)
@@ -578,16 +756,21 @@
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/testsuite.h
^
|
@@ -95,6 +95,8 @@
*/
const struct keyval *files;
} output;
+ /* comma-separated list of loaded modules at the end of the test */
+ const char *modules_loaded;
testfunc func;
const char *config[_TC_LAST];
const char *path;
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/testsuite/uname.c
^
|
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
+#include <unistd.h>
#include "testsuite.h"
@@ -29,17 +30,10 @@
{
static void *nextlib = NULL;
static int (*nextlib_uname)(struct utsname *u);
- const char *release = getenv(S_TC_UNAME_R);
+ const char *release;
int err;
size_t sz;
- if (release == NULL) {
- fprintf(stderr, "TRAP uname(): missing export %s?\n",
- S_TC_UNAME_R);
- errno = EFAULT;
- return -1;
- }
-
if (nextlib == NULL) {
#ifdef RTLD_NEXT
nextlib = RTLD_NEXT;
@@ -53,6 +47,20 @@
if (err < 0)
return err;
+ if (!environ)
+ /*
+ * probably called from within glibc before main(); unsafe
+ * to call getenv()
+ */
+ return 0;
+
+ release = getenv(S_TC_UNAME_R);
+ if (release == NULL) {
+ fprintf(stderr, "TRAP uname(): missing export %s?\n",
+ S_TC_UNAME_R);
+ return 0;
+ }
+
sz = strlen(release) + 1;
if (sz > sizeof(u->release)) {
fprintf(stderr, "uname(): sizeof release (%s) "
|
[-]
[+]
|
Added |
_service:tar_git:kmod-17.tar.xz/kmod/tools/Makefile
^
|
@@ -0,0 +1,13 @@
+# Copyright 2010 Lennart Poettering
+#
+# This file has been copied from systemd. It is a dirty trick to simplify
+# compilation when CWD is not the root of the source tree. This file is not
+# intended to be distributed. So, don't touch it, even better ignore it!
+
+all:
+ $(MAKE) -C ..
+
+clean:
+ $(MAKE) -C .. clean
+
+.PHONY: all clean
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/tools/depmod.c
^
|
@@ -846,12 +846,9 @@
return err;
}
- if (S_ISREG(st.st_mode)) {
+ if (!S_ISDIR(st.st_mode)) {
cfg_files_insert_sorted(p_files, p_n_files, path, NULL);
return 0;
- } else if (!S_ISDIR(st.st_mode)) {
- ERR("unsupported file mode %s: %#x\n", path, st.st_mode);
- return -EINVAL;
}
d = opendir(path);
@@ -1156,10 +1153,10 @@
DBG("search %s\n", se->builtin ? "built-in" : se->path);
if (se->builtin)
bprio = i;
- else if (newlen >= se->len &&
+ else if (newlen > se->len && newpath[se->len] == '/' &&
memcmp(se->path, newpath, se->len) == 0)
newprio = i;
- else if (oldlen >= se->len &&
+ else if (oldlen > se->len && oldpath[se->len] == '/' &&
memcmp(se->path, oldpath, se->len) == 0)
oldprio = i;
}
@@ -1170,7 +1167,7 @@
oldprio = bprio;
DBG("priorities: built-in: %d, old: %d, new: %d\n",
- bprio, newprio, oldprio);
+ bprio, oldprio, newprio);
return newprio <= oldprio;
}
@@ -1955,8 +1952,6 @@
size_t i;
fputs("# Soft dependencies extracted from modules themselves.\n", out);
- fputs("# Copy, with a .conf extension, to /etc/modprobe.d to use "
- "it with modprobe.\n", out);
for (i = 0; i < depmod->modules.count; i++) {
const struct mod *mod = depmod->modules.array[i];
|
[-]
[+]
|
Changed |
_service:tar_git:kmod-17.tar.xz/kmod/tools/rmmod.c
^
|
@@ -40,7 +40,6 @@
{"syslog", no_argument, 0, 's'},
{"verbose", no_argument, 0, 'v'},
{"version", no_argument, 0, 'V'},
- {"wait", no_argument, 0, 'w'},
{"help", no_argument, 0, 'h'},
{NULL, 0, 0, 0}
};
|