Commit Graph

277 Commits

Author SHA1 Message Date
Lucas De Marchi c5db1a3fd2 depmod: don't return error if modules.builtin don't exist 2012-06-15 02:42:25 -03:00
Lucas De Marchi ccd6afa4f2 Remove ifdef for building tools not bundled
Current build system do not support to build separate tools anymore, so
just remove the ifdefs.
2012-06-15 00:40:14 -03:00
Lucas De Marchi ac78e109c3 tools: rename source files
There's no point anymore in having "kmod-" prefix. This is a historical
thing when we started implementation of these tools.
2012-06-14 16:29:28 -03:00
Dave Reisner 819f79a24d 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.
2012-05-08 10:22:14 -03:00
Lucas De Marchi 20c6e18c37 Return error instead of always 0 2012-04-26 11:40:26 -03:00
Lucas De Marchi 18a492e6f7 Remove dead assignment 2012-04-26 11:39:54 -03:00
Dave Reisner ccb64d1ead 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.

Fixes Debian bug 668216.
2012-04-16 10:37:32 -04:00
Elan Ruusamäe 02629fa02e modprobe: fix typo in config dump: option->options
kmod uses "option MODNAME", not "options MODNAME"

	--- modprobe-sorted.kmod	2012-03-21 22:31:03.751754042 +0200
	+++ modprobe-sorted.module-init-tools	2012-03-21 22:30:49.561753089 +0200
	@@ -1,6 +1,23 @@
	[...]
	-option uvesafb mode_option=1024x786-32 mtrr=4 scroll=ywrap
	+options uvesafb mode_option=1024x786-32 mtrr=4 scroll=ywrap

This breaks scripts that depend in modprobe -c output grepping
2012-03-22 12:00:16 -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
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
Dave Reisner 3e4c6af6ad modinfo: use new apply_filter method to avoid builtins 2012-02-24 10:53:42 -05: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 814a57babf libkmod-module: probe: rename flag to be more meaningful 2012-02-06 12:46:39 -02:00
Dan McGee 2ec79834a3 Update .gitignore files
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.
2012-02-05 02:15:20 -02:00
Khem Raj 035cbdc763 depmod: Dont use errno unconditionally
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
2012-02-03 14:52:59 -02:00
Dave Reisner 1505ee9793 modprobe: avoid breaking on insertion failure 2012-02-03 09:10:13 -05:00
Dave Reisner 297a3182e4 modprobe: properly handle errors from init_module
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.
2012-01-31 14:08:57 -02:00
Dave Reisner 69a1974347 modprobe: post-remove module deps with 0 refcnt
This commit looks shockingly similar to 0e9bd2d1 because SOMEONE decided
to remove it in a872bba in a glorious frenzy of refactoring.
2012-01-31 14:08:57 -02:00
Lucas De Marchi 2e9dcd742e kmod-modprobe: migrate to kmod_module_probe_insert_module() 2012-01-31 14:08:57 -02:00
Lucas De Marchi 28f32c65ca modprobe: print end of configuration files 2012-01-27 23:56:46 -02:00
Lucas De Marchi 3ef848b28b modprobe: fix build 'cause of excessive number of arguments 2012-01-26 16:03:47 -02:00
Dave Reisner cc98830ca4 modprobe: remove code referring to -t, --type
This was only useful with the --list function, which isn't implemented.
2012-01-26 15:07:09 -02:00
Lucas De Marchi fe8b0671a0 build-sys: do not create symlinks by default
Distro packagers should create them instead. It's too much trouble to
create them in the build system and every distro wants a different path
for them.
2012-01-21 18:01:00 -02:00
Lucas De Marchi 569f1609bd modprobe: kill operations depending on path
It was not on module-init-tools and it doesn't make much sense. It will
deal with dependencies, but looking at modules in the index. This might
not be the module we want if we are loading another from outside of the
tree.

Dealing with paths causes this bug (supposing there's a module names
squashfs):

	# cd /
	# touch squashfs
	# modprobe squashfs

That is because it detects that squashfs exists as a file and it will
try to load it instead of the alias "squashfs".

If you need to load a module from a path, use insmod.

Thanks to Silvan Calarco <silvan.calarco@mambasoft.it> who reported the
bug and helped debugging it.
2012-01-21 02:47:08 -02:00
Lucas De Marchi 411d83c41e Add program to calculate the shortest relative path for symlinks 2012-01-18 19:48:16 -02:00
Thierry Vignaud eff917c0d2 WEXITSTATUS is defined in sys/wait.h
Fix compiling with dietlibc:

