Commit Graph

927 Commits

Author SHA1 Message Date
W. Trevor King 075f4ea0e2 python: Add missing copyright blurbs. 2014-03-25 00:34:15 -03:00
W. Trevor King c737198936 python: Add docstrings to kmod.kmod and kmod.kmod.Kmod. 2014-03-25 00:34:15 -03:00
W. Trevor King 3cc8a66078 python: MANIFEST.in: add missing source to the sdist tarball. 2014-03-25 00:34:15 -03:00
W. Trevor King 113b46bc1e python: Add additional out Module attributes (path, refcnt, ...). 2014-03-25 00:34:15 -03:00
W. Trevor King f7c62154ec python: Convert to Cython.
With Cython we get easier memory handling and Python 3 compatibility.
2014-03-25 00:34:15 -03:00
Andy Grover cd4df5accd python: update FSF address in COPYING and COPYING.LESSER
Please FSF, never move again.
2014-03-25 00:34:15 -03:00
Andy Grover 6cdc22b36b python: whitespace 2014-03-25 00:34:15 -03:00
Andy Grover 705187f17b python: add proper error handling to loaded_modules()
We need to check the result of basically all Py* calls and cleanup
properly if they fail.
2014-03-25 00:34:14 -03:00
Andy Grover 31aa6834ba python: Improve README's description of kmod
Based on text from kmod's README.
2014-03-25 00:34:14 -03:00
Andy Grover c73ffc51e5 python: Make setup.py version match version in .c 2014-03-25 00:34:14 -03:00
Andy Grover 3aa27ba988 python: Add README 2014-03-25 00:34:14 -03:00
Andy Grover 8a4d09336e python: More cleanup and renaming of stuff. Add docstrings. 2014-03-25 00:34:14 -03:00
Andy Grover 1e688f86a7 python: Add support for listing loaded modules, modprobe, rmmod
And other misc. cleanups and changes.
2014-03-25 00:34:14 -03:00
Andy Grover d2042ca0c7 python: use c99 init for struct init
move casts of pyobject -> kmodobject to the functions from the struct
init.
2014-03-25 00:34:14 -03:00
Andy Grover a942131e7b python: a skeleton that compiles 2014-03-25 00:34:14 -03:00
Andy Grover cc688e6722 python: initial checkin 2014-03-25 00:34:14 -03:00
Lucas De Marchi db62153ea0 build-sys: try harder to shut up compiler wrt strict-aliasing
With -Wstrict-aliasing=2 we get the following warning:

	libkmod/libkmod-signature.c:124:20: note: in expansion of macro 'get_unaligned'
	  sig_len = be32toh(get_unaligned(&modsig->sig_len));

However there's nothing wrong with it. modsig->sig_len is uint32_t and
get_unaligned in this case returns uint32_t. There's notstrict aliasing
violation.
2014-03-24 23:50:24 -03:00
Lucas De Marchi f87dc57a71 libkmod: Fix unaligned access
From Jan Engelhardt:

	Program received signal SIGBUS, Bus error.
	[Switching to process 11100]
	0x00035278 in kmod_module_signature_info (file=0x4eeb8, sig_info=0xffffc254)
	    at libkmod/libkmod-signature.c:124
	124             sig_len = be32toh(modsig->sig_len);
	(gdb) p modsig
	$1 = (const struct module_signature *) 0xf7dfe143

modsig->sig_len can be unaligned if modsig is unaligned, so the padding
in the struct has no effect since we are mapping it to the mem buffer.
2014-03-24 23:47:31 -03:00
Lucas De Marchi 6d59d9d086 build-sys: Remove -Werror from CFLAGS
Just let the warnings be emmited, but don't fail on them.
2014-03-24 14:54:01 -03:00
Lucas De Marchi aa72284f83 build-sys: Remove bogus line causing warning
./configure: line 14316: xyes: command not found

We are not using have_manpages, so remove it.
2014-03-24 14:53:56 -03:00
Lucas De Marchi ad7f1757c0 Add test for depmod using search dirs with same prefix
Test depmod with search dirs "foo" and "foobar". Previously to 49b33c1
("depmod: do not allow partial matches with "search" directive") we were
failing this test due to matching the prefix without checking if
it's the full dir name.

We are adding 2 tests here in order to catch the case we only pass the
test due to processing the directories in a favourable order.
2014-03-19 09:22:20 -03:00
Anssi Hannula 49b33c1f21 depmod: do not allow partial matches with "search" directive
Currently e.g. "search foo foobar built-in" will cause unpredictable
results if baz.ko is in both foo/ and foobar/, since "foo" in search may
match both of those directories and the preferred module therefore
depends on processing order.

