Commit Graph

277 Commits

Author SHA1 Message Date
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