Commit Graph

242 Commits

Author SHA1 Message Date
Lucas De Marchi
f304afe153 Change error message to reflect reality 2011-12-20 23:48:27 -02:00
Lucas De Marchi
142db570bf Update doc to reflect function behavior 2011-12-20 23:39:30 -02:00
Luis Felipe Strano Moraes
9efaf2f627 Testing for return of alias_normalize. 2011-12-20 23:23:55 -02:00
Lucas De Marchi
f39dc70e4b Removing comments saying flags are not implemented
Both removal and insertion flags are already implemented.
2011-12-20 19:31:14 -02:00
Lucas De Marchi
5e50464548 Move symbols introduced in libkmod2 to the right place 2011-12-20 17:16:24 -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
7fe5f7abce Use sorted configuration files in precedence order
We need to keep config files sorted and use them taking the precedence
order into account.

The following message was taken from module-init-tools commit doing a
similar thing:

	Configuration files are parsed in alphabetic order, regardles of
	what directory they reside in. Furthermore, if several files by
	the same name exist in different directories only the one in the
	directory with highest precedence is loaded.

	The order of precedence is /run, /etc, /usr/lib, /lib.

The sad thing is that we are not using openat() anymore since each file
is in different directories. In future we might change the
implementation to open all DIRs and keep a reference
to them instead of the path. However we'd have to keep a separate list
with all the opened dirs so we can close them later (when all configs
are parsed).
2011-12-20 16:08:18 -02:00
Jan Engelhardt
87beacc99f libkmod: use C99 __func__ over GNU-specific __FUNCTION__ 2011-12-20 13:48:44 -02:00
Lucas De Marchi
135bffd652 kmod_config: fix kcmd line parser with dots after =
Check if '=' appeared before the dot. In this case, it's not a valid
module option in kernel command line.

The command line that was failing is:

"root=/dev/sda3 ro pcie_aspm=force init=/sbin/bootchartd
	initrd=../initramfs-linux.img BOOT_IMAGE=../vmlinuz-linux"
2011-12-20 13:25:24 -02:00
Luis Felipe Strano Moraes
a969376fb0 Removing warnings when compiling on i686 platform. 2011-12-20 13:15:32 -02:00
Gustavo Sverzut Barbieri
b55df2ee03 kmod_module_new_*: improve debugging. 2011-12-20 13:13:41 -02:00
Lucas De Marchi
16ca3666bf Fix check for opened indexes 2011-12-20 12:29:13 -02:00
Lucas De Marchi
76b8031bce elf: fix regression with empty strings
Commit "b20dc17 Remove unneeded reference to last string" reverted the
fix in "47a0ef6 elf: do not output empty strings." and empty strings are
appearing again in kmod-modinfo.

With this commit we do a bit different and instead of keeping the
reference to last string we skip the '\0' inside the loop.
2011-12-20 12:04:21 -02:00
Lucas De Marchi
51c409b449 Cache the offset of crc
This way we don't need to check every time in loop. Indeed compiler
could already optimize out that checks, but this ways is cleaner and
shorter.
2011-12-20 11:41:19 -02:00
Lucas De Marchi
58b7191c94 Make section size constant since it's always the same 2011-12-20 11:35:17 -02:00
Lucas De Marchi
f8fa525c7f Optimize kmod_elf_get_strings() by reducing calls to memcpy
Copy the entire string only once and then scan it, setting up the
pointers of the vector.
2011-12-20 03:34:28 -02:00
Lucas De Marchi
b20dc17068 Remove unneeded reference to last string 2011-12-20 03:27:51 -02:00
Lucas De Marchi
052656f5b3 Put blank lines where it's due
See CODING-STYLE for reference
2011-12-20 03:27:51 -02:00
Lucas De Marchi
3267026e0b Terminate strv with NULL 2011-12-20 03:27:50 -02:00
Lucas De Marchi
4f0f0e75e2 Reduce ident by continuing early 2011-12-20 03:27:50 -02:00
Gustavo Sverzut Barbieri
1c58590549 elf: skip leading symbol dot in modversion.
Mimics module-init-tools's dump_modversions() that calls skip_dot()
to skip leading dots. This is required for PPC64.
2011-12-19 21:55:27 -02:00
Gustavo Sverzut Barbieri
fc8e58ba4e elf: fix typo that resulted in invalid uint reads for big-endian platforms. 2011-12-19 21:55:22 -02:00
Gustavo Sverzut Barbieri
47a0ef601d elf: do not output empty strings. 2011-12-19 18:32:58 -02:00
Gustavo Sverzut Barbieri
fc27344ed9 elf: fix minimum file size calculation.
there is only a single file header, multiple sections.
2011-12-19 15:06:49 -02:00
Gustavo Sverzut Barbieri
708624a4eb ELF: initial support for modinfo and strip of modversions and vermagic.
Needs testing, but should work.
2011-12-19 15:06:49 -02:00
Lucas De Marchi
e5a7f6ac79 Fix debug message formatting 2011-12-19 15:06:49 -02:00
Lucas De Marchi
9dec24462d Fix wrong name len when converting path to modname 2011-12-18 15:12:57 -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
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
Ulisses Furquim
a955f71f60 trivial: fix typo causing an infinite loop 2011-12-15 21:36:12 +00: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
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
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
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