Commit Graph

1008 Commits

Author SHA1 Message Date
Lucas De Marchi 1a07559af3 Clarify what licences apply where
This doesn't change any license, just clarifies what's licensed under
LGPL and what's under GPL.
2014-10-09 01:26:34 -03:00
Lucas De Marchi aafd38359a Rename getline_wrapped() to freadline_wrapped() 2014-10-03 03:25:06 -03:00
Lucas De Marchi b18979b770 Prefer inttypes.h over stdint.h 2014-10-03 02:03:55 -03:00
Lucas De Marchi c2e4286bb9 Reorder and reorganize header files
Let the includes in the following order:

< system headers >
< libkmod >
< tool >
< local headers >
2014-10-03 01:43:15 -03:00
Lucas De Marchi 0db718edcf Move hash implementation to shared directory 2014-10-03 00:40:11 -03:00
Lucas De Marchi 74d1df6682 Move array implementation to shared directory 2014-10-03 00:33:25 -03:00
Lucas De Marchi 8eded79c50 build-sys: normalize line breaks
Break lines earlier, as it's already done in some places and use only 1
tab to avoid reaching the column limit.
2014-10-03 00:33:25 -03:00
Lucas De Marchi 96573a0220 Move generic util functions to shared directory 2014-10-03 00:33:25 -03:00
Lucas De Marchi 8b7189bc25 Move missing.h to shared directory 2014-10-03 00:31:10 -03:00
Lucas De Marchi 576dd4393d Move macro.h to shared directory
It's not really related to libkmod, so move it to a directory in which
we keep common stuff.
2014-10-02 22:03:19 -03:00
Randy MacLeod 9b34db1ae6 Add back-up implementation of be32toh()
Older systems may not have the be32toh function defined. Check for this
and fall back to checking the endianness and calling bswap_32 directly
if needed.  This works on both old and new systems.

[Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>:
address comments raised by Lucas De Marchi [1], update commit message]
[1] http://www.spinics.net/lists/linux-modules/msg01129.html
2014-09-29 17:13:26 -03:00
Lucas De Marchi 419b7003af Update TODO 2014-09-23 00:21:53 -03:00
Marco d'Itri 66f4f6804c Add the man page for kmod(8) 2014-09-22 08:52:47 -03:00
Marco d'Itri fde693c94f Document depmod --show in depmod(8) 2014-09-20 11:23:56 -03:00
Holger Obermaier 1a4aa7e2cb libkmod-index.c: Fix error message 2014-09-04 16:29:47 -03:00
Cristian Rodríguez 74c26943f1 Add missing O_CLOEXEC in kmod_module_get_size() 2014-06-19 18:01:37 -03:00
Lucas De Marchi ae58de0fcb kmod 18 2014-06-14 12:46:38 -03:00
Lucas De Marchi a5a41f8dbb testsuite: Fix macro missing format string 2014-06-14 11:14:58 -03:00
Lucas De Marchi 5963c36da3 testsuite: Add basic tests for hash implementation
Far from complete, but already covers all internal APIs.
2014-06-06 02:24:39 -03:00
Lucas De Marchi 30471c80a4 testsuite: Add assert_return
Add assert_return to use in testcases instead of assert. The issues
with assert are:
	1) It's disabled when NDEBUG is defined
	2) Even if it's well supported by testsuite (the parent will
	   report the child died) it can't output any meaningful
	   error message
2014-06-06 02:19:28 -03:00
Lucas De Marchi f988e25c68 testsuite: separate testcases on log 2014-06-05 17:54:41 -03:00
Lucas De Marchi 7a2d0e6187 testsuite: check for correct error message in detect-loop 2014-05-30 10:26:17 -03:00
Lucas De Marchi d7293a1628 testsuite: Fix expected_fail parsing
If a test has expected_fail=true, it means the return code must be
different from 0 *and* the outputs must match. This way it's possible to
check if the error messages are printed as they should.
2014-05-30 10:23:05 -03:00
Lucas De Marchi f429113a47 testsuite: Add braces 2014-05-30 10:20:19 -03:00
Lucas De Marchi c89d219884 depmod: Add better error messages when facing loops
Since now depmod fails when there are module loops, let's at least give
better error messages, printing the loops we found. Since we may have
more than 1 loop, just printing the modules that are in loop is not
very clear.

Assuming as an example 2 independent loops, this is how the new messages
compare to the old ones:

Before:
	depmod: ERROR: Found 5 modules in dependency cycles!
	depmod: ERROR: /tmp/test-kmod//lib/modules/3.14.4-1-ARCH/kernel/moduleE.ko in dependency cycle!
	depmod: ERROR: /tmp/test-kmod//lib/modules/3.14.4-1-ARCH/kernel/moduleB.ko in dependency cycle!
	depmod: ERROR: /tmp/test-kmod//lib/modules/3.14.4-1-ARCH/kernel/moduleC.ko in dependency cycle!
	depmod: ERROR: /tmp/test-kmod//lib/modules/3.14.4-1-ARCH/kernel/moduleD.ko in dependency cycle!
	depmod: ERROR: /tmp/test-kmod//lib/modules/3.14.4-1-ARCH/kernel/moduleA.ko in dependency cycle!

After:
	depmod: ERROR: Found 5 modules in dependency cycles!
	depmod: ERROR: Cycle detected: moduleE -> moduleD -> moduleE
	depmod: ERROR: Cycle detected: moduleB -> moduleC -> moduleA -> moduleB
2014-05-30 09:43:30 -03:00
Lucas De Marchi 8183cfa9da testsuite: add test to fail depmod on module loops 2014-05-30 09:36:56 -03:00
Lucas De Marchi a873f2350f depmod: Rename variable to clarify its meaning
In mod->modnamelen we were actually including the '\0', i.e.
strlen(modname) + 1. So rename it to modnamesz and add a comment in
depmod_module_is_higher_priority() to notice why it's correct since the
new one is really using strlen(modname).
2014-05-30 09:03:33 -03:00
Lukas Anzinger 86e19e9acd Fix use-after-free in hash implementation.
If a value is added to the hash under a key that already exists the new value
replaces the old value for that key. Since key can be a pointer to data that
is part of value and freed by hash->free_value(), the key must be also
replaced and not only the value. Otherwise key potentially points to freed data.
2014-05-18 16:04:50 -03:00
Leandro Pereira 30bfd48aef Close /sys/module/$NAME directory if opening /proc/module fails. 2014-05-14 20:24:19 -03:00
Leandro Pereira c1bc88c98e Free abspath if kmod_module_new_from_path() fails. 2014-05-14 20:21:20 -03:00
Leandro Pereira e84d912bd7 Free realnames if kmod_lookup_alias_from_alias_bin() fails 2014-05-14 20:19:52 -03:00
Leandro Pereira b6d985c61a Ensure read_long() reads the correct number of bytes from the index 2014-05-14 20:18:00 -03:00
Leandro Pereira d36c886aed Bail out of index_mm_open() if fstat() fails 2014-05-14 20:17:30 -03:00
Lucas De Marchi c48b269d64 depmod: Make dependency loops be fatal
Since the beginning depmod just warned about dependency loops and upon
creation of modules.dep{,.bin} it skipped the modules that were part of
a loop. However just skipping the modules may come as a surprise to
kernel module developers: they will need to try to load the module (or
to pay attention to the log messages) to notice thavt the module has not
been put in the index. Also, differently from module-init-tools we were
not skipping modules that depend on modules with dependency loops,
leading to a segfault in depmod.

So this is a summary of the change in behavior with this patch:

Loop 1)
    A -> B -> C -
    ^           |
    '------------

    Before:
        depmod: WARNING: found 3 modules in dependency cycles!
        depmod: WARNING: /tmp/test-kmod/lib/modules/3.14.2-1-ARCH/kernel/moduleB.ko in dependency cycle!
        depmod: WARNING: /tmp/test-kmod/lib/modules/3.14.2-1-ARCH/kernel/moduleC.ko in dependency cycle!
        depmod: WARNING: /tmp/test-kmod/lib/modules/3.14.2-1-ARCH/kernel/moduleA.ko in dependency cycle!

        return code: 0

    After:
        depmod: ERROR: Found 3 modules in dependency cycles!
        depmod: ERROR: /tmp/test-kmod/lib/modules/3.14.2-1-ARCH/kernel/moduleB.ko in dependency cycle!
        depmod: ERROR: /tmp/test-kmod/lib/modules/3.14.2-1-ARCH/kernel/moduleC.ko in dependency cycle!
        depmod: ERROR: /tmp/test-kmod/lib/modules/3.14.2-1-ARCH/kernel/moduleA.ko in dependency cycle!

        return code: 2

