Commit Graph

1371 Commits

Author SHA1 Message Date
Lucas De Marchi e5a7f6ac79 Fix debug message formatting 2011-12-19 15:06:49 -02:00
Gustavo Sverzut Barbieri f841e63d7a TODO: add idea about single file with all compressed modules. 2011-12-19 12:34:37 -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
Lucas De Marchi 9dec24462d Fix wrong name len when converting path to modname 2011-12-18 15:12:57 -02:00
Lucas De Marchi b6ea28dda4 Fix leak of kmod_module 2011-12-18 01:35:30 -02:00
Gustavo Sverzut Barbieri a6bf2495f6 compatibility: match commands using fnmatch() instead of strcmp().
module-init-tools modprobe.c use fnmatch() and not strcmp() to match
commands and softdeps, although the man page does not say so. Then use
the same function to provide compatibility.
2011-12-17 20:03:44 -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
Gustavo Sverzut Barbieri d6b55b7d18 introduce kmod_list_foreach_reverse().
walks the list in the reverse order.
2011-12-17 20:03:43 -02:00
Lucas De Marchi fecbad2f22 Use tab instead of spaces 2011-12-17 20:03:13 -02:00
Gustavo Sverzut Barbieri d5ec60bc0c introduce kmod_list_last()
This gets the last element in the list, that is, the previous element
of the head.
2011-12-17 19:43:11 -02:00
Gustavo Sverzut Barbieri 2a70a5d4e0 fix kmod_list_prev().
kmod_list_prev() should return NULL if the current element is the
head, not if the previous element is the head. This was likely a copy
& paste error from kmod_list_next().
2011-12-17 19:43:11 -02:00
Gustavo Sverzut Barbieri 1c52260048 implement softdeps. 2011-12-17 19:43:11 -02:00
Gustavo Sverzut Barbieri a5a92a613c fix error handling path. 2011-12-17 19:43:11 -02:00
Gustavo Sverzut Barbieri 3d8226edfe implement zlib module loading. 2011-12-17 19:43:11 -02:00
Lucas De Marchi f4fc552368 Lookup for commands in kmod_module_new_from_lookup()
Install and remove commands are now properly treated on lookup. Example
config file:

$ ./test/test-lookup installme
libkmod version 1
Alias: 'installme'
Modules matching:
	installme
		install commands: 'echo "this is a install message"'

$ ./test/test-lookup removeme
libkmod version 1
Alias: 'removeme'
Modules matching:
	removeme
		remove commands: 'echo "this is a remove message"'
2011-12-17 19:41:35 -02:00
Lucas De Marchi 60f6760e73 kmod_module: do not find more than the first command
modprobe from module-init-tools does not use more than one
install/remove command, it just stops on the first one. Test
modprobe.conf:

install bla echo "this is a message"
install bla echo "this is a message"

$ modprobe bla
this is a message
$

Install and remove commands are already a legacy thing we need to carry,
but let's not extend it so people do not start doing crazy things.

With this patch we are breaking on the first element we find in the
configuration. May be we can add a warning later when parsing the config
that install commands are duplicated.
2011-12-17 19:41:35 -02:00
Cristian Rodríguez 8e3e5839a0 Open more file descriptors with O_CLOEXEC 2011-12-17 19:28:10 -02:00
Cristian Rodríguez 79e5ea91e0 Library must use O_CLOEXEC whenever it opens file descriptors 2011-12-16 04:16:09 -02:00
Lucas De Marchi e17cc3afcc Add address of mailing list 2011-12-16 04:11:25 -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 5e690c5cbd TODO: add new tasks and notes to future development 2011-12-16 02:20:44 -02:00
Ulisses Furquim a955f71f60 trivial: fix typo causing an infinite loop 2011-12-15 21:36:12 +00:00
Lucas De Marchi 89eba7cb77 kmod 1 2011-12-15 15:43:58 -02:00
Lucas De Marchi e269a84cab Add libkmod files to EXTRA_DIST 2011-12-15 15:40:22 -02:00
Lucas De Marchi 4084c176c1 Remove module from hash when it's gone
Module was never being removed from hash table. Therefore, if we create
a module, unref it and create it again we will access freed memory.
Commit "53385cf Improve test of double references" introduced a new test
in test-mod-double-ref.c that previously to this commit was crashing and
now it's working fine.
2011-12-15 13:49:13 -02:00
Lucas De Marchi 22907a188c Improve test of double references 2011-12-15 13:49:13 -02:00
Lucas De Marchi 818f8e8ad5 Add safety NULL checks in exported functions 2011-12-15 13:49:13 -02:00
Lucas De Marchi 8bdeca11b1 Fix changing hash key after module is inserted in hash
The hash key is not copied so we can't change the string from:
	modname/modalias

	to:

	modname'\0'modalias

