History log of /external/kmod/libkmod/libkmod-module.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
b1982674ae994b6ceda36dbee3fba3b2a6ba10de 15-Feb-2017 Bartosz Golaszewski <bgolaszewski@baylibre.com> module: fix a memory leak

When a module is removed and re-inserted without unrefing, the
kmod_file is unconditionally re-opened. This results in a memory
and file descriptor leak.

Fix it by checking if the file is already open in
kmod_module_insert_module().

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
/external/kmod/libkmod/libkmod-module.c
e78fe15f0aa7150ad8faa01665511a608202dccb 05-Jun-2016 Lucas De Marchi <lucas.demarchi@intel.com> libkmod-module: modinfo: print signature id

This way it's possible to give at least the signature type for PKCS#7.
/external/kmod/libkmod/libkmod-module.c
dcdb17715e451acc5bd6fef0d18b0c3cef77f2c9 05-Jun-2016 Lucas De Marchi <lucas.demarchi@intel.com> libkmod-module: do not crash modinfo on 0 key id len
/external/kmod/libkmod/libkmod-module.c
2206d7f763a1c9cf88f77d0ab19e410d17749361 17-Jun-2016 Michal Marek <mmarek@suse.cz> libkmod: Handle long lines in /proc/modules

kmod_module_new_from_loaded() calls fgets with a 4k buffer. When a
module such as usbcore is used by too many modules, the rest of the line
is considered a beginning of another lines and we eventually get errors
like these from lsmod:

libkmod: kmod_module_get_holders: could not open '/sys/module/100,/holders': No such file or directory

together with bogus entries in the output. In kmod_module_get_size, the
problem does not affect functionality, but the line numbers in error
messages will be wrong.

Signed-off-by: Michal Marek <mmarek@suse.com>
/external/kmod/libkmod/libkmod-module.c
1930899aaed49c96f41dd71da6d19f71f11b5258 21-May-2016 Peter Wu <peter@lekensteyn.nl> kmod_module_get_refcnt: fix documentation
/external/kmod/libkmod/libkmod-module.c
114ec87c85c35a2bd3682f9f891e494127be6fb5 13-Jun-2015 Lucas De Marchi <lucas.demarchi@intel.com> libkmod-module: fix return code in error path

ENOSYS is the wrong errno to return when we don't find a module in
kmod_module_insert_module(). Why is it there in the first place? This
goes back to kmod v1 when we couldn't load modules by names, but we
should give a path instead.