../libkmod/libkmod-module.c:858:2: warning: implicit declaration of function 'WEXITSTATUS' [-Wimplicit-function-declaration]
../libkmod/libkmod-module.c:858:2: warning: nested extern declaration of 'WEXITSTATUS' [-Wnested-externs]
(...)
kmod-modprobe.c:(.text.command_do+0x157): undefined reference to `WEXITSTATUS'
2012-01-17 17:33:07 -02:00
Lucas De Marchi 09e9ae58b6 modprobe: flush stdout before dumping indexes
Index dump doesn't use stdio.h function and instead call write()
directly on STDOUT_FILENO file descriptor. Therefore we need to flush
stdio buffers before calling it, to be sure the configuration dump will
appear before index's.
2012-01-17 10:11:03 -02:00
Lucas De Marchi b8542a82b7 Fix common misspelling with codespell
-------8<-------
SUMMARY:
ommitted      1
2012-01-16 23:03:33 -02:00
Lucas De Marchi 49a163759d modprobe: dump indexes as well 2012-01-16 16:05:47 -02:00
Lucas De Marchi e15a56af85 depmod: deal with relative root dir
module paths coming from libkmod are absolute. Make sure we store the
absolute dirname to compare later.
2012-01-14 02:46:58 -02:00
Lucas De Marchi 33557e8d69 depmod: fix idx calculation after postponed array creation
We need to set up each module's idx when the array is created. So,
postpone its initialization as well.
2012-01-14 02:07:14 -02:00
Lucas De Marchi 31f1d0d306 Reduce scope of counter variable 2012-01-14 02:04:31 -02:00
Lucas De Marchi f6b838e1ba depmod: adhere to coding style 2012-01-14 02:03:21 -02:00
Lucas De Marchi bc43496a87 modprobe: dump configuration 2012-01-13 11:12:41 -02:00
Lucas De Marchi 8b01376742 modprobe: abort on dependency loop that cannot be broken 2012-01-12 17:14:30 -02:00
Lucas De Marchi e4e1e64ab0 modprobe: fix leak on error path 2012-01-12 15:37:57 -02:00
Lucas De Marchi a872bba22d modprobe: rework module removal without tree traversing
Just like the module insertion, module removal is remade.

The dependencies line that comes from modules.dep already contains all
the dependencies necessary to remove that module. Therefore modprobe
doesn't have to do the recursion between the modules in order to remove
it. All we have to do is to remove in order:

For the module being removed:
----------------------------

1. softdeps (in reverse order)
2. deps (in reverse order)
3. module
4. postdeps (in reverse order)

For any of the dependencies:
----------------------------

1. softdeps (in reverse order)
2. module
3. softdeps (in reverse order)
2012-01-12 15:23:51 -02:00
Lucas De Marchi 0cf2832a31 modprobe: rework module insertion without tree traversing
The dependencies line that comes from modules.dep already contains all
the dependencies necessary to insert that module. Therefore modprobe
doesn't have to do the recursion between the modules in order to load a
module. All we have to do is to load in order:

For the module being loaded:
----------------------------

1. softdeps
2. deps
3. module
4. postdeps

For any of the dependencies:
----------------------------

1. softdeps
2. module
3. softdeps
2012-01-12 14:34:19 -02:00
Lucas De Marchi 92122614b2 modprobe: show if module is in kernel
Now with './tools/modprobe --show-depends ahci' (ahci is builtin) we have the following
output:

$ ./tools/modprobe --show-depends ahci
builtin ahci

Just like modprobe from m-i-t. Previously we had:

$ ./tools/modprobe --show-depends ahci
FATAL: Module ahci not found.
2012-01-11 21:54:25 -02:00
Jan Alexander Steffens (heftig) 00bd319113 depmod: Postpone creation of module array
Deleting modules (we have found replacements) invalidates the indices
because the array collapses removed elements, hitting the assertion.

Since we don't make use of the array until the sorting step, build it from
the modules_by_name hash instead.
2012-01-11 20:35:18 -02:00
Lucas De Marchi af0ff2f22a modprobe: break dependency loop by checking if module is loaded
modprobe doesn't have support for handling dependency loop. That happens
with poorly written softdeps that can introduce a loop. We must deal
with them like it's being done in libkmod.

However, we can break a dependency loop when the dependency was already
inserted. This commit fixes this issue, that happens in the following
scenario:

dependencies:
-------------

modA:
modB: modA
modC: modA

config:

softdep modA post: modB modC

This creates the following loop:

modA
    inserted ok
    handle post-soft-deps of modA -> modB modC
        modB
            handle dependencies of modB -> modA
                modA is already inserted
                    handle post-soft-deps of modA -> modB modC

And so on and so forth.

Now we break the loop by checking if module is already inserted, before
handling it. Thus this gives us:

modA
    inserted ok
    handle post-soft-deps of modA -> modB modC
        modB
            handle dependencies of modB -> modA
                modA is already inserted
            inserted ok
        modC
            handle dependencies of modC -> modA
                modA is already inserted
            inserted ok
2012-01-11 18:29:55 -02:00
Lucas De Marchi 8f1922101e modprobe: adhere do coding style 2012-01-11 15:48:20 -02:00
Dave Reisner 6da9cdf1f7 rmmod: behavior more like m-i-t's rmmod
In line with m-i-t's behavior, we should check to see if each module is:

- loaded
- has any holders
- has a 0 refcnt

Detecting any of these lets us provide a more useful message than the
kernel's EPERM response to delete_module(2).

Additionally, alter the main loop behavior to avoid exiting early on the
first error.
2012-01-10 22:35:18 -05:00
Dave Reisner b54f1bf06a modprobe: check for EPERM on insertion
Throw an appropriate error when an unprivileged user attempts to load a
module.
2012-01-10 22:33:05 -05:00
Lucas De Marchi 0b22179acd build-sys: workaround libtool issue with argv[0]
Symlinking tools to kmod doesn't work because argv[0] is not the name of
the symlink, but rather 'kmod' (since libtool's wrapper script calls the
tools/.libs/kmod directly)

Now we create another binary kmod-nolib that is statically linked to
libkmod so we can call the binary directly and do not worry about
LD_LIBRARY_PATH.
2012-01-10 15:31:58 -02:00
Lucas De Marchi 00fc926cd8 build-sys: create symlinks instead of building separate tools 2012-01-10 15:31:58 -02:00
Lucas De Marchi a66a6a999f Update copyright 2012-01-09 00:41:07 -02:00
Lucas De Marchi cb0d0b7212 modprobe: fix error path when loading dependencies
demarchi> scenario is the following:
demarchi> modA depends on modB and modC
demarchi> if there's a race when trying to insert a dependency of a module, say
          modB, it will stop loading all the modules
demarchi> it should check by "module already loaded error"
demarchi> like it does for modA
2012-01-08 18:08:05 -02:00
Gustavo Sverzut Barbieri 525fa07b8f modprobe: show is independent from verbose level.
"modprobe --quiet --show-depends" now works.
2012-01-08 14:32:23 -02:00
Lucas De Marchi 6daceb2f1f Replace NAME_MAX with PATH_MAX for module aliases
Module aliases can be bigger than NAME_MAX. So, replace with PATH_MAX
that is bigger enough to hold them.

Technically in some places NAME_MAX would be sufficient (those using
module names only), but they use functions that can be called with
alias. So increase the buffers in these cases to PATH_MAX too.
2012-01-08 01:02:29 -02:00
Rolf Eike Beer 55021bed20 tools/kmod-depmod: fix aliasing warning 2012-01-06 10:47:47 -02:00
Lucas De Marchi 3f1e970b5a Revert "tools/kmod-depmod: fix aliasing warning"
This reverts commit f63fc9e606. Wrong
author name. I'll apply it again later.
2012-01-06 10:44:45 -02:00
root f63fc9e606 tools/kmod-depmod: fix aliasing warning 2012-01-06 10:39:39 -02:00
Dave Reisner 7f37491375 tools/modprobe: exit non-zero on module not found with --all 2012-01-06 02:33:58 -02:00
Dave Reisner 5f85a133f8 tools/modinfo: exit non-zero on module not found 2012-01-06 02:32:28 -02:00
Lucas De Marchi aa156c9860 tools: use basename in help message 2012-01-05 08:16:28 -02:00
Lucas De Marchi 56406fdb0a kmod-depmod: demote messages to WRN when non-critical files are missing 2012-01-04 21:02:20 -02:00
Dave Reisner 6369837707 tools: unify error verbiage and casing
Fix a typo and ensure that we always use "could not" instead of "Could
not" or the conjunction "couldn't".
2012-01-04 10:59:03 -05:00
Gustavo Sverzut Barbieri 3db5bf9d38 kmod-depmod: fix replacement of existing modules.
We cannot create a kmod_module for existing module name, it will fail
due existing in the hash table "modules_by_name".

To avoid it, we first delete the existing module, if lower priority,
then add the new one.

kmod_module_new_from_path() is called only when the former module was
deleted or does not exist.
2012-01-03 16:14:57 -02:00
Gustavo Sverzut Barbieri 026c7b448d kmod-depmod: fix comparison of module priority.
This code was never tested, my bad!

 * the prefix should be ignored, as it is not stored in cfg_search/override.

 * baselen should not include '/'.

 * search length should not include '\0'.

 * override path should not include cfg->dirname prefix.
2012-01-03 16:10:17 -02:00
Gustavo Sverzut Barbieri 8ea02fe056 kmod-depmod: fix incorrect math finding out end of dirname. 2012-01-03 15:11:58 -02:00
Gustavo Sverzut Barbieri 5988652597 kmod-depmod: document --config/-C in help output. 2012-01-03 15:06:08 -02:00
Gustavo Sverzut Barbieri b0bcadd0ae kmod-depmod: add missing trailing \n to log messages. 2012-01-03 15:04:34 -02:00
Lucas De Marchi d8a6c0ccb8 kmod-modprobe: mimic modprobe when removing deps with usecount=0 2012-01-01 06:13:09 -02:00
Lucas De Marchi c9a144481d Fix leak of kmod_module and fix code style 2012-01-01 06:12:59 -02:00
Dave Reisner 0e9bd2d1ca kmodprobe: post-remove module deps with 0 refcnt 2011-12-31 18:21:00 -05:00
Dave Reisner d98880ad5c modprobe: use lighter access call instead of stat 2011-12-31 18:02:30 -05:00
Dave Reisner b09668cf64 modprobe: remove --list option
This was marked as deprecated in m-i-t's modprobe in favor of find and
basename.
2011-12-31 16:51:40 -05:00
Lucas De Marchi 0c010fae10 Move libkmod-util.c to convenience util lib
Share more code between tools and libkmod. underscores() in kmod-depmod
can not use the same function as in the lib, so rename it.
2011-12-28 13:33:26 -02:00
Lucas De Marchi 6670c63344 Move array implementation from depmode to libkmod-util 2011-12-28 12:58:47 -02:00
Lucas De Marchi f6cf14ce13 tools: kmod: bundle depmod together with the others 2011-12-27 19:56:33 -02:00
Lucas De Marchi bcb812275e Fix header guard 2011-12-27 19:53:38 -02:00
Leandro Pereira 4783d69e48 kmod tool: don't keep iterating when command has been executed 2011-12-27 19:46:44 -02:00
Lucas De Marchi 5cd13064ec kmod-depmod: use hash implementation from util lib 2011-12-27 18:11:58 -02:00
Lucas De Marchi ea1b8c3702 kmod-depmod: Fix leak of dependency vector 2011-12-27 15:21:31 -02:00
Gustavo Sverzut Barbieri a627c3f31a kmod-depmod: refactor extension matching array, support XZ.
move the extensions array match to global, conditionally add GZ and XZ
if the support is enabled.
2011-12-27 12:09:17 -02:00
Gustavo Sverzut Barbieri 18cd9da303 kmod-depmod: implement -A (--quick) 2011-12-27 12:09:17 -02:00
Gustavo Sverzut Barbieri 4a0e46dac2 kmod-depmod: implement -F and -E options.
Read System.map and Module.symvers from kernel built, then be able to
report unknown symbols.
2011-12-27 12:09:16 -02:00
Gustavo Sverzut Barbieri 7436788ca0 kmod-depmod: dump modules.dep.bin 2011-12-27 12:09:16 -02:00
Gustavo Sverzut Barbieri ec77abb918 kmod-depmod: dump modules.alias.bin 2011-12-27 12:09:16 -02:00
Gustavo Sverzut Barbieri 75a9723bb2 kmod-depmod: dump modules.symbols.bin 2011-12-27 12:09:16 -02:00
Gustavo Sverzut Barbieri 4b144e5fb4 kmod-depmod: dump modules.builtin.bin 2011-12-27 12:09:16 -02:00
Gustavo Sverzut Barbieri 92df661697 kmod-depmod: add utility functions to be used by binary dumps.
Binary dumps will use functions to convert alias to underscores and
paths to module names.
2011-12-27 12:09:16 -02:00
Gustavo Sverzut Barbieri 0de40463ba kmod-depmod: copy code from module-init-tools/index.c
Copy code from module-init-tools/index.c, the following copyright applies:

    Copyright (C) 2008  Alan Jenkins <alan-jenkins@tuffmail.co.uk>.
2011-12-27 12:09:16 -02:00
Gustavo Sverzut Barbieri 8e3505c504 kmod-depmod: dump deps. 2011-12-27 12:09:16 -02:00
Gustavo Sverzut Barbieri 0d13174578 kmod-depmod: dump aliases 2011-12-27 12:09:16 -02:00
Gustavo Sverzut Barbieri 8bc830efc5 kmod-depmod: dump softdeps. 2011-12-27 12:09:16 -02:00
Gustavo Sverzut Barbieri 9a14d0e989 kmod-depmod: dump modules.symbols
note that the hash algorithm is different thus the output order will
be different as well.

to compare the outputs, sort the files:

   depmod -n | grep '^alias symbol:' | sort > /tmp/orig
   kmod-depmod -n | grep '^alias symbol:' | sort > /tmp/new
   diff /tmp/orig /tmp/new
2011-12-27 12:09:16 -02:00
Gustavo Sverzut Barbieri 25c4151203 kmod-depmod: dump devname
first try to dump files: modules.devname.
2011-12-27 12:09:16 -02:00
Gustavo Sverzut Barbieri 64b8b586eb kmod-depmod: initial code (no files generated, untested)
this is the initial code for depmod, it should:
 * use configuration from /run/depmod.d, /etc/depmod.d, /lib/depmod.d
 * respect overrides and searches
 * resolve symbols and dependencies
 * break circular dependencies (dependency loops)
 * --errsyms: print out modules with unresolved symbols and incorrect crc
 * --symbol-prefix: respect architecture symbol prefix

it will not:
 * --quick: does not do quick mode
 * --warn: does not warn on duplicates
 * --filesyms: does not load symbols from map file
 * --symvers: does not load symbol versions from map file
 * dump files: does not dump any files at the moment.

it is highly untested, then I appreciate your help with real world
scenarios using overrides and searches. To get output run with -vvvvvv.

next version should fill in the gaps and at least generate the files
2011-12-27 12:09:16 -02:00
Lucas De Marchi 9b966da87e tools: kmod: show wrong command in err message 2011-12-23 11:44:28 -02:00
Lucas De Marchi a458e36738 tools: kmod: print help message when no commands given 2011-12-23 11:35:48 -02:00
Lucas De Marchi 252c51a996 tools: kmod: add list command
It's the same of lsmod since there's not much to change on its format.
2011-12-23 11:33:02 -02:00
Lucas De Marchi fa29c0ee96 tools: kmod: Add handling of compat modprobe 2011-12-23 03:09:05 -02:00
Lucas De Marchi 769becb5db tools: kmod: Add handling of compat modinfo 2011-12-23 03:09:05 -02:00
Lucas De Marchi ad6026965f tools: kmod: Add handling of compat insmod 2011-12-23 03:09:05 -02:00
Lucas De Marchi f712ebc429 tools: kmod: Add handling of compat rmmod 2011-12-23 03:09:05 -02:00
Lucas De Marchi 6fcf69e62b tools: kmod: Add handling of compat lsmod 2011-12-23 03:09:05 -02:00
Lucas De Marchi 35a29aa519 tools: kmod: check progname for handling compat commands 2011-12-23 03:09:05 -02:00
Lucas De Marchi bc85432aa3 tools: kmod: Add global options 2011-12-23 03:03:23 -02:00
Lucas De Marchi 8900b9166b tools: add skeleton of kmod tool
If using libtool 2.4.2, running the script generated by libtool will not
work because libtool changes argv[0] to lt-progname.

To test this is necessary to either fix the installed
build-aux/ltmain.sh file or run the binary directly like in:

$ export LD_LIBRARY_PATH=$PWD/libkmod/.libs/
$ ./tools/.libs/kmod help
2011-12-23 03:01:58 -02:00
Lucas De Marchi 3e8de63d2d kmod_modprobe: use basename(argv[0]) in help message 2011-12-23 01:36:27 -02:00
Gustavo Sverzut Barbieri 5f9f58f9f6 kmod-modprobe: fix leak in command line option processing.
not that it should matter for the binary, but let's be strict with
leaks so running in valgrind never complains.
2011-12-23 01:25:21 -02:00
Lucas De Marchi 2c96693eb2 kmod_modprobe: fix description of -C flag 2011-12-20 16:39:59 -02:00
Kay Sievers a308abec37 introduce --with-rootprefix=DIR
Configure the location of the rootfs directories and use it
to find (/usr)/lib/modules and (/usr)/lib/modprobe.d.
2011-12-20 16:22:07 -02:00
Lucas De Marchi 95dd837daf kmod_modprobe: Fix regression when inserting module
Commit "e5e2a68 kmod_modprobe: properly handle install/remove commands"
introduced a regression that, while it worked for install/remove
commands, it ceased to work for normal module names. Move the check for
whether it's a install command or a module so both cases work.
2011-12-20 13:11:33 -02:00
Gustavo Sverzut Barbieri b014c490cb kmod-modinfo: -p (-F parm) shows also parmtype in Debian expected formatting.
debian expected formatting is:

    name:description (type)

variants:

    name:description
    name: (type)
2011-12-19 18:32:58 -02:00
Gustavo Sverzut Barbieri 515ec7960b kmod-modinfo: fix typo and output format.
* it's parm, not param (does not have the second 'a');
 * output format requires ':' after the name.
2011-12-19 18:32:58 -02:00
Gustavo Sverzut Barbieri 022e1f0e0d kmod-modinfo: add missing short options.
Thanks to falconindy for testing.
2011-12-19 18:32:58 -02:00
Gustavo Sverzut Barbieri 0cc3ccfd52 Introduce kmod-modinfo. 2011-12-19 15:06:49 -02:00
Gustavo Sverzut Barbieri ab70dce181 kmod-modprobe: improve --help output. 2011-12-19 15:06:49 -02:00
Gustavo Sverzut Barbieri 0e3e2f436e kmod-modprobe: implement --dump-modversions 2011-12-19 15:06:49 -02:00
Lucas De Marchi e5e2a683f7 kmod_modprobe: properly handle install/remove commands
Handle install/remove commands just like modprobe does. Test configure
file:

install installme echo "this is a install message"
remove  removeme echo "this is a remove message"

Tests:

$ ./tools/kmod-modprobe installme
this is a install message

$ ./tools/kmod-modprobe -r removeme
this is a remove message

$ ./tools/kmod-modprobe removeme
FATAL: Module removeme not found.

./tools/kmod-modprobe -r installme
FATAL: Module installme not found.
2011-12-19 12:17:44 -02:00
Lucas De Marchi 9bf60d21f3 kmod_modprobe: fix handling of remove commands
The check for remove/install commands must be before the ignore_loaded
check because we will actually run something instead of
removing/inserting a module and the modname might not correspond to a
real module. Otherwise a fake module like "remove removeme echo 'bla'"
would not work.

This also keeps compatibility with modprobe.
2011-12-19 09:35:43 -02:00
Gustavo Sverzut Barbieri e793f1eae9 kmod-modprobe: implement softdeps.
Implement soft dependencies in a way similar to module-init-tools
modprobe. Unlike regular dependencies they are allowed to fail
inserting or removing.

The rmmod version walks the lists in reverse order, also doing post
before and pre later.
2011-12-17 20:03:44 -02:00
Lucas De Marchi 8122985dbb tools: fix kmod-modprobe -R trying to insert module 2011-12-16 02:58:48 -02:00
Lucas De Marchi cb451f35d9 Change licenses
libkmod is under LGPL 2.1 or later
tools/* are under GPL
2011-12-12 18:24:35 -02:00
Lucas De Marchi 45f2778174 Remove warnings: ‘err’ may be used uninitialized in this function 2011-12-12 17:23:04 -02:00
Lucas De Marchi 2411c07794 Do not use config if it's not needed/wanted 2011-12-12 15:41:02 -02:00
Lucas De Marchi a102e262e6 Rename kmod_loaded_get_list() to kmod_module_new_from_loaded()
Be consistent with other similar functions already present and improve
documentation.
2011-12-12 13:50:19 -02:00
Gustavo Sverzut Barbieri cb8d4d3e99 API-BREAK: kmod_new() takes a second parameter for configuration directory.
This is required by modprobe and also to help doing unit tests in future.
2011-12-11 20:58:22 -02:00
Gustavo Sverzut Barbieri c3d0a5f2ef tools: add modprobe
try to mimic original module-init-tools' modprobe as much as possible,
but this exposed some missing features in libkmod, these are now
listed in TODO.
2011-12-11 20:58:22 -02:00
Gustavo Sverzut Barbieri 72c51a9e4d add lsmod, insmod and rmmod tools.
these tools are compatible with module-init-tools (except insmod does
not take data from stdin).
2011-12-11 20:58:22 -02:00