Commit Graph

283 Commits

Author SHA1 Message Date
Lucas De Marchi
c4dc3ca8a2 Add call to check if resources are valid 2012-01-01 06:18:16 -02:00
Lucas De Marchi
9fd58f30bf index: save timestamp of each loaded index 2012-01-01 06:18:16 -02:00
Lucas De Marchi
b6a4dfb1b4 config: save list of config paths with their timestamps
Save a list of config paths with their timestamps so they can be checked
later.
2012-01-01 06:18:01 -02:00
Lucas De Marchi
0b29ef6f59 util: add helper function to compare timestamps 2012-01-01 06:17:54 -02:00
Dave Reisner
9070b117ec libkmod-config: remove warning for skipped config files
conf_files_filter_out() already skips these files, but writes to the log
to warn that they'll be ignored in the future.
2011-12-31 19:30:26 -02:00
Lucas De Marchi
2f76fda259 Use last enum value instead of ARRAY_SIZE 2011-12-31 19:30:09 -02:00
Lucas De Marchi
4926cb501d Do not call exported function for mod->name
Name is always available and we don't neet to call a exported function
to get it.
2011-12-31 11:21:52 -02:00
Lucas De Marchi
0d46743ca5 Move function to the right place 2011-12-31 11:15:52 -02:00
Lucas De Marchi
e47c604525 Ignore "already loaded" error in module_probe_insert_module()
It also fixes a leak in the error path.
2011-12-30 14:16:15 -02:00
Lucas De Marchi
bbf59327e3 Use errno instead of return value of init_module()
Return -errno instead of the value returned by init_module(). We need to
differentiate between the several errors that might occur, e.g. "module
already loaded", access denied, etc.
2011-12-30 14:13:33 -02:00
Leandro Pereira
1698456259 libkmod-util: getline_wrapped: return NULL when buffer allocation fails 2011-12-28 15:55:45 -02:00
Leandro Pereira
40ee8dadca Do not forget parenthesis around if (streq(A, B)). 2011-12-28 15:54:38 -02: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
a4848e249f Move util functions to libkmod-util.c
These allow them to be later shared with tools.
2011-12-27 18:11:58 -02:00
Lucas De Marchi
8d1278d03f hash: add iterator 2011-12-27 18:11:58 -02:00
Lucas De Marchi
529148ea70 build-sys: create libkmod-util.la convenience lib
Util functions can be shared betweeing libkmod and tools. Start with the
hash implementation.
2011-12-27 18:11:58 -02:00
Lucas De Marchi
d707380744 Copy missing hash functions from kmod-depmod to libkmod 2011-12-27 18:11:58 -02:00
Lucas De Marchi
822913d74c Remove kmod_ prefix from hash implementation
In a future commit, hash implementation will be shared between libkmod
and depmod. kmod_hash is not exported, so remove the namespace.
2011-12-27 18:11:58 -02:00
Lucas De Marchi
ebaa7beb0a Log paths if kmod_module_new_from_path() failed 2011-12-27 18:11:12 -02:00
Lucas De Marchi
ddbda02286 Add implementation of modprobe's insertion
Treat module insertion as modprobe does: look for (soft-)dependencies, run
install commands, apply blacklist.

The difference with the blacklist is that it's applied to all modules,
including the dependencies. If you want to apply a blacklist only on the
module it's better to call the filter function by yourself.

This implementation detects loops caused by poorly written
soft-dependencies and fail gracefully, printing the loop to the log.
2011-12-27 11:55:22 -02:00
Lucas De Marchi
2bd7cbf644 Do not cache softdeps list
This might include a circular dependency which would screw up the
refcounting because there's an internal reference.
2011-12-27 10:40:51 -02:00
Lucas De Marchi
b72f74b5dd Allow to internally get dependencies without copying list 2011-12-27 10:40:51 -02:00
Lucas De Marchi
c1c9c44628 Add functions to get ctx blacklists 2011-12-27 02:49:46 -02:00
Lucas De Marchi
eb4ae531f7 Fix kmod_list_remove_n_latest()
It only worked because n was always 1. kmod_list_remove returns a
pointer to the next element, relative to the removed one. Therefore we
need to always get a pointer to the last.
2011-12-27 02:48:36 -02:00
Lucas De Marchi
b94a737935 Reverse order of dependency list
Dependency list in modules.dep is kept in reverse order. Prepend to
list so all the other places treat it in the right order.
2011-12-26 20:15:10 -02:00
Cristian Rodríguez
4088b27e21 index_file_open: fix another fd leak on error path. 2011-12-26 09:55:15 -02:00
Lucas De Marchi
ef4a349aaa Merge branch 'master' of git://dev.medozas.de/libkmod 2011-12-24 17:51:27 -02:00
Lucas De Marchi
7adfd2c36d Merge branch 'master' of git://dev.medozas.de/libkmod 2011-12-24 17:39:44 -02:00
Jan Engelhardt
c362171286 libkmod: remove external cflags from .pc file
Since the public header files of libkmod do not include header files
of liblzma or zlib, the flags need not be present.
2011-12-24 20:28:11 +01:00
Jan Engelhardt
b182f8fb5e Support for loading Xz-compressed modules 2011-12-24 20:26:22 +01:00
Jan Engelhardt
7b3a74fc67 build: use pkgconfig to detect zlib
build: explicitly call PKG_PROG_PKG_CONFIG

Per the manual page, PKG_PROG_PKG_CONFIG needs to be invoked
explicitly if PKG_CHECK_MODULES might not happen (it is indeed stowed
in an AS_IF in kmod). Without this, funny failures can occur.
(As it did.)
2011-12-24 20:25:21 +01:00
Lucas De Marchi
3af4f558da Fix version script with v3 symbols 2011-12-24 02:40:30 -02:00
Gustavo Sverzut Barbieri
674f8590e3 elf: implement kmod_module_get_dependency_symbols()
Uses kmod_elf_get_dependency_symbols() that looks into ".symtab" for
UNDEF symbols and matches the name from ".strtab" to "__versions" to
get crc.

Likely the public API should unify the symbol information getters and
list release, they are almost the same.
2011-12-24 01:44:31 -02:00
Gustavo Sverzut Barbieri
4b55befd37 elf: add bind type to kmod_modversion.
will be used to share this structure with get_dependency_symbols()
2011-12-24 01:44:31 -02:00
Gustavo Sverzut Barbieri
45e6db9c01 elf: add get_symbols()
Similar to module-init-tools load_symbols(), it will try .symtab and
.strtab for symbols starting with __crc_, if they are found their crc
is read from ELF's Elf_Sym::st_value.

If not found, then it will fallback to __ksymtab_strings.
2011-12-24 01:44:31 -02:00
Gustavo Sverzut Barbieri
9bbb72df05 elf: minimum size is enough. 2011-12-24 01:24:55 -02:00
Gustavo Sverzut Barbieri
bb417099e4 file: speed up loading non-gzipped modules when zlib is enabled.
Just now realized that my distro (Gentoo) enables support for gzip but
does not compress modules by default.

In this case it's better to have a special case that uses mmap()
instead of a loop of realloc() + gzread().
2011-12-24 01:15:25 -02:00
Cristian Rodríguez
67d94ad388 Fix leak on error path 2011-12-23 03:08:57 -02:00
Lucas De Marchi
759214fad0 Initialize line number with 0 2011-12-22 01:30:40 -02:00
Gustavo Sverzut Barbieri
c6824b62f2 Fix unaligned memory access
Bug found on sparc64. Thanks to "Jan Engelhardt <jengelh@medozas.de>"
for providing access to such a machine.
2011-12-21 18:37:46 -02:00
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