Fix the code to ensure that the match is performed on full pathname
components only.
2014-03-19 09:18:39 -03:00
Lucas De Marchi aa0abec721 Add test for simple search order in depmod 2014-03-19 08:52:33 -03:00
Anssi Hannula 27881f6fbc depmod: fix debug print parameter order 2014-03-19 07:04:24 -03:00
Lucas De Marchi fea655dcb3 libkmod-elf: Fix check by class in get_modversions()
Commit 51c409b ("Cache the offset of crc") unintentinally changed the
comparison "if (elf->class & KMOD_ELF_32)" to
"if (elf->class == KMOD_ELF_32)".

This has been reported by Serge Voilokov <serge0x76@gmail.com>:

	On Raspberry PI elf->class equals KMOD_ELF_32|KMOD_ELF_LSB so
	valid condition should be (elf->class & KMOD_ELF_32) instead of
	(elf->class == KMOD_ELF_32).

This fixes "modprobe --dump-modversions" failing on 32b systems.
2014-03-07 01:24:39 -03:00
Michal Marek 632fb7b463 testsuite: Fix uname() during glibc startup
In a specific configuration (chroot with the linux32 personality), the
modprobe_install_cmd_loop test failed, because the bash process handling
the install command segfaulted. The backtrace showed a uname() call
during libpthread initialization, at which point the environ pointer
hadn't been initialized yet:

	Program terminated with signal SIGSEGV, Segmentation fault.
	#0  0x080c1591 in getenv (name=<optimized out>,
	    name@entry=0xf775f850 "TESTSUITE_UNAME_R") at getenv.c:81
	81	      for (i = 0, len = strlen (name); environ[i]; i++)
	(gdb) bt
	#0  0x080c1591 in getenv (name=<optimized out>,
	    name@entry=0xf775f850 "TESTSUITE_UNAME_R") at getenv.c:81
	#1  0xf775f754 in uname (u=u@entry=0xff946350) at testsuite/uname.c:32
	#2  0xf74ffc6c in is_smp_system ()
	    at ../nptl/sysdeps/unix/sysv/linux/i386/smp.h:39
	#3  __pthread_initialize_minimal_internal () at nptl-init.c:460
	#4  0xf74fe32c in _init () at ../sysdeps/i386/crti.S:74
	#5  0x00000000 in ?? ()
	(gdb) p environ
	$1 = (char **) 0x0

I don't know why it only happend in the chroot, but glibc can call its
own functions and impose any restrictions before main() is started, so
we have to adapt.

Also, do not return error if there is an environment, but the
environment variable is not found. If uname() is called by kmod, then
the respective test will simply fail later. If it's something else
calling uname(), then we do not want to disturb the program.
2014-03-06 23:09:56 -03:00
Lucas De Marchi 3be5bf4646 man: use systemd as example instead of udev
Nowadays udev doesn't create nodes in /dev anymore. This role is rather
taken by systemd-tmpfiles on early boot so reference it generically as
systemd.
2014-03-06 02:47:05 -03:00
Lucas De Marchi eb18b26905 man: clarify the support to modules.dep file 2014-03-06 02:46:27 -03:00
Lucas De Marchi bccb4b2545 build-sys: Do not require xsltproc for installation of man pages
Same reason as found in this commit to systemd:

	commit 4ca39b280fce3c60d2fdecbd478fd9bf7f9d3e64
	Author: Mike Gilbert <floppym@gentoo.org>
	Date:   Sun Feb 23 11:21:13 2014 -0500

	    configure: Do not require xsltproc for installation of man pages

	    The release tarballs ship with pre-generated man pages, so we do not
	    need xsltproc for a typical end-user build.

	    Developers will probably have xsltproc anyway, but if not they will now
	    encounter a build-time failure instead of an error in configure.
