Commit Graph

998 Commits

Author SHA1 Message Date
Randy Witt 1701b1b46f 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.
2012-03-17 03:34:08 -03:00
Randy Witt 00ff57663d 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.
2012-03-17 03:34:08 -03:00
Lucas De Marchi 436da1e96e 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.
2012-03-15 09:19:34 -03:00
Lucas De Marchi ae7ebe8770 modprobe: set log prio to 0 if user passed -q arg 2012-03-15 01:16:54 -03:00
Lucas De Marchi 23ea575014 Merge branch 'master' of git://code.falconindy.com/kmod 2012-03-15 00:31:22 -03:00
Lucas De Marchi c1b84540bb modprobe: always try to remove all modules in command line 2012-03-15 00:27:18 -03:00
Lucas De Marchi 4744ebcef4 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.
2012-03-15 00:14:35 -03:00
Dave Reisner f758caf57c 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:

* modprobe -r realmod_notloaded => exit zero
* modprobe -r --first-time realmod_notloaded => exit non-zero
* modprobe -r bogusmod => exit non-zero
2012-03-14 22:26:30 -04:00
Lucas De Marchi 26906fe73e kmod 6 2012-03-02 22:34:36 -03:00
Lucas De Marchi 49c6489d74 Use upper case after Deprecated in doc 2012-03-02 22:28:38 -03:00
Lucas De Marchi 6204d5b123 Add kmod_module_apply_filter() to doc-sections file 2012-03-02 22:18:33 -03:00
Lucas De Marchi bfcd31def9 Fix wrong printf format string
This fixes build in 32 bits machines.
2012-03-02 21:28:11 -03:00
Lucas De Marchi 2e2e252bd4 libkmod-index: do not pre-populate mmap
If we tell mmap to populate all the indexes and they are big, this will
impact load time. Let them be mapped as they are used.
2012-03-02 20:33:26 -03:00
Lucas De Marchi 9c5f057c7c Downgrade log message: refcnt file may not exist
If kernel doesn't have support to unload modules,
/sys/module/<modname>/refcnt will not exist and that's ok.

Reported by: Sven Anders <anders@anduras.de>
2012-03-01 14:04:29 -03:00
Lucas De Marchi dcf06c5306 man: detail modprobe.blacklist in kcmdline 2012-02-27 20:35:12 -03:00
Lucas De Marchi 817f4e33de libkmod-index: free node when we have only partial match 2012-02-27 19:54:33 -03:00
Dave Reisner aa5da52c3b modprobe: show builtin label on --show-depends
Previously, we didn't handle builtins very well, displaying things like:

$ modprobe -D btrfs
insmod /lib/modules/3.2.6-foo/kernel/crypto/crc32c.ko.gz
insmod (null)
insmod /lib/modules/3.2.6-foo/kernel/lib/libcrc32c.ko.gz
insmod /lib/modules/3.2.6-foo/kernel/lib/zlib_deflate/zlib_deflate.ko.gz
insmod /lib/modules/3.2.6-foo/kernel/fs/btrfs/btrfs.ko.gz

Follow module-init-tools and show builtins with the label 'builtin' and
their name:

$ modprobe -D btrfs
insmod /lib/modules/3.2.6-foo/kernel/crypto/crc32c.ko.gz
builtin intel_crc32c
insmod /lib/modules/3.2.6-foo/kernel/lib/libcrc32c.ko.gz
insmod /lib/modules/3.2.6-foo/kernel/lib/zlib_deflate/zlib_deflate.ko.gz
insmod /lib/modules/3.2.6-foo/kernel/fs/btrfs/btrfs.ko.gz
2012-02-27 18:49:36 -03:00
Lucas De Marchi ee1d188f70 libkmod-module: fill builtin's name
modules.builtin don't have any realname->value -- it follows the same
format of modules.dep, not the aliases ones.
2012-02-27 18:48:02 -03:00
Dave Reisner bdda7e14d8 find builtins by property, not initstate 2012-02-24 23:02:09 -05:00
Dave Reisner 3e4c6af6ad modinfo: use new apply_filter method to avoid builtins 2012-02-24 10:53:42 -05:00
Dave Reisner d80b103c63 libkmod/module: add kmod_module_apply_filter method
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.
2012-02-24 10:53:42 -05:00
Lucas De Marchi bb05bc8ac1 Move repository to kernel.org 2012-02-24 01:58:20 -02:00
Lucas De Marchi 7cd664fbae 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.
2012-02-23 16:47:33 -02:00
Lucas De Marchi 80e54cb675 TODO: update and organize items 2012-02-22 13:07:13 -02:00
Lucas De Marchi abd5557bd1 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:

