Search modules.builtin file before saying the module was not found.
Note: these "modules" should not appear as dependencies of other modules
(in modules.dep) even if they appear in modinfo. This fixes the return
code of modprobe with builtin modules.
Also fixes a small coding style issue in module_is_inkernel().
When user tries to load a module that is builtin in kernel, modprobe
should just return 0. This is not happening right now, so mark test as
expected_fail until it gets fixed.
This allows us to prepend an arbitrary item to the PATH environment
variable, meaning we can favor the binaries we just built, rather than
relying on those in the filesystem.
int isn't big enough to hold a FILE* / DIR* on some systems, this causes
segfaults in calls that try to use the resulting FILE* / DIR*:
TESTSUITE: ERR: 'testsuite_rootfs_fopen' [1176160] terminated by signal 11 (Segmentation fault)
TESTSUITE: ERR: FAILED: testsuite_rootfs_fopen
FAIL: testsuite/test-testsuite
...
TESTSUITE: ERR: 'loaded_1' [1176166] terminated by signal 11 (Segmentation fault)
TESTSUITE: ERR: FAILED: loaded_1
FAIL: testsuite/test-loaded
...
TESTSUITE: ERR: 'from_alias' [1176181] terminated by signal 11 (Segmentation fault)
TESTSUITE: ERR: FAILED: from_alias
FAIL: testsuite/test-new-module
For reference on my system:
sizeof(int) = 4
sizeof(long) = 8
sizeof(FILE*) = 8
sizeof(DIR*) = 8
If a softdep depends on a module in the dependency list of the module
being inserted, we would enter and infinite loop.
Move the "mod->visited = true" assignment to the proper place, hoping it
didn't break other use cases. This is a bug that comes and goes every
now and then. Since we have a testsuite now, a test for this should be
written.
Functions that always call exit() should be marked with attribute
noreturn. With glibc this is not necessary, but it fails to compile with
uClibc otherwise.
test 1 - check whether modprobe outputs the right thing when
using --show-depends is used with already loaded modules.
test 2 - check whether modprobe outputs the right thing when
using --show-depends with modules not loaded yet
Ensure this dependency is explicit in the Makefile so rebuilding just
one test works correctly. Also reduce some repetition in the test LDADD
bits by adding a new TESTSUITE_LDADD variable.
A simple case of breakage before this commit:
$ touch aes
$ modinfo aes
filename: /tmp/aes
ERROR: could not get modinfo from 'aes': Invalid argument
Add a new is_module_filename() function that attempts to do more than
just check if the passed argument is a regular file. We look at the name
for a '.ko' string, and if that is found, ensure it is either at the end
of the string or followed by another '.' (for .gz and .xz modules, for
instance). We don't make this second option conditional on the way the
tools are built with compression support; the file is a module file
regardless and should always be treated that way.
When doing this, and noticed in the test suite output, we open the
system modules index unconditionally, even if it is never going to be
used during the modinfo call, which is the case when passing module
filenames directly. For only one module there's not much advantage in
pre-loading the index, so just remove the call to kmod_load_resources().
With-help-from: Dave Reisner <dreisner@archlinux.org>
[lucas.demarchi@profusion.mobi: remove call to kmod_load_resources()]
Commit "af9572c lib/module: check initstate before inserting module"
removed the check for "we should return -EEXIST" and moved it back to
the start of the function. The problem with this is the following
scenario:
- We check if module is in kernel -> no
- We insert the dependencies
<-- External program loads
the module
- We check if module is in kernel -> yes
- We return 0, when we should return -EEXIST
Add kmod-* prefixed tool names, add 'tags' in root directory (for ctags,
matches cscope.out ignore already in there), and prefix tools/ entries
with '/' so they are absolute ignores and don't apply to subdirectories.
Use a function to properly get an unsigned short from memory that is
possibly unaligned.
Note that it implicitly fixes a small bug in the hash function that
was introduced when modifying the eina code: the line "hash ^= key[2]
<< 18;" is supposed to be accessing the 3rd byte of the remainder of
the input, but when 'it' was introduced, 'key' ('data' in eina code)
was no longer incremented, so this ended up accessing the 3rd byte of
the input from the beginning. This is fixed by iterating over 'key',
like the eina code does.
Before this patch depmod was failing on ARMv5 and possibly others that
don't have unaligned access. They do not calculate correctly the
dependencies as shown below:
[root@alarm ~]# modinfo bridge
filename: /lib/modules/2.6.39.4/kernel/net/bridge/bridge.ko
version: 2.3
license: GPL
srcversion: 6B583530AE2B39C7E2317BF
depends: stp,llc
vermagic: 2.6.39.4 preempt mod_unload ARMv5
[root@alarm ~]# depmod
[root@alarm ~]# cat /lib/modules/2.6.39.4/modules.dep |grep bridge
kernel/net/bridge/bridge.ko:
[root@alarm ~]#
See how modinfo properly lists the dependencies, but modules.dep which
depmod generates does not contain them. As a result, most kernel
modules fail to load because their dependencies are not loaded by
modprobe.
- Gah, kmod insmod can't load from stdin anymore. :/
- What's the use case?
- zcat module.ko.gz | insmod - (but the new insmod apparently can load .gz fine)
- yes... just insmod module.ko.gz
- and actually insmod(8) says it works. :)
Not anymore...
fopen() will not reset errno if it succeeds so we should
make sure that we only use errno in error cases.
Also fix the diagnostic messages to not use strerror
when there is no error since strerror will not return
anything useful in this case
This applies to both the high level probe_insert_module() and the
underlying insert_module() functions. By checking module initstate prior
to inserting a module, we can avoid a lot of needless work just to find
out that the init_module call fails with EEXIST.
This implements a helper function, module_is_inkernel, to return a
boolean value describing if a module is live, coming, or builtin.
Just printing the errno string such as "%m\n" is not enough to help
debug or users understand the problem.
Change to provide more context on the failing operation.
Some messages may happen more than once in the same function and
discovering the line is hard. Now we print the actual log priority
that exposed the message as well as filename and line.
NOTE: We should consider printing the log priority in the non-debug
version as well.
Effectively catch and the zero and non-zero cases and error out
appropriately. Note that -EEXIST will only ever be returned when
KMOD_PROBE_STOP_ON_ALREADY_LOADED is set as a probe_insert_module flag.
Adds a bool to the test struct called 'expected_fail' which can be set
to flip the logic used to determine success and failure. Messaging is
also changed to reflect an unexpected pass or expected fail. This can be
used to write tests which may represent functionality desirable for a
future release.
We need a way to tell libkmod to ignore loaded modules, so modprobe can
tell it to dry-run and show dependencies. However there's a conflict
with two flags. KMOD_PROBE_STOP_ON_ALREADY_LOADED prevails if passed
together with KMOD_PROBE_IGNORE_LOADED.