in order to setup mod->name and mod->alias.

Now what we do is:

1) if name is in the form 'modname/modalias', the final struct
   kmod_module will be:

   struct kmod_module {
           char *alias;------,
           char *name;-----, |
           char *hashkey;--|-|-,
   }                       | | |
   name <------------------' | |
   alias <-------------------' |
   hashkey <-------------------'

2) if name is in the simple form 'modname', then the final struct
   kmod_module will be:

   struct kmod_module {
           char *alias;------> NULL
           char *name;-----,
           char *hashkey;--|---,
   }                       |   |
   name <------------------*---'
2011-12-15 13:48:19 -02:00
Lucas De Marchi 91428ae1b8 Fix docs with wrong function names 2011-12-15 13:09:46 -02:00
Lucas De Marchi 5f3429cdad Add comment in public header about flags not implemented 2011-12-15 12:27:45 -02:00
Lucas De Marchi 128386a406 Rename symbol group 2011-12-15 12:26:15 -02:00
Lucas De Marchi 3e71947c1e Remove flags that likely will not be used 2011-12-15 12:18:00 -02:00
Lucas De Marchi c4b4ac9e5b TODO: rephrase some tasks 2011-12-15 12:14:43 -02:00
Lucas De Marchi 836e455155 Add file with details regarding coding style 2011-12-15 00:43:54 -02:00
Lucas De Marchi 23c0d01279 Fix format of log message 2011-12-14 17:21:46 -02:00
Lucas De Marchi 1684e4402c kmod_config: parse kernel command line for options and blacklist 2011-12-14 17:19:19 -02:00
Luis Felipe Strano Moraes fe8bf3b009 Do not depend on AM_SILENT_RULES if it is not available. 2011-12-14 16:19:03 -02:00
Lucas De Marchi 113c66a562 kmod_module: use 'modname/aliasname' as key for hash
1 alias may correspond to more than 1 module. This would cause a
conflict in the hash table when inserting a module there and bad things
could happen.

Now we use 'modname/aliasname' as key, '/aliasname' part being optional.
Internally kmod_module_new_from_alias() will setup a 'modname/aliasname'
string and pass to kmod_module_new_from_name() that will treat the case
with a '/' in the name.

User might call kmod_module_new_from_name() without any slashes, so the
key my not contain it.
2011-12-14 15:26:04 -02:00
Lucas De Marchi 788ef0f7e6 Use malloc + memset instead of calloc 2011-12-14 15:05:03 -02:00
Lucas De Marchi d68ea2aede TODO: update tasks 2011-12-14 14:39:26 -02:00
Lucas De Marchi 2d7bab5c7d kmod_module: move function to the right section 2011-12-14 12:10:30 -02:00
Lucas De Marchi 63af0615d5 kmod_module: fix log message upon module removal 2011-12-14 12:10:30 -02:00
Lucas De Marchi 7afc98a1f6 kmod_module: add missing documentation 2011-12-14 12:10:30 -02:00
Lucas De Marchi 6de8f6e966 Simplify kmod_load_resources()
We have a static vector of indexes. There's no need to check if they
have a suffix or if they are absolute, we just already know in advance
and there are no plans to change it.
2011-12-14 10:53:10 -02:00
Lucas De Marchi 3e67676617 Log and break early if index is already open 2011-12-14 10:53:10 -02:00
Lucas De Marchi be5a6deaea Update documentation 2011-12-14 10:53:10 -02:00
Lucas De Marchi 25c0543ff6 Remove function kmod_resolve_alias_options()
Remove function kmod_resolve_alias_options since it's not needed
anymore. Test is using the following configuration file:

alias blablabla ac
options ac test=1
options blablabla test=2

Lookup test by module name:
	$ ./test/test-lookup ac
	libkmod version 1
	Alias: 'ac'
	Modules matching:
		ac
			options: 'test=1'

Lookup test by alias:
	$ ./test/test-lookup blablabla
	libkmod version 1
	Alias: 'blablabla'
	Modules matching:
		ac
			options: 'test=1 test=2'
2011-12-13 14:28:16 -02:00
Lucas De Marchi 07b8c823ed kmod_module: make get_options() search for alias names too 2011-12-13 14:21:24 -02:00
Lucas De Marchi ee3b3ff292 Create module by alias name where appropriate 2011-12-13 14:20:48 -02:00