install snd /sbin/modprobe --ignore-install snd && { /sbin/modprobe --quiet snd-ioctl32 ; /sbin/modprobe --quiet snd-seq ; }
install snd_rawmidi /sbin/modprobe --ignore-install snd-rawmidi && { /sbin/modprobe --quiet snd-seq-midi ; : ; }
install snd_emu10k1 /sbin/modprobe --ignore-install snd-emu10k1 && { /sbin/modprobe --quiet snd-emu10k1-synth ; : ; }
install snd_pcm modprobe --ignore-install snd-pcm $CMDLINE_OPTS && { modprobe --quiet snd-pcm-oss ; : ; }
install snd_mixer modprobe --ignore-install snd-mixer $CMDLINE_OPTS && { modprobe --quiet snd-mixer-oss ; : ; }
install snd_seq modprobe --ignore-install snd-seq $CMDLINE_OPTS && { modprobe --quiet snd-seq-midi ; modprobe --quiet snd-seq-oss ; : ; }
2012-02-22 13:06:56 -02:00
Lucas De Marchi 050db08c57 Add missing newlines
Checked with following semantic patch for the library:

// smpl
@a@
identifier virtual.func;
expression E1;
expression fmt;
position p1;
@@

func(E1, fmt@p1, ...)

@script:python b@
fmt << a.fmt;
p1 << a.p1;
@@

s = str(fmt)
if s.find("\\n") < 0:
	print p1[0].file + ":" + p1[0].line

// smpl

For tools, just remove E1
2012-02-18 03:56:21 -02:00
Lucas De Marchi adca3cd203 Downgrade log level when modules.dep{,.bin} don't exist 2012-02-17 05:00:09 -02:00
Lucas De Marchi 658e0471b3 testsuite: fix color of unexpected failure 2012-02-16 21:18:00 -02:00
Lucas De Marchi 3805274bf5 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().
2012-02-16 21:18:00 -02:00
Lucas De Marchi a7f5300d50 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.
2012-02-16 21:18:00 -02:00
Dave Reisner f31d49c8b3 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.
2012-02-16 16:52:38 -02:00
Wouter van Kesteren f6301b65bd Fix path.c's function pointer defenitions.
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
2012-02-16 14:37:32 -02:00
Lucas De Marchi 9207df753a TODO: add tasks and bug fixes 2012-02-14 21:57:35 -02:00
Lucas De Marchi 73298175ea libkmod-index: don't print an error if index doesn't exist
It's ok not to have the index files, so just print a DBG message instead
of an ERR.
2012-02-13 21:58:36 -02:00
Lucas De Marchi 8cd0f9e4f9 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.
2012-02-11 19:50:00 -02:00
Lucas De Marchi abb7e4706d test: remove test-state
This test is already covered by testsuite/test-loaded.
2012-02-09 01:44:09 -02:00
Lucas De Marchi 32d29b3523 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.
2012-02-08 20:32:31 -02:00
Lucas De Marchi d005aeb752 Check if libc has __xstat
uClibc doesn't use __xstat. Check if it exists, otherwise don't export
the override function.
2012-02-08 20:29:52 -02:00
Lucas De Marchi 995627d04e build-sys: add rule to pack rootfs 2012-02-08 02:04:10 -02:00
Lucas De Marchi 976ea8c3ae testsuite: add tests to modprobe --show-depends
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
2012-02-08 02:04:10 -02:00
Lucas De Marchi 4083b0997a testsuite: update README file
- Tell about TESTSUITE_MAIN and DEFINE_TEST macros
- Align item bodies and break on 80 chars
2012-02-07 11:00:41 -02:00
Lucas De Marchi c5d81989bc testsuite: macronify test definitions 2012-02-07 10:46:46 -02:00
Lucas De Marchi e9fa9de3c9 testsuite: macronify main function 2012-02-07 10:09:20 -02:00
Dan McGee d35e8832a6 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.
2012-02-07 10:08:58 -02:00
Lucas De Marchi 269de2e0bf libkmod-module: probe: Fix ignore-loaded flag not being applied 2012-02-07 09:48:59 -02:00
Lucas De Marchi e479598b7d kmod 5 2012-02-06 20:34:33 -02:00
Dan McGee a23f0c9c55 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()]
2012-02-06 20:29:08 -02:00
Lucas De Marchi 54c43dff1b Add WARNING file for test dir and improve testsuite README 2012-02-06 19:52:58 -02:00
Lucas De Marchi 23e354bfdf testsuite: add README 2012-02-06 16:50:54 -02:00
Lucas De Marchi 08600ee579 libkmod-module: probe: return -EEXIST if told to do so
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
2012-02-06 12:54:42 -02:00