Loop 2)
    A -> B -> C -
         ^      |
         '-------

    Before:
        depmod: WARNING: found 2 modules in dependency cycles!
        depmod: WARNING: /tmp/test-kmod//lib/modules/3.14.2-1-ARCH/kernel/moduleB.ko in dependency cycle!
        depmod: WARNING: /tmp/test-kmod//lib/modules/3.14.2-1-ARCH/kernel/moduleC.ko in dependency cycle!
        Segmentation fault (core dumped)

    After:
        depmod: ERROR: Found 2 modules in dependency cycles!
        depmod: ERROR: /tmp/test-kmod/lib/modules/3.14.2-1-ARCH/kernel/moduleB.ko in dependency cycle!
        depmod: ERROR: /tmp/test-kmod/lib/modules/3.14.2-1-ARCH/kernel/moduleC.ko in dependency cycle!

        return code: 2

The segfault above could be fixed, but let's just fail everything
because dependency cycles should be fixed in the modules rather than
just be skipped in the index.
2014-05-14 20:05:12 -03:00
Joe Lawrence 445e51c57d man: fixup spacing/parens in modprobe.d(5) 2014-05-13 14:45:15 -03:00
Lucas De Marchi b8b990f47d Add gitignore to module playground 2014-05-09 08:43:32 -03:00
Marco d'Itri 1008a2d5ba Remove references to systemd from the bash completion file
And restore the original LGPL disclaimer text.
2014-05-05 01:52:04 -03:00
Lucas De Marchi 3f8dd30a76 testsuite: Add module playground dir 2014-05-02 12:57:17 -03:00
Lucas De Marchi f5cdd574a5 Make sure there's NUL byte at the end of strndupa
Since strcpy() doesn't ensure we have a NUL byte in the resulting
string, use alloca() + memcpy(). Also make sure we don't evaluate "s"
twice.
2014-04-07 12:30:04 -03:00
Lucas De Marchi 04c0956e20 Add strndupa to missing.h 2014-04-07 11:00:24 -03:00
Lucas De Marchi 29bc329f55 Update .travis.yml
- Add cython to the dependencies, so it can compile the python bindings
 - Remove unecessary -Wno-error since now we don't use -Werror anymore.
2014-04-07 10:55:47 -03:00
Lucas De Marchi 49d8e0b590 kmod 17 2014-04-06 17:52:44 -03:00
Lucas De Marchi 3e68b2c455 testsuite: Remove duplicate test
This partially reverts ad7f175 ("Add test for depmod using search dirs
with same prefix"). Testing it twice in the inverted order doesn't
ensure we get the bug with wrong ordering.

As put by Anssi Hannula <anssi@mageia.org>:

	So the bug is triggered only if the shorter name is higher-prio _and_
	shorter name is traversed first. If the long name is traversed first,
	the bug don't trigger with either "search" directive order (and on my
	"make check" runs this is the case).
2014-04-06 17:46:45 -03:00
Lucas De Marchi 6ca7c0926f build-sys: enable python in bootstrap-configure 2014-04-06 17:14:23 -03:00
Michal Marek 9324bb52f3 testsuite: Warn if sysconfdir is not /etc 2014-04-04 13:06:05 +02:00
Michal Marek 81bf88d6c4 testsuite: Do not run tests with *.ko.gz if zlib is not enabled 2014-04-04 13:05:49 +02:00
Michal Marek 73476ec5cb testsuite: Uncompress most modules
Only keep test-depmod/modules-order-compressed to test compressed module
support.
2014-04-04 12:32:16 +02:00
Tom Gundersen 8240333b25 config: also parse softdeps from modules
This information can be found in /lib/modules/`uname -r`/modules.softdep, and
has only recently been exported by the kernel.

Also remove the advice about copying modules.softdep to /lib/modules as it is
not clear how to do this correctly with several kernels installed with
potentially conflicting soft dependencies.
2014-04-01 08:13:54 -03:00
Michal Marek 450bd1b429 libkmod: Ignore errors from softdeps
Before we had softdeps, the usual idiom was

install foo /sbin/modprobe bar; /sbin/modprobe --ignore-install foo

ignoring errors from the first modprobe invocation. This also matches
the behavior of module-init-tools' implementation of softdep.
2014-04-01 07:40:37 -03:00
Lucas De Marchi 3a33a7a566 build-sys: add hooks to build python bindings
Add --enable-python configure switch so we build the python bindings. We
also pass version.py through SED_PROCESS macro, so the version is kept
in sync with kmod.

Acked-by: Andy Grover <agrover@redhat.com>
2014-03-26 22:30:56 -03:00