2014-03-06 02:07:20 -03:00
Lucas De Marchi 06eb29e117 build-sys: add small redirecting Makefiles
These redirecting makefiles simplifies compiling from some editors and
when CWD is not the root of the source tree. This is similar to what was
introduced in systemd in 340d89e ("build-sys: add small redirecting
Makefiles to simplify compilation from within emacs")
2014-03-06 01:59:58 -03:00
Lucas De Marchi 49776627e6 testsuite: add test for '.' correctly parsed in param's value
In kcmdline it's possible to have a dot in the param's value. The
support for this was added in 66f3228 ("libkmod: Add support for '.' in
module parameter on kcmdline") and is needed to correctly support some
modules that depend on it.

This test was added in order to make sure the commit  aa87854
("libkmod-config: Only match dot before '=' in /proc/cmdline") didn't
break it. Although that commit  message says it's allowing to match a
dot before '=' it's actually enforcing the first part of the string to
be always in the format "<module-name>.param". Dots after '=' are still
correctly allowed.
2014-03-06 01:36:02 -03:00
Lucas De Marchi 4214902482 testsuite: add test to ignore unrelated strings in kcmdline
Strings unrelated to modules and modprobe should be ignored and not
appear in the output of "modprobe -c".

This adds a test for the fix provided in aa87854 ("libkmod-config: Only
match dot before '=' in /proc/cmdline").
2014-03-06 01:30:56 -03:00
Lucas De Marchi bad84a9e6e testsuite: give a more suitable description to test
We are not only checking if those options are correctly parsed from
kcmdline, but if in fact they are being passed to the final
(f)init_module call. This is why we use 'modprobe --show-depends'
instead of the simpler 'modprobe -c'.
2014-03-06 01:30:08 -03:00
Lucas De Marchi 55bcc4a5bd testsuite: add test for kcmdline params with no value
Use "modprobe -c" to dump the configuration. Since we configure our
rootfs to have only a /proc/cmdline file, this should dump the knowledge
we have from its parsed content.

Test if <module>.option, without any value is correctly parsed, as fixed
in commit 493dc65 ("libkmod: Fix getting param with no value from kcmdline")
2014-03-06 01:29:41 -03:00
Michal Marek aa878540e6 libkmod-config: Only match dot before '=' in /proc/cmdline
Otherwise, we also parse strings like

  BOOT_IMAGE=/boot/vmlinuz-3.12.12-57.g5f654cf-default

In practice, this is not a problem, because there is no module named
BOOT_IMAGE=/boot/vmlinuz-3. It just disturbs in modprobe -c output.
2014-03-05 12:30:52 -03:00
Michal Marek 519d27de5a libkmod-config,depmod: Accept special files as configuration files, too
If we can open it and read it, it's good enough for us. Otherwise, we
cannot use -C /dev/null to skip the system configuration for instance:

$ ./tools/modprobe -C /dev/null -c
libkmod: ERROR libkmod/libkmod-config.c:821 conf_files_list: unsupported
file mode /dev/null: 0x21b6
...
2014-03-05 12:27:24 -03:00
Michal Marek c2f4d85a9a libkmod-module: Simplify kmod_module_insert_module()
Store the file and elf pointer in the kmod_module structure and have it
freed together with the module.
2014-03-05 12:22:37 -03:00
Michal Marek be29c40e25 Add some tests for kernels without finit_module(2) 2014-03-05 12:22:37 -03:00
Michal Marek 063086e038 testsuite: Do not provide finit_module(2) on older kernels
If the test's uname -r is less that 3.8, return -ENOSYS from
finit_module(), so that the fallback is tested.
2014-03-05 12:22:37 -03:00
Michal Marek 2ce5de0ae6 testsuite: Add test for modprobe --force
There is no check if the correct flags are passed to finit_module, but
at least we cover the respective code path in kmod.
2014-03-05 12:22:37 -03:00
Michal Marek 88ac40840f testsuite: Check the list of loaded modules after a test
Add a ->modules_loaded member to struct test, which is a comma-separated
list of modules that should be present after the test finishes. Both
missing and excess modules cause an error.
2014-03-05 12:22:37 -03:00
Stephen Kitt a4bd1441e5 Remove "rmmod -w" documentation and getopt entry
This patch removes the cmdopts declaration and the documentation. They
were leftover from the -w removal.
2014-01-26 18:00:23 -02:00
Lukas Berk 3d51a2f6ef man: insmod documentation fix
Add comma between lsmod(8) and modinfo(8)

Signed-off-by: Lukas Berk <lberk@redhat.com>
2014-01-24 10:23:30 -02:00
Lucas De Marchi 366e2ed791 Remove duplicate includes
Found by
https://raw.github.com/karelzak/util-linux/master/tools/checkincludes.pl
2014-01-21 14:03:02 -02:00
Lucas De Marchi 2726da5768 man: Change my contact email address 2014-01-02 17:13:38 -02:00
Lucas De Marchi 36c4bb928a kmod 16 2013-12-22 19:45:19 -02:00
Lucas De Marchi d96ca9c429 Use C11's noreturn
Also define noreturn w/o <stdnoreturn.h> and move it to macro.h instead
of in the testsuite.

Based on similar commit on systemd by Shawn Landden
<shawn@churchofgit.com>.
2013-12-17 19:10:16 -02:00
Lucas De Marchi 9f02561d84 module: use _cleanup_free and remove useless call to free() 2013-11-18 11:56:57 -02:00
Lucas De Marchi d3c16c7946 file: use _cleanup_free_ 2013-11-18 11:43:10 -02:00
Lucas De Marchi cacbcc4215 array: avoid duplicate code to reallocate 2013-11-18 11:29:11 -02:00