Commit Graph

33 Commits

Author SHA1 Message Date
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
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
Lucas De Marchi
e5a7f6ac79 Fix debug message formatting 2011-12-19 15:06:49 -02:00
Gustavo Sverzut Barbieri
1c52260048 implement softdeps. 2011-12-17 19:43:11 -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
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
1c250ec150 Fix "Dead assignments" as reported by llvm 2011-12-12 18:36:27 -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
8f767e2dfa Use true/false for bool return 2011-12-12 15:27:57 -02:00
Lucas De Marchi
98c80f44c9 Directories inside config directories are not supported
This was failing silent, both in libkmod and module-init-tools. Give a
warning if we created a dir inside config directories.
2011-12-12 15:26:59 -02:00
Lucas De Marchi
4782396cc4 Do not stat() dir twice 2011-12-12 15:00:51 -02:00
Lucas De Marchi
016d619cd9 Fix leak of DIR 2011-12-12 14:39:35 -02:00
Lucas De Marchi
28c175edd1 coding style: be consistent with blank lines 2011-12-12 11:52:59 -02:00
Lucas De Marchi
c35347f15c coding style: fix lines over 80 chars
Lines should not go over 80 chars with a few exceptions:
	- headers
	- function definitions with only 1 argument
	- long strings, otherwise we break grep

This should go later in a coding-style file
2011-12-12 10:54: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
bd3f553526 export module's options and commands.
This will be required to implement modprobe later. The implementation
follows "man modprobe.conf" and allows options to be specified for
alias as well, thus the need for kmod_resolve_alias_options().

Example mod-a.conf:

    options mod-a a=1 b=2
    options mod-a c=3
    alias mymod-a mod-a
    options mymod-a d=4

Results in:
    options mod-a a=1 b=2 c=3
    options mymod-a a=1 b=2 c=3 d=4

Install commands are being concatenated with ";", but manpage is not
clean about this behavior.
2011-12-11 20:58:21 -02:00
Lucas De Marchi
a5cce6d6ef kmod_config: parse install and remove commands 2011-12-07 11:31:28 -02:00
Lucas De Marchi
615c42be5c kmod_config: parse module options 2011-12-07 10:59:44 -02:00
Lucas De Marchi
877e80cd93 Use streq() when possible 2011-12-07 02:32:28 -02:00
Lucas De Marchi
b7b7ac298f kmod_config: optimize config files handling
1) Allocate less by not sorting the result with qsort. Instead,
    insert the nodes in the correct order;
 2) Do not maintain the whole path in memory, but rely on openat()
2011-12-06 03:34:51 -02:00
Gustavo Sverzut Barbieri
43c29d10ff kmod_alias: reduce from 3 mallocs to a single one. 2011-12-05 13:42:13 -02:00
Lucas De Marchi
2295acc5da Fix some coding style issues 2011-12-03 04:05:22 -02:00
Gustavo Sverzut Barbieri
d13e606ff6 improve kmod_config api.
make the function names reflect the structure they are operating on.

the structure is now allocated and remembers the context it was
created, then no need to give the context in every function call.
2011-12-03 03:56:57 -02:00
Gustavo Sverzut Barbieri
1ce08a563e improve "const" keyword usage.
functions that do not modify their parameters get them as const pointers.

special cases:
 * kmod_get_userdata/kmod_set_userdata: return as void* for user convenience.
 * kmod_list_append/kmod_list_prepend: take const void* for user convenience.
2011-12-03 03:51:55 -02:00
Lucas De Marchi
ca491ca99c Drop configurations from /usr/local 2011-12-02 15:02:50 -02:00
Lucas De Marchi
6f1bc6e36e Clean 'unused variable' warnings 2011-12-02 10:02:05 -02:00
Lucas De Marchi
c11e62bfd4 Use strtok_r insteat of strtok
strtok is not thread-safe because it uses a static pointer to keep track
of position in the string. Using strtok_r solves the problem.
2011-12-01 18:59:54 -02:00
Lucas De Marchi
b0ef19f7f5 Add getters for aliases 2011-11-30 18:18:13 -02:00
Lucas De Marchi
30be7513c0 Use underscores() in module names and aliases 2011-11-30 02:14:57 -02:00
Lucas De Marchi
81cf2060e0 Parse blacklists in config files 2011-11-29 18:48:02 -02:00
Lucas De Marchi
7c2ab358fd Add support for parsing config files
Right now only alias keyword is treated.
2011-11-29 18:07:43 -02:00