Lucas De Marchi [Tue, 12 Jun 2012 04:43:46 +0000 (01:43 -0300)]
libkmod-config: refactor functions to get config
It makes more sense to have libkmod-config.c deal with the configuration
directly and the others get the config from ctx. As a bonus point we get
a smaller binary. Following numbers are for x86-64, libkmod + kmod:
Before:
text data bss dec hex filename
128840 1496 104 130440 1fd88 tools/modprobe
After:
text data bss dec hex filename
128392 1496 104 129992 1fbc8 tools/modprobe
Lucas De Marchi [Wed, 6 Jun 2012 04:44:23 +0000 (01:44 -0300)]
testsuite: add test for install-commands loop
This loop is similar to the one that comes with install rules of
alsa-utils package. It can be easily verified by reverting commit abd5557 and running the testsuite.
Lucas De Marchi [Wed, 6 Jun 2012 04:03:15 +0000 (01:03 -0300)]
testsuite: add timeout for each test
Each test must run under 2 seconds. Ideally they should run in much less
than this; just give an arbitrary number so we don't wait forever in
case we reached an infinite loop somewhere.
Lucas De Marchi [Thu, 24 May 2012 04:31:36 +0000 (01:31 -0300)]
testsuite: check if rootfs dir is dirty before running
Keep around a stamp-rootfs file that is generated together with the
rootfs. testsuite checks each test directory if its mtime is greater
than stamp's mtime, deciding if rootfs should be re-generated.
Mike Frysinger [Tue, 15 May 2012 22:29:44 +0000 (19:29 -0300)]
libkmod: move function to the only file using it
If we don't have --gc-sections support, linking kmod fails:
libkmod/.libs/libkmod-util.a(libkmod-util.o): In function 'underscores':
libkmod/libkmod-util.c:117: undefined reference to 'kmod_log'
This is because libkmod-util.la uses kmod_log(), that is in libkmod.la.
Move the function so we don't have a dependency loop while building the
libraries and it works with compilers with no support for --gc-sections.
Dan McGee [Thu, 23 Feb 2012 05:56:58 +0000 (23:56 -0600)]
test-conversion: convert test-blacklist to new infrastructure
Add a modprobe.conf with some blacklist entries in a test rootfs, and
then ensure our blacklist function actually cuts out the two listed
entries (and doesn't cut out the others).
Lucas De Marchi [Fri, 11 May 2012 03:04:59 +0000 (00:04 -0300)]
build-sys: copy rootfs to another directory
We can't use the rootfs directory because it breaks out-of-tree build
and in future we want to make modifications to the fake filesystem such
as adding and removing files.
We need to call "chmod -R +w" in the resulting directory because when we
distribute the source with make dist all files will be readonly.
Dan McGee [Fri, 3 Feb 2012 19:24:18 +0000 (13:24 -0600)]
testsuite: ship testsuite/rootfs unzipped
The current configuration is dumb in any number of ways:
1) If the rationale was for space savings, it works the opposite- the
git repo gets more bloated because we are adding binary compressed
blobs that share little in common with their parent, and anyone that
wants to run the test suite has to unzip it anyway.
2) It is a pain in the butt to add new tests, and not accidentally lose
any new rootfs you built in the directory.
3) `git status` won't help you if you are tweaking files in the rootfs
and don't know they have been changed, or if some test did that and
you couldn't detect it.
4) `git log` won't help you find out what is changing in the rootfs test
directory itself when changes are made to the binary blob, such as
new files being added or even existing files being tweaked.
5) The files just aren't that big anyway- 2.7MB unzipped.
Lucas De Marchi [Fri, 11 May 2012 00:11:27 +0000 (21:11 -0300)]
build: remove private symbol from linker script
There's no reason kmod_log should be exported, remove it from linker
script. This doesn't break the API/ABI because we are luck: since the
function had visibility=hidden it was not getting exported as a global
symbol.
Dave Reisner [Mon, 7 May 2012 23:41:42 +0000 (19:41 -0400)]
depmod: report failures in loading symbols
Previously, depmod would relegate failures of kmod_module_get_symbols()
to debug output, assuming the "error" was simply a lack of symbols.
Leave the ENOENT return to debug output, but report anything else as a
real error.
Dave Reisner [Mon, 7 May 2012 23:41:41 +0000 (19:41 -0400)]
libkmod-file: gracefully handle errors from zlib
zlib won't necessarily set the system errno, and this is particularly
evident on corrupted data (which results in a double free). Use zlib's
gzerror to detect the failure, returning a generic EINVAL when zlib
doesn't provide us with an errno.
Mike Frysinger [Sat, 21 Apr 2012 06:53:23 +0000 (02:53 -0400)]
libkmod: make sure to export kmod_log
If we don't have --gc-sections support, linking kmod fails:
libkmod/.libs/libkmod-util.a(libkmod-util.o): In function 'underscores':
libkmod/libkmod-util.c:117: undefined reference to 'kmod_log'
This is because kmod_log is missing the export define, even though it's
already listed in the exported symbol list.
Dave Reisner [Mon, 16 Apr 2012 14:37:32 +0000 (10:37 -0400)]
modprobe: handle -ENOENT return from init_module
init_module returns -ENOENT when the module failed to load because of a
bad parameter or unknown symbol. Throw a more descriptive error message
than the generic "No such file or directory" to alert the user.
Lucas De Marchi [Sat, 17 Mar 2012 18:12:44 +0000 (15:12 -0300)]
build-sys: don't set CFLAGS and LDFLAGS
These variables are supposed to be set by user. What we can do in
configure is to set another variable and AC_SUBST() it. Then in
Makefile.am we assign it to AM_{CFLAGS,LDFLAGS}. This way user can
always override their values, in configure or make phase.
Randy Witt [Fri, 16 Mar 2012 05:01:18 +0000 (01:01 -0400)]
configure.ac: Move link only flags out of CFLAGS and into LDFLAGS.
On the ARM gcc 4.2.2 I'm using I get many
"--as-needed: linker input file unused because linking not done"
style errors when libtool is using compile mode.
In order to silence these warnings and be "correct", the flags that
only make sense for linking were moved into LDFLAGS.
Randy Witt [Fri, 16 Mar 2012 05:01:17 +0000 (01:01 -0400)]
Add CC_CHECK_LDFLAGS_APPEND m4 macro.
This is mostly just preparation for the next patch. But this macro is
used for flags that are only needed during linking but that don't
make sense for normal compilation.
I saw this exact type of patch online for systemd, but it never seems to
have actually been incorporated into their attributes.m4.
Lucas De Marchi [Thu, 15 Mar 2012 12:19:34 +0000 (09:19 -0300)]
config: use order /etc, /run, /lib
This matches the change in systemd and udev. Log message on udev's
change by Kay Sievers:
After long consideration we came to the conclusion that user
configuration in /etc should always override the (generally
computer generated) configuration in /run. User configuration
should always be what matters over anything else. Hence rearrange
the search orders accordingly. In general this should change
very little as overriding like this is seldomn done so far,
and the order between /etc and /usr stays the same.
Lucas De Marchi [Thu, 15 Mar 2012 03:14:35 +0000 (00:14 -0300)]
modprobe: don't check if module builtin to decide if it's builtin
More or less confusing message, but if module is builtin in the live
system, it doesn't mean it's builtin in the target kernel.
Instead we now check if module has a path. It don't have a path only if
it's builtin in the target or if it doesn't exist at all. The latter
should not be a problem since this code is being called from inside the
library. Anyway, put an assert to make sure we get bug reports if any
case slipped in here.
Dave Reisner [Thu, 15 Mar 2012 02:15:21 +0000 (22:15 -0400)]
modprobe: fix error path in removing modules
We really haven't paid this code much attention, and it's somewhat
evident in our divergence in behavior from module-init-tools. This patch
asserts the following behavior on exit:
This is a more generic method of applying filters to module lists. This
deprecates kmod_module_get_filtered_blacklist() which now simply returns
a call to _apply_filter with the extra filter enum arg.
Lucas De Marchi [Thu, 23 Feb 2012 18:37:13 +0000 (16:37 -0200)]
libkmod-module: don't treat "coming" as in-kernel
Running two instances of modprobe with the same module should both
succeed or both fail:
modprobe foo&; modprobe foo;
Previously if foo failed to be inserted by the first call, the second one
could return 0 because it may have occurred while the first one was being
processed by kernel (thus marked as "coming").
Now we simply don't check by "coming" in order to decide if we need to
call init_module(). module-init-tools used to spin calling
usleep(100000), but calls to init_module() are already synchronous.
Therefore let kernel synchronize the calls.
Lucas De Marchi [Sun, 19 Feb 2012 06:20:30 +0000 (04:20 -0200)]
libkmod-module: probe: check if module exists for install cmds
Mimic what module-init-tools was doing before running install commands:
check if a module with the same name is already loaded in kerne, and if
it is, bail out.
This fixes the issue with some install commands used in Debian with
alsa-base package:
Lucas De Marchi [Thu, 16 Feb 2012 22:43:16 +0000 (20:43 -0200)]
kmod-module: lookup: search modules.builtin file too
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().
Lucas De Marchi [Thu, 16 Feb 2012 23:04:24 +0000 (21:04 -0200)]
testsuite: add test for builtins with modprobe
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.
Dave Reisner [Wed, 15 Feb 2012 02:49:26 +0000 (21:49 -0500)]
testsuite: add .path member to test struct
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.
Lucas De Marchi [Sat, 11 Feb 2012 21:45:29 +0000 (19:45 -0200)]
libkmod-module: probe: fix infinite loop with softdeps
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.
Lucas De Marchi [Wed, 8 Feb 2012 22:32:31 +0000 (20:32 -0200)]
Mark functions with attribute noreturn
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.
Dan McGee [Sat, 4 Feb 2012 02:29:09 +0000 (20:29 -0600)]
testsuite: libtestsuite depends on individual components
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.
Dan McGee [Sat, 4 Feb 2012 02:25:00 +0000 (20:25 -0600)]
modinfo: handle arguments more carefully
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()]