708624a ("ELF: initial support for modinfo and strip of modversions and
vermagic.") changed that so we do a lazy-search by the module path in
this function. Later f304afe ("Change error message to reflect
reality") fixed the log message but the return coded remained the same.
/external/kmod/libkmod/libkmod-module.c
fd44a98ae2eb5eb32161088954ab21e58e19dfc4 22-Feb-2015 Harish Jenny K N <harish_kandiga@mentor.com> Fix race while loading modules

usecase: two sd cards are being mounted in parallel at same time on
dual core. example modules which are getting loaded is nls_cp437.
While one module is being loaded , it starts creating sysfs files.
meanwhile on other core, modprobe might return saying the module
is KMOD_MODULE_BUILTIN, which might result in not mounting sd card.

Experiments done to prove the issue in kmod.
Added sleep in kernel module.c at the place of creation of sysfs files.
Then tried `modprobe nls_cp437` from two different shells.
While the first was still waiting for its completion ,
the second one returned saying the module is built-in.

[ Lucas:

The problem is that the creation of /sys/module/<name> and
/sys/module/<name>/initstate are not atomic. There's a small window in
which the directory exists but the initstate file was still not
created.

Built-in modules can be handled by searching the modules.builtin file.
We actually lose some "modules" that create entries in /sys/modules
(e.g. vt) and are not in modules.builtin file: only those that can be
compiled as module are present in this file.

We enforce mod->builtin to always be up-to-date when
kmod_module_get_initstate() is called. This way if the directory
exists but the initstate doesn't, we can be sure this is because the
module is in the "coming" state, i.e. kernel didn't create the file
yet, but since builtin modules were already handled by checking our
index the only reason for that to happen is that we hit the race
condition.

I also added some tweaks to the patch, so we don't repeat the code for builtin
lookup. ]
/external/kmod/libkmod/libkmod-module.c
01f9bc6deed3f9f14c8129efd0ffc100e7a0e6d0 26-Jan-2015 Lucas De Marchi <lucas.demarchi@intel.com> Fix uninitialized warning

Initialize variable to NULL before calling kmod_module_new_from_lookup().

libkmod/libkmod-module.c: In function 'kmod_module_new_from_lookup.part.4.constprop':
libkmod/libkmod-module.c:192:8: warning: 'depmod' may be used uninitialized in this function [-Wmaybe-uninitialized]
list = kmod_list_prepend(list, depmod);
^
libkmod/libkmod-module.c:173:23: note: 'depmod' was declared here
struct kmod_module *depmod;
/external/kmod/libkmod/libkmod-module.c
dea2dfee9b301da84dbb09cf510b8ebf2ef28fff 26-Dec-2014 Lucas De Marchi <lucas.demarchi@intel.com> Remove FSF mailing address

It has changed in the past, and these days, anyone can get a copy of the
LGPL via the web rather than by post.

Like 657a122 (Remove FSF mailing address) in libabc by Josh Tripplet,
but let the FSF website in which the license can be found.
/external/kmod/libkmod/libkmod-module.c
c2e4286bb98c6bec77575ac0c6f862e7ddf6394f 03-Oct-2014 Lucas De Marchi <lucas.demarchi@intel.com> Reorder and reorganize header files

Let the includes in the following order:

< system headers >
< libkmod >
< tool >
< local headers >
/external/kmod/libkmod/libkmod-module.c
96573a02208abebe4a884c0bbd0d6ecde9047f37 03-Oct-2014 Lucas De Marchi <lucas.demarchi@intel.com> Move generic util functions to shared directory
/external/kmod/libkmod/libkmod-module.c
74c26943f1228870022d116a1fda25be3a55a38e 19-Jun-2014 Cristian Rodríguez <crrodriguez@opensuse.org> Add missing O_CLOEXEC in kmod_module_get_size()
/external/kmod/libkmod/libkmod-module.c
30bfd48aeffa6465d2de0e927cdfc6205c1f1fd2 29-Apr-2014 Leandro Pereira <leandro@hardinfo.org> Close /sys/module/$NAME directory if opening /proc/module fails.
/external/kmod/libkmod/libkmod-module.c
c1bc88c98ed2c1dce4de8a6ed45db212a19f79f4 29-Apr-2014 Leandro Pereira <leandro@hardinfo.org> Free abspath if kmod_module_new_from_path() fails.
/external/kmod/libkmod/libkmod-module.c
450bd1b4290e0dec65397881a7037090f203045a 31-Mar-2014 Michal Marek <mmarek@suse.cz> libkmod: Ignore errors from softdeps

Before we had softdeps, the usual idiom was

install foo /sbin/modprobe bar; /sbin/modprobe --ignore-install foo

ignoring errors from the first modprobe invocation. This also matches
the behavior of module-init-tools' implementation of softdep.
/external/kmod/libkmod/libkmod-module.c
c2f4d85a9adea895958fc85b9b87ce95a7dc7774 28-Feb-2014 Michal Marek <mmarek@suse.cz> libkmod-module: Simplify kmod_module_insert_module()

Store the file and elf pointer in the kmod_module structure and have it
freed together with the module.
/external/kmod/libkmod/libkmod-module.c
366e2ed7913410bfd5b2bcbe88128686f153d501 21-Jan-2014 Lucas De Marchi <lucas.demarchi@intel.com> Remove duplicate includes

Found by
https://raw.github.com/karelzak/util-linux/master/tools/checkincludes.pl
/external/kmod/libkmod/libkmod-module.c
9f02561d84235608c3c97ef97e957e331a4c1d82 18-Nov-2013 Lucas De Marchi <lucas.demarchi@intel.com> module: use _cleanup_free and remove useless call to free()
/external/kmod/libkmod/libkmod-module.c
7ab8804448377fb6b8854f2dd288608db01bb43b 20-Sep-2013 Lucas De Marchi <lucas.demarchi@intel.com> libkmod: always pass O_NONBLOCK to kernel

Not passsing O_NONBLOCK to delete_module() is deprecated since kmod 11
and is being removed from the kernel. Force this flag in libkmod.
/external/kmod/libkmod/libkmod-module.c
7e0385c47ae7c313a59de3ea431af7b5d18807d7 28-Aug-2013 Lucas De Marchi <lucas.demarchi@intel.com> Fix usage of readdir_r()

With readdir_r() we should be providing enough space to store the dir
name. This could be accomplished by define an union like systemd does:

union dirent_storage {
struct dirent de;
uint8_t storage[offsetof(struct dirent, d_name) +
((NAME_MAX + 1 + sizeof(long)) & ~(sizeof(long) - 1))];
};

However in all places that we use readdir_r() we have no concerns about
reentrance nor we have problems with threads. Thus use the simpler
readdir() instead.

We also remove the error logging here (that could be added back by
checking errno), but it was not adding much value so it's gone.
/external/kmod/libkmod/libkmod-module.c
83b855a6ed7028173e231eab0a39c929a962ddf5 04-Jul-2013 Lucas De Marchi <lucas.demarchi@intel.com> Use "-internal" suffix instead of "-private"
/external/kmod/libkmod/libkmod-module.c
d7152f6282fe10486d41f7917393e3b86c0e5766 04-May-2013 Chengwei Yang <chengwei.yang@intel.com> Add document for exported enums

There are several exported enums by libkmod without document, this patch
mainly added documentation for below enums like the way kmod_resources
be documented in.
* kmod_index
* kmod_remove
* kmod_insert
* kmod_probe
* kmod_filter
* kmod_module_initstate

This is not the best way to document these exported enums, however, it's
the simple way due to gtkdoc limits. It doesn't support export plain
enum like below: see https://bugzilla.gnome.org/show_bug.cgi?id=657444
---------8<-------head.h--------------8<-----------
...
enum foo {
...
};
...
---------8<-------end of head.h-------8<-----------
---------8<-------source.c------------8<-----------
...
/**
* document for foo here
*/
...
typedef enum foo foo;
...
---------8<-------end of source.c-----8<----------
/external/kmod/libkmod/libkmod-module.c
491c490204f72a8eea627bebe25f6d242e4fecb7 04-May-2013 Chengwei Yang <chengwei.yang@intel.com> Several minor fixes for documentation
/external/kmod/libkmod/libkmod-module.c
b9a7da391066768736a2f23a360a3995df4bc097 24-Apr-2013 Lucas De Marchi <lucas.de.marchi@gmail.com> libkmod-module: Don't pass NULL ctx to kmod_log
/external/kmod/libkmod/libkmod-module.c
818af4f6fa925a2affdc6d65e9d18d6922b11baf 24-Apr-2013 Lucas De Marchi <lucas.de.marchi@gmail.com> libkmod-module: Don't pass NULL pointer to memcpy

When passing n=0, don't pass a NULL pointer, but instead pass anything
else (like the pointer to the start of the string).
/external/kmod/libkmod/libkmod-module.c
55112d19f7067dff89b1481d5bd8cc49139c4ecb 09-Apr-2013 Lucas De Marchi <lucas.de.marchi@gmail.com> libkmod: Move finit_module() definition to missing.h

Check for finit_module() and don't use our own static inline function if
there's such function in libc (or another lib).

In testsuite we need to unconditionally define HAVE_FINIT_MODULE because
we want to override this function, and never use the static inline one
in missing.h
/external/kmod/libkmod/libkmod-module.c
1407064e730732dd20952671077007dd4133f7db 09-Apr-2013 Lucas De Marchi <lucas.de.marchi@gmail.com> libkmod: Add missing definitions

Depending on kernel header and simply not passing the flags in
finit_module() if this header is not found is not good.

Add a missing.h header in which stuff like this should be added.
/external/kmod/libkmod/libkmod-module.c
144d1826f1a0fcd6cc59c4535f0a8145163c640c 18-Feb-2013 Kees Cook <keescook@chromium.org> libkmod: add finit_module logic

When a module is being loaded directly from disk (no compression, etc),
pass the file descriptor to the new finit_module() syscall. If the
finit_module syscall is exported by the kernel syscall headers, use it.
Additionally, if the kernel's module.h file is available, map kmod flags
to finit_module flags.
/external/kmod/libkmod/libkmod-module.c
8fe1681c52ceec35c77e37ca03837c0948e41b49 16-Jan-2013 Michal Marek <mmarek@suse.cz> libkmod: Return module signature information in kmod_module_get_info()

If the module is built with CONFIG_MODULE_SIG, add the the signer's
name, hexadecimal key id and hash algorithm to the list returned in
kmod_module_get_info(). The modinfo output then looks like this:

filename: /home/mmarek/kmod/testsuite/rootfs-pristine/test-modinfo/ext4-x86_64-sha256.ko
license: GPL
description: Fourth Extended Filesystem
author: Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others
alias: ext3
alias: ext2
depends: mbcache,jbd2
intree: Y
vermagic: 3.7.0 SMP mod_unload
signer: Magrathea: Glacier signing key
sig_key: E3:C8:FC:A7:3F:B3:1D:DE:84:81:EF:38:E3:4C:DE:4B:0C:FD:1B:F9
sig_hashalgo: sha256

The signature algorithm (RSA) and key identifier type (X509) are not
displayed, because they are constant information for every signed
module. But it would be trivial to add this. Note: No attempt is made at
verifying the signature, I don't think that modinfo is the right tool
for this.
/external/kmod/libkmod/libkmod-module.c
6333934e27934a4d8d7dde729e965fab7f2c416b 16-Jan-2013 Michal Marek <mmarek@suse.cz> libkmod-module: Do not free the list in kmod_module_info_append

In error case, just return NULL and let the caller free the list.
/external/kmod/libkmod/libkmod-module.c
e6b0e49b4ea7937a98b16f23d621244ee1a3e588 16-Jan-2013 Lucas De Marchi <lucas.demarchi@profusion.mobi> Update copyright notices
/external/kmod/libkmod/libkmod-module.c
f64458cab522670135950adc4b04f18df20ae947 16-Jan-2013 Michal Marek <mmarek@suse.cz> libkmod-module: Add helper for building the module info list
/external/kmod/libkmod/libkmod-module.c
1eff942e37adda55bd8c506d4e2a7970fdbf7a74 18-Oct-2012 Lucas De Marchi <lucas.de.marchi@gmail.com> libkmod: cache open file for later access

If we are accessing several times the modules and reading some sections
by sucessive calls to the functions below, we are incurring in a penalty
of having to open, parse the header and close the file. For each
function.

- kmod_module_get_info()
- kmod_module_get_versions()
- kmod_module_get_symbols()
- kmod_module_get_dependency_symbols()

These functions are particularly important to depmod. It calls all of
them, for each module. Moreover there's a huge bottleneck in the open
operation if we are using compression. Every time we open the module we
need to uncompress the file and after getting the information we need we
discard the result. This is clearly shown by profiling depmod with perf
(record + report), using compressed modules:

64.07% depmod libz.so.1.2.7 [.] 0x00000000000074b8 ◆
18.18% depmod libz.so.1.2.7 [.] crc32 ▒
2.42% depmod libz.so.1.2.7 [.] inflate ▒
1.17% depmod libc-2.16.so [.] __memcpy_ssse3_back ▒
0.96% depmod [kernel.kallsyms] [k] copy_user_generic_string ▒
0.89% depmod libc-2.16.so [.] __strcmp_sse42 ▒
0.82% depmod [kernel.kallsyms] [k] hrtimer_interrupt ▒
0.77% depmod libc-2.16.so [.] _int_malloc ▒
0.44% depmod kmod-nolib [.] kmod_elf_get_strings ▒
0.41% depmod kmod-nolib [.] kmod_elf_get_dependency_symbols ▒
0.37% depmod kmod-nolib [.] kmod_elf_get_section ▒
0.36% depmod kmod-nolib [.] kmod_elf_get_symbols
...

Average of running depmod 5 times, dropping caches between them, in a
slow spinning disk:

Before: 12.25 +- 0.20
After: 8.20 +- 0.21
m-i-t: 9.62 +- 0.27

So this patch leads to an improvement of ~33% over unpatched version,
ending up with 15% speedup over module-init-tools.
/external/kmod/libkmod/libkmod-module.c
6882017f809691d070e4df26414676d0219145d5 17-Aug-2012 Lucas De Marchi <lucas.demarchi@profusion.mobi> libkmod-module: Add KMOD_PROBE_APPLY_BLACKLIST_ALIAS_ONLY flag

With this flag kmod_module_probe_insert_module() check if module is
blacklisted only if it's also an alias. This is needed in order to allow
blacklisting a module by name and effectively blacklisting all its
aliases as module-init-tools was doing.

Before this patch we could load pcspkr module as follows:

/etc/modprobe.d/test.conf:
alias yay pcspkr
blacklist pcspkr

$ modprobe yay

Now libkmod has support to blacklist "yay" because "pcspkr" is blacklisted.
/external/kmod/libkmod/libkmod-module.c
486f901392e7eb6a5e8139785b9ff2ade5a547a8 28-Jun-2012 Dave Reisner <dreisner@archlinux.org> module: support reading coresize from /sys if supported

Linux 3.3 introduced the coresize attribute in /sys/module/*. When
available, use this instead of parsing some portion of /proc/modules.
/external/kmod/libkmod/libkmod-module.c
e7fc2c868e240b280f593934278cc719e33e90f7 12-Jun-2012 Lucas De Marchi <lucas.de.marchi@gmail.com> libkmod-config: refactor functions to get config

It makes more sense to have libkmod-config.c deal with the configuration
directly and the others get the config from ctx. As a bonus point we get
a smaller binary. Following numbers are for x86-64, libkmod + kmod:

Before:
text data bss dec hex filename
128840 1496 104 130440 1fd88 tools/modprobe

After:
text data bss dec hex filename
128392 1496 104 129992 1fbc8 tools/modprobe
/external/kmod/libkmod/libkmod-module.c
471a7d00893809be2bff6cd6cea83666fd4158af 14-Apr-2012 Kay Sievers <kay@vrfy.org> doc: silent man page generation and fix gtk-doc warnings
/external/kmod/libkmod/libkmod-module.c
49c6489d74f525e42ebffed4c5b1e52dbab913ab 03-Mar-2012 Lucas De Marchi <lucas.demarchi@profusion.mobi> Use upper case after Deprecated in doc
/external/kmod/libkmod/libkmod-module.c
9c5f057c7c5924ee3121bf1abbdca59544f8e4fc 01-Mar-2012 Lucas De Marchi <lucas.demarchi@profusion.mobi> Downgrade log message: refcnt file may not exist

If kernel doesn't have support to unload modules,
/sys/module/<modname>/refcnt will not exist and that's ok.

Reported by: Sven Anders <anders@anduras.de>
/external/kmod/libkmod/libkmod-module.c
bdda7e14d8ddf2b18cee85d677121a2d762e68a0 25-Feb-2012 Dave Reisner <dreisner@archlinux.org> find builtins by property, not initstate
/external/kmod/libkmod/libkmod-module.c
d80b103c63cef4b60874520d67f61f84f6a20355 24-Feb-2012 Dave Reisner <dreisner@archlinux.org> libkmod/module: add kmod_module_apply_filter method

This is a more generic method of applying filters to module lists. This
deprecates kmod_module_get_filtered_blacklist() which now simply returns
a call to _apply_filter with the extra filter enum arg.
/external/kmod/libkmod/libkmod-module.c
7cd664fbaead46b5f5ea4812cf9a7cbe6264eb7d 23-Feb-2012 Lucas De Marchi <lucas.demarchi@profusion.mobi> libkmod-module: don't treat "coming" as in-kernel

Running two instances of modprobe with the same module should both
succeed or both fail:

modprobe foo&; modprobe foo;

Previously if foo failed to be inserted by the first call, the second one
could return 0 because it may have occurred while the first one was being
processed by kernel (thus marked as "coming").

Now we simply don't check by "coming" in order to decide if we need to
call init_module(). module-init-tools used to spin calling
usleep(100000), but calls to init_module() are already synchronous.
Therefore let kernel synchronize the calls.
/external/kmod/libkmod/libkmod-module.c
abd5557bd178a1813faace87b585a316892c60ee 19-Feb-2012 Lucas De Marchi <lucas.demarchi@profusion.mobi> libkmod-module: probe: check if module exists for install cmds

Mimic what module-init-tools was doing before running install commands:
check if a module with the same name is already loaded in kerne, and if
it is, bail out.

This fixes the issue with some install commands used in Debian with
alsa-base package:

install snd /sbin/modprobe --ignore-install snd && { /sbin/modprobe --quiet snd-ioctl32 ; /sbin/modprobe --quiet snd-seq ; }
install snd_rawmidi /sbin/modprobe --ignore-install snd-rawmidi && { /sbin/modprobe --quiet snd-seq-midi ; : ; }
install snd_emu10k1 /sbin/modprobe --ignore-install snd-emu10k1 && { /sbin/modprobe --quiet snd-emu10k1-synth ; : ; }
install snd_pcm modprobe --ignore-install snd-pcm $CMDLINE_OPTS && { modprobe --quiet snd-pcm-oss ; : ; }
install snd_mixer modprobe --ignore-install snd-mixer $CMDLINE_OPTS && { modprobe --quiet snd-mixer-oss ; : ; }
install snd_seq modprobe --ignore-install snd-seq $CMDLINE_OPTS && { modprobe --quiet snd-seq-midi ; modprobe --quiet snd-seq-oss ; : ; }
/external/kmod/libkmod/libkmod-module.c
050db08c57c10cb964d337c5668c4dce309b8d41 18-Feb-2012 Lucas De Marchi <lucas.demarchi@profusion.mobi> Add missing newlines

Checked with following semantic patch for the library:

// smpl
@a@
identifier virtual.func;
expression E1;
expression fmt;
position p1;
@@

func(E1, fmt@p1, ...)

@script:python b@
fmt << a.fmt;
p1 << a.p1;
@@

s = str(fmt)
if s.find("\\n") < 0:
print p1[0].file + ":" + p1[0].line

// smpl

For tools, just remove E1
/external/kmod/libkmod/libkmod-module.c
3805274bf5e1e0acbd072ac7d523db8c8057130c 16-Feb-2012 Lucas De Marchi <lucas.demarchi@profusion.mobi> kmod-module: lookup: search modules.builtin file too

Search modules.builtin file before saying the module was not found.
Note: these "modules" should not appear as dependencies of other modules
(in modules.dep) even if they appear in modinfo. This fixes the return
code of modprobe with builtin modules.

Also fixes a small coding style issue in module_is_inkernel().
/external/kmod/libkmod/libkmod-module.c
8cd0f9e4f9f5c093136a7a2c0c2998b9dd203161 11-Feb-2012 Lucas De Marchi <lucas.demarchi@profusion.mobi> libkmod-module: probe: fix infinite loop with softdeps

If a softdep depends on a module in the dependency list of the module
being inserted, we would enter and infinite loop.

Move the "mod->visited = true" assignment to the proper place, hoping it
didn't break other use cases. This is a bug that comes and goes every
now and then. Since we have a testsuite now, a test for this should be
written.
/external/kmod/libkmod/libkmod-module.c
269de2e0bf5011072da2f40f4f2d4023fad696b9 07-Feb-2012 Lucas De Marchi <lucas.demarchi@profusion.mobi> libkmod-module: probe: Fix ignore-loaded flag not being applied
/external/kmod/libkmod/libkmod-module.c
08600ee579d9be4b54ee5ac56ce13706b3cfecf4 06-Feb-2012 Lucas De Marchi <lucas.demarchi@profusion.mobi> libkmod-module: probe: return -EEXIST if told to do so

Commit "af9572c lib/module: check initstate before inserting module"
removed the check for "we should return -EEXIST" and moved it back to
the start of the function. The problem with this is the following
scenario:

- We check if module is in kernel -> no
- We insert the dependencies
<-- External program loads
the module
- We check if module is in kernel -> yes
- We return 0, when we should return -EEXIST
/external/kmod/libkmod/libkmod-module.c
814a57babfffb62a19ddeceb7949d601f1147fa9 06-Feb-2012 Lucas De Marchi <lucas.demarchi@profusion.mobi> libkmod-module: probe: rename flag to be more meaningful
/external/kmod/libkmod/libkmod-module.c
9a252c218a5df58edae4039f8ad8d0a077c91a18 04-Feb-2012 Dan McGee <dan@archlinux.org> Fix simple grammar issue
/external/kmod/libkmod/libkmod-module.c
af9572c6d7288515623d2b85204cb97eb5c7b151 02-Feb-2012 Dave Reisner <dreisner@archlinux.org> lib/module: check initstate before inserting module

This applies to both the high level probe_insert_module() and the
underlying insert_module() functions. By checking module initstate prior
to inserting a module, we can avoid a lot of needless work just to find
out that the init_module call fails with EEXIST.

This implements a helper function, module_is_inkernel, to return a
boolean value describing if a module is live, coming, or builtin.
/external/kmod/libkmod/libkmod-module.c
7bede7b6a8a75841a09478e59efbc39677b8d1d2 02-Feb-2012 Dave Reisner <dreisner@archlinux.org> whitespace fix -- no logical code changes
/external/kmod/libkmod/libkmod-module.c
7aed46088e9351a68ede14e8b9037f16289ff270 31-Jan-2012 Lucas De Marchi <lucas.demarchi@profusion.mobi> libkmod-module: probe: remove useless KMOD_PROBE_STOP_ON_COMMAND
/external/kmod/libkmod/libkmod-module.c
3bc92e8949146cb57e6eecfb954a6efe114a041a 31-Jan-2012 Lucas De Marchi <lucas.demarchi@profusion.mobi> libkmod-module: probe: return -EEXIST if told to stop on already loaded
/external/kmod/libkmod/libkmod-module.c
4c1ffb75d4efe799162a7780498246a8b94585fb 30-Jan-2012 Lucas De Marchi <lucas.demarchi@profusion.mobi> libkmod-module: probe: add flag to dry-run
/external/kmod/libkmod/libkmod-module.c
7c10c69c72a5639048d75b681395ecf72193ba7f 30-Jan-2012 Lucas De Marchi <lucas.demarchi@profusion.mobi> libkmod-module: probe: add flag to ignore loaded modules

We need a way to tell libkmod to ignore loaded modules, so modprobe can
tell it to dry-run and show dependencies. However there's a conflict
with two flags. KMOD_PROBE_STOP_ON_ALREADY_LOADED prevails if passed
together with KMOD_PROBE_IGNORE_LOADED.
/external/kmod/libkmod/libkmod-module.c
6bd0713deb6be5922b419c6a73361843b8497025 30-Jan-2012 Lucas De Marchi <lucas.demarchi@profusion.mobi> libkmod-module: probe: add print_action callback

This allows to implement dry-run in modprobe without exporting
kmod_module_get_probe_list().
/external/kmod/libkmod/libkmod-module.c
79d6c7d7642c832feeffefc4e68e58cf76e50ded 30-Jan-2012 Lucas De Marchi <lucas.demarchi@profusion.mobi> libkmod-module: probe: remove useless flag to stop on failure

We always want to stop if module failed to loaded due to unknown reason.
/external/kmod/libkmod/libkmod-module.c
5f3514731ef82084c1a24b15445e0f1352681a19 30-Jan-2012 Lucas De Marchi <lucas.demarchi@profusion.mobi> libkmod-module: probe: add flag to stop loading on already loaded

It's not as simple as tell user to check if the module is loaded before
calling this function. Due to race conditions, module might not be
loaded before the function call, but fail later because another process
inserted it.
/external/kmod/libkmod/libkmod-module.c
9c7f3ad0a4fe4edb9cdef3db6f8d0d9be4483e3d 29-Jan-2012 Lucas De Marchi <lucas.demarchi@profusion.mobi> libkmod-module: split creation of new modules to share code

Share code of module creation among the several new functions. With this
we let the alias/modname/path parsing to the separate functions, and the
rest with the common one.

This fixes the issue of alias names not being able to contain dots.
/external/kmod/libkmod/libkmod-module.c
89e92487bc53cbb41c7d401d9a580b3009b2f711 29-Jan-2012 Lucas De Marchi <lucas.demarchi@profusion.mobi> libkmod-module: probe: add flag to ignore commands
/external/kmod/libkmod/libkmod-module.c
b1a51256a9ed581cac9a3887ddb6aa316e8dbcd5 29-Jan-2012 Lucas De Marchi <lucas.demarchi@profusion.mobi> libkmod-module: probe: change insertion to cover more use cases

Split kmod_module_probe_insert_module() in 2:
1) Get list of modules to be loaded
2) Iterate the list, loading the module

With this in future we will be able to cover use cases of modprobe,
that has a logic a bit more complicated.

With this we also change the logic to detect dependency loops: instead
of checking the recursion every STEP times, we now keep a field in
kmod_module, marking it as visited. We simply ignore already visited
modules and thus we break loops.
/external/kmod/libkmod/libkmod-module.c
ece09aac7f516549c6f14b7af68cd9c24d709b68 18-Jan-2012 Lucas De Marchi <lucas.demarchi@profusion.mobi> libkmod-module: add visited field

This field can be used to iterate the modules, controlling whether we
are revisiting a certain module. A function to clear the values in all
modules is needed since when we are iterating, we don't know if the
module is created anew or if it's picked from the pool. Therefore we
can't know if the field is true because of a previous iteration or if
the module was indeed already visited.
/external/kmod/libkmod/libkmod-module.c
eff917c0d24e8189a98f41d186e7b17e269578a7 17-Jan-2012 Thierry Vignaud <thierry.vignaud@gmail.com> WEXITSTATUS is defined in sys/wait.h

Fix compiling with dietlibc:

../libkmod/libkmod-module.c:858:2: warning: implicit declaration of function 'WEXITSTATUS' [-Wimplicit-function-declaration]
../libkmod/libkmod-module.c:858:2: warning: nested extern declaration of 'WEXITSTATUS' [-Wnested-externs]
(...)
kmod-modprobe.c:(.text.command_do+0x157): undefined reference to `WEXITSTATUS'
/external/kmod/libkmod/libkmod-module.c
ba998b9c9ecaf8433325446892d6f80aecbdae39 11-Jan-2012 Lucas De Marchi <lucas.demarchi@profusion.mobi> Fix error code returned on module removal
/external/kmod/libkmod/libkmod-module.c
6681951bbeb04f7b5c08e49da81a0da6f2aca2d2 09-Jan-2012 Lucas De Marchi <lucas.demarchi@profusion.mobi> doc: organize sections
/external/kmod/libkmod/libkmod-module.c
db74ceec8030e7e3b069c4a226b3557c6933f735 09-Jan-2012 Lucas De Marchi <lucas.demarchi@profusion.mobi> doc: fix broken links to other functions
/external/kmod/libkmod/libkmod-module.c
a66a6a999f0156f5c43bc51660300f9a7466986f 09-Jan-2012 Lucas De Marchi <lucas.demarchi@profusion.mobi> Update copyright
/external/kmod/libkmod/libkmod-module.c
6daceb2f1f4d442ba04752aaa1cf43d554d5f646 08-Jan-2012 Lucas De Marchi <lucas.demarchi@profusion.mobi> 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.
/external/kmod/libkmod/libkmod-module.c
b787b5693d54747ea7d3a70a318662e907021604 04-Jan-2012 Dave Reisner <dreisner@archlinux.org> libkmod: Fix casing in error output
/external/kmod/libkmod/libkmod-module.c
c68e92f73133d4220bc6dfe1ca960cf58da7a4b3 04-Jan-2012 Lucas De Marchi <lucas.demarchi@profusion.mobi> file: take a weakref to ctx
/external/kmod/libkmod/libkmod-module.c
4926cb501d1dfeb19f9cb7788ea26d91d2ee6e47 31-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> 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.
/external/kmod/libkmod/libkmod-module.c
0d46743ca50e6005843d13b012db96ae7e7b2c57 31-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Move function to the right place
/external/kmod/libkmod/libkmod-module.c
e47c604525611397ee3172d8a20fab2043dd9564 30-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Ignore "already loaded" error in module_probe_insert_module()

It also fixes a leak in the error path.
/external/kmod/libkmod/libkmod-module.c
bbf59327e397f3a5dd810cb044e1823d3b17653e 30-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> 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.
/external/kmod/libkmod/libkmod-module.c
a4848e249f4bf2845e17cbb35a519b2b567f3710 27-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Move util functions to libkmod-util.c

These allow them to be later shared with tools.
/external/kmod/libkmod/libkmod-module.c
ebaa7beb0a1be07b154e3ec9adba15d9cb2d7ca1 27-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Log paths if kmod_module_new_from_path() failed
/external/kmod/libkmod/libkmod-module.c
ddbda02286f3b8fa58fb587403f2f9f0e9b4a147 27-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> 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.
/external/kmod/libkmod/libkmod-module.c
2bd7cbf64409f11497a6bfb6d1d998a869783a95 27-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Do not cache softdeps list

This might include a circular dependency which would screw up the
refcounting because there's an internal reference.
/external/kmod/libkmod/libkmod-module.c
b72f74b5dd17daf6d52672f26fbd8051fd106789 27-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Allow to internally get dependencies without copying list
/external/kmod/libkmod/libkmod-module.c
b94a737935d8dcb515194705a1ac1f82ebc82889 26-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> 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.
/external/kmod/libkmod/libkmod-module.c
674f8590e3aac67e0decd3da41407091c2d6a8d5 20-Dec-2011 Gustavo Sverzut Barbieri <barbieri@profusion.mobi> 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.
/external/kmod/libkmod/libkmod-module.c
45e6db9c016b7802f2013b22ad63e7005f5683ef 20-Dec-2011 Gustavo Sverzut Barbieri <barbieri@profusion.mobi> 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.
/external/kmod/libkmod/libkmod-module.c
f304afe1539fd71dbeac75c224072f48646545a8 21-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Change error message to reflect reality
/external/kmod/libkmod/libkmod-module.c
142db570bfa527e31807e3b21ec7d7795463c5c9 21-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Update doc to reflect function behavior
/external/kmod/libkmod/libkmod-module.c
9efaf2f6275ced585623e59fbfcddf20d9f69f08 20-Dec-2011 Luis Felipe Strano Moraes <lfelipe@profusion.mobi> Testing for return of alias_normalize.
/external/kmod/libkmod/libkmod-module.c
b55df2ee0313da8c42605d9570da1d5c8e901132 20-Dec-2011 Gustavo Sverzut Barbieri <barbieri@profusion.mobi> kmod_module_new_*: improve debugging.
/external/kmod/libkmod/libkmod-module.c
708624a4ebffc515da2f9e2fdbdce79fc9c0aaaf 18-Dec-2011 Gustavo Sverzut Barbieri <barbieri@profusion.mobi> ELF: initial support for modinfo and strip of modversions and vermagic.

Needs testing, but should work.
/external/kmod/libkmod/libkmod-module.c
9dec24462d5bdf0ed852493f28b81757f863ef48 18-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Fix wrong name len when converting path to modname
/external/kmod/libkmod/libkmod-module.c
a6bf2495f6738c6a06028678e652f271bca8fc47 17-Dec-2011 Gustavo Sverzut Barbieri <barbieri@profusion.mobi> 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.
/external/kmod/libkmod/libkmod-module.c
1c52260048792561160a75a2ce62217e98cd381a 17-Dec-2011 Gustavo Sverzut Barbieri <barbieri@profusion.mobi> implement softdeps.
/external/kmod/libkmod/libkmod-module.c
3d8226edfea12b951f6e257b087ec7453135ed10 16-Dec-2011 Gustavo Sverzut Barbieri <barbieri@profusion.mobi> implement zlib module loading.
/external/kmod/libkmod/libkmod-module.c
f4fc55236815514fe44cc9258a1b42af1383f5a1 16-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> 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"'
/external/kmod/libkmod/libkmod-module.c
60f6760e73cac29c04c3568109dd2df92758eda7 16-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> 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.
/external/kmod/libkmod/libkmod-module.c
8e3e5839a0d65e7a779d4130f9ece02fa88af7e2 16-Dec-2011 Cristian Rodríguez <crrodriguez@opensuse.org> Open more file descriptors with O_CLOEXEC
/external/kmod/libkmod/libkmod-module.c
79e5ea91e04e96bdfde63b02c6859128e9b0a8ad 16-Dec-2011 Cristian Rodríguez <crrodriguez@opensuse.org> Library must use O_CLOEXEC whenever it opens file descriptors
/external/kmod/libkmod/libkmod-module.c
4084c176c1504397d0f66bd404799f7b2da92058 15-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> 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.
/external/kmod/libkmod/libkmod-module.c
818f8e8ad58f51074b356580c18d451f5dea7d5a 15-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Add safety NULL checks in exported functions
/external/kmod/libkmod/libkmod-module.c
8bdeca11b14c2e1350b018386b9b91aa1a52dfcb 15-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> 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 <------------------*---'
/external/kmod/libkmod/libkmod-module.c
91428ae1b8d1de1bc5300edb59268bb40ef49ec7 15-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Fix docs with wrong function names
/external/kmod/libkmod/libkmod-module.c
113c66a56290f68d55364f8d6f01aa5cbd02d514 14-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> 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.
/external/kmod/libkmod/libkmod-module.c
788ef0f7e69a766aa8d94b852d46fd0786233ddc 14-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Use malloc + memset instead of calloc
/external/kmod/libkmod/libkmod-module.c
2d7bab5c7d5be08bd68190e2cc77e3a816b8d95b 14-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> kmod_module: move function to the right section
/external/kmod/libkmod/libkmod-module.c
63af0615d50016c92bf856e451673cc749acb916 14-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> kmod_module: fix log message upon module removal
/external/kmod/libkmod/libkmod-module.c
7afc98a1f6f095258b2a0baef6cc3d91990b2227 14-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> kmod_module: add missing documentation
/external/kmod/libkmod/libkmod-module.c
07b8c823ed4b8ff8e3a6b09f1f2f4d81fcf4be78 13-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> kmod_module: make get_options() search for alias names too
/external/kmod/libkmod/libkmod-module.c
6ad5f2636249bc1ceeab81325284686815aa7fbe 13-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Add private function kmod_module_new_from_alias()

This function will create a new kmod_module() by calling
kmod_module_new_from_name(), but instead of given the module name, it
gives the alias. This way, the modules' hash will contain the alias
instead of the name. If module was created successfully, then it swap
the alias with the actual name.

The downside is that the structure is not shared anymore if we create a
kmod_module by alias and after by name. However, in modprobe's
configuration it's possible to have different options for different
aliases. In future we might want to create a way to share the common
part of the structure (then having only one instance as we had before).
/external/kmod/libkmod/libkmod-module.c
219f9c38bb283f6173ed37d1eb54671e1ca52349 13-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> kmod_module: use pointer instead of vector for its name

We still have name allocated just after the struct kmod_module, but
now we use a pointer instead of putting name as a vector in the end of
the structure.

The previous way has some problems, the worst is:
- it's not possible to swap the name with another value: this is
the real problem that this patch is solving. Later patches
will make name be swappable with alias, which is not possible
if name is a vector.
/external/kmod/libkmod/libkmod-module.c
d470db10a3a319d638522ed19963c64db4df41bb 13-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Use alias_normalize() instead of modname_normalize()

When normalizing alias names (or if we don't know if it's an alias or
modname), use alias_normalize() instead of modname_normalize(). The
difference is that alias names can contain dashes withing brackets, and
those should not be changed to underscores.

Most of the places using underscores() function might be converted to
alias_normalize(), but this is not done now.
/external/kmod/libkmod/libkmod-module.c
4308b176e9e7f58c62c181ea596b92e04622a852 13-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Fix check for NULL variable
/external/kmod/libkmod/libkmod-module.c
973c80ba7c4e38f1d4fb54ae9258b1977b3c3f12 12-Dec-2011 Gustavo Sverzut Barbieri <barbieri@profusion.mobi> handle case where modname was not detected.
/external/kmod/libkmod/libkmod-module.c
cb451f35d9fe25ec1dee0628f8af23f022358f6b 12-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Change licenses

libkmod is under LGPL 2.1 or later
tools/* are under GPL
/external/kmod/libkmod/libkmod-module.c
45f277817489b9373a89ce43f8c3628330fd38b0 12-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Remove warnings: ‘err’ may be used uninitialized in this function
/external/kmod/libkmod/libkmod-module.c
970ba8be9dc0b390e56a20ed3fa11482e05d851c 12-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Remove leftover comment

mod->path is always absolute: remove comment from previous behavior.
/external/kmod/libkmod/libkmod-module.c
49ce6d074199d5c0c2532cb6a636b6a368871917 12-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Remove libkmod-loaded.c and re-order functions in libkmod-module.c

It's not possible to move functions related to "live" modules to
libkmod-loaded.c because they depend on the definition of kmod_module.
Putting this structure in the private header is not a good idea, so let
all functions related to "live" information in the end of
libkmod-module.c, and move the sole function from libkmod-loaded.c to
this place. This way all functions get the right documentation
about their sections.
/external/kmod/libkmod/libkmod-module.c
28c175edd10eb778c706fb133a40150cf1a58054 12-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> coding style: be consistent with blank lines
/external/kmod/libkmod/libkmod-module.c
c35347f15cf0ed71a0929ddb0a0d8e2de5f73de8 12-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> 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
/external/kmod/libkmod/libkmod-module.c
d01c67e38334ca5aa62e6c645e416d4989696294 11-Dec-2011 Gustavo Sverzut Barbieri <barbieri@profusion.mobi> add missing newline to log messages.
/external/kmod/libkmod/libkmod-module.c
926f67a6d6f86e76d568309262bffdb226ba85ef 11-Dec-2011 Gustavo Sverzut Barbieri <barbieri@profusion.mobi> be less verbose on initstate for unexistent modules.

the module may be unloaded, in this case -NOENT is returned but it
should not present an error message
/external/kmod/libkmod/libkmod-module.c
3a721bbcf02217e11b214a479f15529669d05339 11-Dec-2011 Gustavo Sverzut Barbieri <barbieri@profusion.mobi> insmod: allows providing option to module.
/external/kmod/libkmod/libkmod-module.c
d917f2743e13e405f7042a31f9e3754f3e95da0e 11-Dec-2011 Gustavo Sverzut Barbieri <barbieri@profusion.mobi> always normalize user-given alias.
/external/kmod/libkmod/libkmod-module.c
bd3f5535268836aa697f84fa6946e4b0fc22df0b 10-Dec-2011 Gustavo Sverzut Barbieri <barbieri@profusion.mobi> 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.
/external/kmod/libkmod/libkmod-module.c
b6a534f72c66b489a6dbc71468db9eb609c3c8bb 10-Dec-2011 Gustavo Sverzut Barbieri <barbieri@profusion.mobi> parse_depline may be called from libkmod.c

allow parse_depline to be called when already initialized as it may be
called from libkmod.c and at that point there is no way to check
mod->init.dep
/external/kmod/libkmod/libkmod-module.c
e18ad35c640d67484d96c1ab71253ba1f69cc805 08-Dec-2011 Gustavo Sverzut Barbieri <barbieri@profusion.mobi> fix path handling at dependencies parsing.

paths come relative to dirname, make them absolute to avoid confusion
later.
/external/kmod/libkmod/libkmod-module.c
e1a6b30dc495c46c14fd9ed7b7a1807858d0d08e 08-Dec-2011 Gustavo Sverzut Barbieri <barbieri@profusion.mobi> modname_normalize: fix const and buffer overflow.

"buf[NAME_MAX] = value" is invalid since it would access the byte
right after the array.

Also fix the const of modname, do not mess with it to avoid mistakes.
/external/kmod/libkmod/libkmod-module.c
f1fb6f8525f12f3a9664527475e4e2cb26d75207 08-Dec-2011 Gustavo Sverzut Barbieri <barbieri@profusion.mobi> kmod_module: Remove const from path

It's an ugly hack. This is an internal variable, we know we shouldn't
change it everywhere.
/external/kmod/libkmod/libkmod-module.c
e005facdb9bc99a3aacb55c23260464fb31e25d0 08-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Only search path in moddep if it's not already set

rmmod/insmod should be able to operate directly on files, not relying on
indexes and configuration.

The following test was not working and now it is:

$ # go to a dir != mod->dirname
$ cd /lib/modules/$(uname -r)/kernel
$ # try to insert module giving a relative path
$ insmod drivers/acpi/ac.ko
/external/kmod/libkmod/libkmod-module.c
6bd0b8d01df7912cd6a7f209db822feff393b59f 07-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> kmod_module: treat module creation by path with same names

If a module with the same name already exists, try to reference it if
paths are the same. Otherwise fail.
/external/kmod/libkmod/libkmod-module.c
71e975cd4d73fcebb3772ac18a8a231830bd9b43 07-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> kmod_module: store absolute path when creating module from path
/external/kmod/libkmod/libkmod-module.c
877e80cd934951c02b437fd81c5a2609c20176be 07-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Use streq() when possible
/external/kmod/libkmod/libkmod-module.c
6c343b1aeecd8bdcb8aeaa186b6d1075d8ce785d 06-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Split function so we don't call basename() unnecessarily
/external/kmod/libkmod/libkmod-module.c
fd186ae9965d1c43c65435af29ee06648c30e06c 06-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Maintain a pool of modules alive

Based on previous implementation by
Gustavo Sverzut Barbieri <barbieri@profusion.mobi>
/external/kmod/libkmod/libkmod-module.c
4f2bb7cdd4c0b77f09f6f79b2c92683fdcdfa163 06-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> kmod_module: normalize module name
/external/kmod/libkmod/libkmod-module.c
c5e7b1f7efd64c5baf6eecbac9b68a8447552f5b 05-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> kmod_module: get path on demand
/external/kmod/libkmod/libkmod-module.c
671d489424df4b8b982a91b9d16badd338df0f0b 05-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> kmod_module: parse dependencies on demand
/external/kmod/libkmod/libkmod-module.c
f1cd799fb0a8e4d2859189b85480cdb5668db72a 05-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> kmod_module: return a new list and increase ref of dependencies

kmod_module_get_dependency is renamed to kmod_module_get_dependencies
since it's returning a list. To match other APIs, now it returns a new
list that user must free with kmod_module_unref_list().
/external/kmod/libkmod/libkmod-module.c
d753b8ca35175fc9ef2d19e6ee3fecd2e6722d74 05-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> kmod_module: inline name and make it always available
/external/kmod/libkmod/libkmod-module.c
40923bdb64459a5eee9d467563ffe9e661d803fe 05-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Use readdir_r in kmod_module_get_sections()

readdir() is not thread-safe. Use readdir_r instead.
/external/kmod/libkmod/libkmod-module.c
53886ddd87bc78492c4e0a6a6f117bfdf1835fac 05-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Use readdir_r in kmod_module_get_holders()

readdir() is not thread-safe. Use readdir_r instead.
/external/kmod/libkmod/libkmod-module.c
69f9dd4369ec9945b3ca3f4aea800fdb027f47da 04-Dec-2011 Gustavo Sverzut Barbieri <barbieri@profusion.mobi> no more kmod_loaded and kmod_loaded_module.

kmod_loaded_get_list() now returns a regular list of kmod_modules, use
kmod_module_get_module(), kmod_module_unref() and
kmod_module_unref_list() to operate on it.
/external/kmod/libkmod/libkmod-module.c
f12ae3c438e845c0d895de99871db30e88baa1ca 04-Dec-2011 Gustavo Sverzut Barbieri <barbieri@profusion.mobi> kmod_module: extended information gathering.

provide means to get:
* refcount
* initstate
* holders
* sections

this can be used to individually query properties from modules,
similar to /proc/modules (kmod_loaded / kmod_loaded_module).
/external/kmod/libkmod/libkmod-module.c
ad4d1ae5654a8954f462cd2833d77c4a66b76391 04-Dec-2011 Gustavo Sverzut Barbieri <barbieri@profusion.mobi> kmod_module_get_module: safety against NULL pointers
/external/kmod/libkmod/libkmod-module.c
87ca03bd0776e863a9d51f20129151137a2c8691 04-Dec-2011 Gustavo Sverzut Barbieri <barbieri@profusion.mobi> module refcount should start at 1.

the current way was having the referenced modules to be released given
the unref comparison checking for "> 0".
/external/kmod/libkmod/libkmod-module.c
8d3f3ef815cf9012ad54a0e0bda21aed8e7afa33 03-Dec-2011 Gustavo Sverzut Barbieri <barbieri@profusion.mobi> reorder struct fields to avoid holes, improving packing
/external/kmod/libkmod/libkmod-module.c
1ce08a563e4ff4a9bcae7a1514f1159232a16f71 02-Dec-2011 Gustavo Sverzut Barbieri <barbieri@profusion.mobi> 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.
/external/kmod/libkmod/libkmod-module.c
84f4220440c2428a24bde9f530b15e2758ccdb62 02-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Fix missing return
/external/kmod/libkmod/libkmod-module.c
1fc1c9a06f533788e25571d2b0fc6887b2062381 02-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Clean 'shadowed declaration' warnings
/external/kmod/libkmod/libkmod-module.c
b418a82097f666a87601b35572495e0f2fbcb1a3 02-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Use fstat() instead of stat() when possible
/external/kmod/libkmod/libkmod-module.c
0835fc3bf9e5b89e2581f97e2bf5505c34e52c7f 01-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Add fucntion to API to get dependencies
/external/kmod/libkmod/libkmod-module.c
7636e72b1575d8544e470cb94654605013815a6d 01-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Add dependency list to kmod_module

Dependency list is created from line as defined in modules.dep.
/external/kmod/libkmod/libkmod-module.c
9eaad1f63aecf743b6aa6f1191c43f72b2d52d38 01-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Allow path_to_modname to operate locally withou alloc
/external/kmod/libkmod/libkmod-module.c
49e61ca347b302c1558bbe40add16eb4b6076af0 01-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Lookup for alias in modules.alias.bin
/external/kmod/libkmod/libkmod-module.c
64700e4747d4331a8c833f234246128b9069a888 01-Dec-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Lookup modules from modules.dep.bin file
/external/kmod/libkmod/libkmod-module.c
9ba6f57b5b398fe81f33df825eaa03c642342c26 30-Nov-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Lookup modules.symbols.bin

Test in my system:

./test/test-lookup symbol:sas_slave_destroy
libkmod version 0.1
Alias: 'symbol:sas_slave_destroy'
Modules matching:
libsas
/external/kmod/libkmod/libkmod-module.c
839d7dadf68ebe536c58ffc232bb343c60994099 30-Nov-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Remove dangling comment
/external/kmod/libkmod/libkmod-module.c
b14dcfdab3acc6e67ad97bbf1439333bcdf0357a 30-Nov-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Prepare lookup function for more files to look after
/external/kmod/libkmod/libkmod-module.c
7f3eb0cced7fc97b8ff1313e046b00e9e62c57bf 30-Nov-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Add lookup to create modules list from alias

We return a kmod_list when searching for an alias. Right now, it only
search for aliases in config files.

To use it, we create a list:
list = NULL;
kmod_module_new_from_lookup(..., &list);

And iterate over it to get the modules and their details:

kmod_list_foreach(l, list) {
struct kmod_mod *mod = kmod_module_get_module(l);
...
... kmod_module_get_name(mod);
... kmod_module_get_path(mod);
}

Aliases might contain globs and are match by using fnmatch().
/external/kmod/libkmod/libkmod-module.c
6e869df73d0ce9df84098acd58d6e9ebc1309fe6 30-Nov-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Add name() and path() getters for kmod_module
/external/kmod/libkmod/libkmod-module.c
191ab4b9e0ae8d1fe9d6377adb8e28fa7f746d60 28-Nov-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Fix wrong copyright

I'm the author, not the copyright owner.
/external/kmod/libkmod/libkmod-module.c
1b2e26a1e2f5ec0e9d1abf0e564e80cbd7edcc03 25-Nov-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Back to logging without \n

It possibly breaks when not logging to stderr
/external/kmod/libkmod/libkmod-module.c
8f788d58c3c58f0559b32fe896a00c35dc58c01e 25-Nov-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Add functions to operate on modules
/external/kmod/libkmod/libkmod-module.c