]> git.ipfire.org Git - thirdparty/kmod.git/log
thirdparty/kmod.git
10 years agoAdd travis-ci config file
Lucas De Marchi [Tue, 30 Apr 2013 03:21:21 +0000 (00:21 -0300)] 
Add travis-ci config file

Experiment with a build bot.

10 years agolibkmod: Avoid calling syscall() with -1
Jan Luebbe [Thu, 2 May 2013 14:47:12 +0000 (16:47 +0200)] 
libkmod: Avoid calling syscall() with -1

At least in qemu 1.4.1 for vexpress/arm-cortexa9, this resulted in an
illegal instruction error. Solve that by returning an error when
__NR_finit_module is -1.

10 years agoRevert "missing: Don't call syscall() with syscallno == -1"
Lucas De Marchi [Sat, 11 May 2013 03:50:32 +0000 (00:50 -0300)] 
Revert "missing: Don't call syscall() with syscallno == -1"

This reverts commit 38829712e5c411bc250aeae142fc6bf06e794d58.  It fixes
the problem, but it breaks the testsuite for those who don't have
__NR_finit_module. The testsuite would have to make the same check.

Instead, I'm reverting this change and I'm going to apply another patch
from Jan Luebbe who got this right from the beginning.

10 years agoAdd document for exported enums
Chengwei Yang [Sat, 4 May 2013 09:07:03 +0000 (17:07 +0800)] 
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<----------

10 years agoSeveral minor fixes for documentation
Chengwei Yang [Sat, 4 May 2013 09:07:02 +0000 (17:07 +0800)] 
Several minor fixes for documentation

11 years agomodprobe: don't check refcount with remove command
Johannes Berg [Thu, 2 May 2013 13:23:28 +0000 (15:23 +0200)] 
modprobe: don't check refcount with remove command

The modprobe.d (5) documentation for the "install" command
states that you could specify

install fred /sbin/modprobe barney; /sbin/modprobe --ignore-install fred

This makes some sense, but then the loading of "barney" is
hidden from the user who did only "modprobe fred". Thus,
it seems it should be possible to be able to unload the
"fred" module with "modprobe -r fred" by configuring the
"barney" module to also be removed:

remove fred /sbin/rmmod barney fred

(or similar.)

Make this possible by not checking the refcount when an
unload command was configured.

Reported-by: David Spinadel <david.spinadel@intel.com>
11 years agomissing: Don't call syscall() with syscallno == -1
Lucas De Marchi [Thu, 2 May 2013 16:22:57 +0000 (13:22 -0300)] 
missing: Don't call syscall() with syscallno == -1

Reported-by: Jean-Francis Roy <jeanfrancis@funtoo.org>
Reported-by: Jan Luebbe <jlu@pengutronix.de>
11 years agoFix coding style
Lucas De Marchi [Tue, 30 Apr 2013 15:34:55 +0000 (12:34 -0300)] 
Fix coding style

Either with space or without, not a mix of both.

11 years agoTODO: Add some entries
Lucas De Marchi [Tue, 30 Apr 2013 15:34:23 +0000 (12:34 -0300)] 
TODO: Add some entries

11 years agolibkmod-index: Return early if readroot failed
Lucas De Marchi [Wed, 24 Apr 2013 00:21:00 +0000 (21:21 -0300)] 
libkmod-index: Return early if readroot failed

11 years agolibkmod-module: Don't pass NULL ctx to kmod_log
Lucas De Marchi [Tue, 23 Apr 2013 23:47:28 +0000 (20:47 -0300)] 
libkmod-module: Don't pass NULL ctx to kmod_log

11 years agolibkmod-module: Don't pass NULL pointer to memcpy
Lucas De Marchi [Tue, 23 Apr 2013 23:33:13 +0000 (20:33 -0300)] 
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).

11 years agobuild-sys: Add AM_V_XSLT to rule creating man pages
Lucas De Marchi [Sun, 21 Apr 2013 19:33:54 +0000 (16:33 -0300)] 
build-sys: Add AM_V_XSLT to rule creating man pages

11 years agoAdd format attribute and fix issues
Lucas De Marchi [Sun, 21 Apr 2013 19:16:18 +0000 (16:16 -0300)] 
Add format attribute and fix issues

Add __attribute__((format)) to log_filep() and _show() functions, fixing
the bugs they found in the source code.

For functions that receive va_list instead of being variadic functions
we put 0 in the last argument, so at least the string is checked and we
get warnings of -Wformat-nonliteral type. So, it's better than adding a
pragma here to shut up the warning.

11 years agostatic-nodes: Fix indentation
Lucas De Marchi [Fri, 19 Apr 2013 22:08:43 +0000 (19:08 -0300)] 
static-nodes: Fix indentation

kmod uses tab instead of spaces and tries to honour 80chr limit, when
that doesn't worsen the readability.

11 years agostatic-nodes: tmpfiles - also create parents directories of device nodes
Tom Gundersen [Fri, 19 Apr 2013 21:53:35 +0000 (23:53 +0200)] 
static-nodes: tmpfiles - also create parents directories of device nodes

Before:

c /dev/cpu/microcode 0600 - - - 10:184
c /dev/fuse 0600 - - - 10:229
c /dev/btrfs-control 0600 - - - 10:234
c /dev/loop-control 0600 - - - 10:237
c /dev/snd/timer 0600 - - - 116:33

After:

d /dev/cpu 0755 - - -
c /dev/cpu/microcode 0600 - - - 10:184
c /dev/fuse 0600 - - - 10:229
c /dev/btrfs-control 0600 - - - 10:234
c /dev/loop-control 0600 - - - 10:237
d /dev/snd 0755 - - -
c /dev/snd/timer 0600 - - - 116:33

11 years agokmod: It's an error not to have modules.devname
Lucas De Marchi [Wed, 17 Apr 2013 03:54:17 +0000 (00:54 -0300)] 
kmod: It's an error not to have modules.devname

This file is created by depmod even if there's no node. In this case it
will be empty.

Previously 'kmod static-nodes' was segfaulting due to passing in==NULL
to fgets.

Also show the error message with %m.

11 years agotools: add static-nodes tool
Tom Gundersen [Tue, 16 Apr 2013 20:39:55 +0000 (22:39 +0200)] 
tools: add static-nodes tool

This tool reads modules.devname from the current kernel directory and outputs
the information. By default in a human-readable format, and optionally in
machine-readable formats.

For now only the tmpfiles.d(5) format is supported, but more could easily be
added in the future if there is a need.

This means nothing but kmod needs to reads the private files under
/lib/modules/. In particular systemd-udevd can stop reading modules.devname.

Tools that used to read /lib/modules/`uname -r`/modules.devname directly, can
now move to reading 'kmod static-nodes devname'.

11 years agoUse static assertions for sizeof checks
Lucas De Marchi [Mon, 15 Apr 2013 17:14:07 +0000 (14:14 -0300)] 
Use static assertions for sizeof checks

11 years agoUse _Static_assert
Lucas De Marchi [Mon, 15 Apr 2013 17:09:05 +0000 (14:09 -0300)] 
Use _Static_assert

Both GCC and clang already supports C11's _Static_assert, so use it
instead of defining our own macro.

11 years agotestsuite: errno is a positive number
Lucas De Marchi [Fri, 12 Apr 2013 04:24:30 +0000 (01:24 -0300)] 
testsuite: errno is a positive number

11 years agoTODO: update and reorder
Lucas De Marchi [Tue, 9 Apr 2013 23:20:38 +0000 (20:20 -0300)] 
TODO: update and reorder

11 years agokmod 13 v13
Lucas De Marchi [Tue, 9 Apr 2013 22:35:32 +0000 (19:35 -0300)] 
kmod 13

11 years agobuild-sys: Always enable parallel tests
Lucas De Marchi [Tue, 9 Apr 2013 14:59:33 +0000 (11:59 -0300)] 
build-sys: Always enable parallel tests

Automake < 1.13 doesn't enable parallel tests by default, so add it to our
automake options.

11 years agotestsuite: Fix checking __sysno
Lucas De Marchi [Tue, 9 Apr 2013 14:54:05 +0000 (11:54 -0300)] 
testsuite: Fix checking __sysno

Use an if instead of a case statemente. If __NR_finit_module is not
defined in system headers we define it to -1, causing a "duplicate case
value" error. Yet, we don't want to actually call our finit_module()
function if -1 is passed.

This also fix errno being set with negative value.

11 years agotestsuite: Wrap syscall() to get calls to finit_module()
Lucas De Marchi [Tue, 9 Apr 2013 08:21:42 +0000 (05:21 -0300)] 
testsuite: Wrap syscall() to get calls to finit_module()

When we don't have finit_module() in libc (most likely because as of
today glibc didn't add it yet), we end up using
syscall(__NR_finit_module, ...). In this case we would not wrap the
function in the testsuite and thus having some tests failing:

TESTSUITE: ERR: could not insert module: Operation not permitted

This implementation relies on the fact that this is the only caller of
syscall(2), because we can't call libc's syscall(). There's an abort()
in place to be future safe: as soon as we need more calls to syscall(),
we can detect (and decide what to do).

Now we have all tests passing in the testsuite again.

11 years agolibkmod: Move finit_module() definition to missing.h
Lucas De Marchi [Tue, 9 Apr 2013 07:16:57 +0000 (04:16 -0300)] 
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

11 years agolibkmod: Add missing definitions
Lucas De Marchi [Tue, 9 Apr 2013 07:00:20 +0000 (04:00 -0300)] 
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.

11 years agolibkmod: Use secure_getenv if available
Cristian Rodríguez [Mon, 11 Feb 2013 18:07:52 +0000 (15:07 -0300)] 
libkmod: Use secure_getenv if available

"The secure_getenv() function is intended for use in general-purpose
libraries to avoid vulnerabilities that could occur if set-user-ID or
set-group-ID programs accidentally trusted the environment."

11 years agomodprobe: Fix assertion on --show-depends with bogus config file
Lucas De Marchi [Thu, 21 Mar 2013 05:33:25 +0000 (02:33 -0300)] 
modprobe: Fix assertion on --show-depends with bogus config file

Putting something like "alias psmouse deadbeef" is a hackish way to
blacklist a module. While I don't encourage doing so, let's not explode
if we fiund such config files.

A small difference from the behavior of module-init-tools: we exit with
0 instead of 1.

11 years agotestsuite: Add test to check if modprobe explodes on bogus config
Lucas De Marchi [Thu, 21 Mar 2013 05:24:07 +0000 (02:24 -0300)] 
testsuite: Add test to check if modprobe explodes on bogus config

Put this one /etc/modprobe.d/bougs.conf:

alias psmouse deaddood

`modprobe --show-depends --quiet psmouse` explodes in an assertion
(unless you have a module named deaddood). Some people and initrd's use
"alias psmouse off" to disable a module instead of blacklisting it or
adding a install rule.

Add a test with expected_fail == true before fixing this.

11 years agotestsuite: Exit with success on signal if test has expected_fail=true
Lucas De Marchi [Thu, 21 Mar 2013 05:22:15 +0000 (02:22 -0300)] 
testsuite: Exit with success on signal if test has expected_fail=true

11 years agolibkmod-util: Add missing include file
Lucas De Marchi [Tue, 19 Mar 2013 20:44:59 +0000 (17:44 -0300)] 
libkmod-util: Add missing include file

Fix compilation issue with musl-libc:

  CC       libkmod/libkmod-list.lo
In file included from libkmod/libkmod-private.h:183:0,
                 from libkmod/libkmod-list.c:24:
libkmod/libkmod-util.h:33:45: warning: 'struct stat' declared inside parameter list [enabled by default]
libkmod/libkmod-util.h:33:45: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default]

11 years agormmod: Teach rmmod about builtin modules
Josh Boyer [Fri, 15 Mar 2013 17:43:40 +0000 (13:43 -0400)] 
rmmod: Teach rmmod about builtin modules

Currently modprobe -r will fail if a module is built in and report that it
is built in.  rmmod calls the same function to determine state but doesn't
handle the KMOD_MODULE_BUILTIN return code.  This leads to confusing errors
like this:

libkmod: kmod_module_get_holders: could not open '/sys/module/loop/holders': No such file or directory
Error: Module loop is in use

Fix this so that it actually reports the correct problem to the user.

11 years agolibkmod: fix address argument to mmap calls
Kees Cook [Mon, 18 Feb 2013 20:02:34 +0000 (12:02 -0800)] 
libkmod: fix address argument to mmap calls

The first argument to mmap should be "NULL" instead of "0".

11 years agotestsuite: handle finit_module
Kees Cook [Mon, 18 Feb 2013 20:02:33 +0000 (12:02 -0800)] 
testsuite: handle finit_module

This adds the finit_module logic to the testsuite.

11 years agolibkmod: add finit_module logic
Kees Cook [Mon, 18 Feb 2013 20:02:32 +0000 (12:02 -0800)] 
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.

11 years agotestsuite: Add modinfo test for module signatures
Michal Marek [Wed, 16 Jan 2013 20:04:00 +0000 (21:04 +0100)] 
testsuite: Add modinfo test for module signatures

11 years agolibkmod: Return module signature information in kmod_module_get_info()
Michal Marek [Wed, 16 Jan 2013 08:52:01 +0000 (09:52 +0100)] 
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.

11 years agolibkmod-module: Do not free the list in kmod_module_info_append
Michal Marek [Wed, 16 Jan 2013 16:51:57 +0000 (17:51 +0100)] 
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.

11 years agoUpdate copyright notices
Lucas De Marchi [Wed, 16 Jan 2013 13:27:21 +0000 (11:27 -0200)] 
Update copyright notices

11 years agolibkmod-module: Add helper for building the module info list
Michal Marek [Wed, 16 Jan 2013 09:18:17 +0000 (10:18 +0100)] 
libkmod-module: Add helper for building the module info list

11 years agogitignore: ignore files generated by Automake's testsuite
Lucas De Marchi [Tue, 15 Jan 2013 20:03:55 +0000 (18:03 -0200)] 
gitignore: ignore files generated by Automake's testsuite

These files are generated by Automake 1.13 when running the testsuite.

11 years agoman: fix lib dir in which we look for config
Lucas De Marchi [Tue, 8 Jan 2013 01:08:46 +0000 (23:08 -0200)] 
man: fix lib dir in which we look for config

Thanks to William Hubbs <w.d.hubbs@gmail.com> for spotting the bug.

11 years agodepmod: fix builtin symbols resolution when the prefix symbol is set
Andrey Mazo [Wed, 12 Dec 2012 12:39:18 +0000 (16:39 +0400)] 
depmod: fix builtin symbols resolution when the prefix symbol is set

When the prefix symbol is set, take it into account while adding symbols
from System.map file by skipping it before "__ksymtab_" comparison.

Also, prevent inserted fake symbols (like "__this_module") from being
wrongly truncated from beginning.

11 years agodepmod: --symbol-prefix actually requires an argument
Andrey Mazo [Wed, 12 Dec 2012 12:36:58 +0000 (16:36 +0400)] 
depmod: --symbol-prefix actually requires an argument

-P requires and uses an argument but its long counterpart --symbol-prefix does not:
depmod: option '--symbol-prefix' doesn't allow an argument

11 years agokmod 12 v12
Lucas De Marchi [Wed, 5 Dec 2012 03:39:17 +0000 (01:39 -0200)] 
kmod 12

11 years agodepmod: fix checking file extension
Lucas De Marchi [Wed, 28 Nov 2012 16:26:23 +0000 (14:26 -0200)] 
depmod: fix checking file extension

In depfile_up_to_date_dir() we need to check if name has a kmod
extension. "path" variable there will be the directory name, which
doesn't contain an extension.

Without this, "depmod -A" returns that the modules.dep is up to date,
even if it isn't.

In depmod_modules_search_file() it's pointless to compare the basename,
so pass only the name to be checked.

11 years agoUse bool instead of int
Lucas De Marchi [Wed, 28 Nov 2012 16:25:50 +0000 (14:25 -0200)] 
Use bool instead of int

Also change the last field initializer in array to be empty.

11 years agofix is_module_filename()
Aleksey Makarov [Wed, 28 Nov 2012 03:44:00 +0000 (10:44 +0700)] 
fix is_module_filename()

modinfo fails if there is a ".ko" substring in the path to the module

11 years agolibkmod-module: mangle the section header, not the section
Lucas De Marchi [Wed, 21 Nov 2012 22:17:25 +0000 (20:17 -0200)] 
libkmod-module: mangle the section header, not the section

When we are told to remove the "__versions" section we were mangling
that section instead of tweaking the SHF_ALLOC flag in its header.

11 years agolibkmod-module: Remove key+value vermagic from .modinfo section
Lucas De Marchi [Wed, 21 Nov 2012 20:34:50 +0000 (18:34 -0200)] 
libkmod-module: Remove key+value vermagic from .modinfo section

When told to force load a module, we were removing only the value of
vermagic instead of the complete entry.

Philippe De Swert (philippe.deswert@jollamobile.com) sent a patch that
was additionally mangling also the last two chars of the key
("vermagic="). Instead of creating an invalid entry in .modinfo section
like this, this patch removes the complete entry, key + value, by
zeroing the entire string.

Much thanks to Philippe who found the issue and pointed to the fix.

11 years agodepmod: fix asserting mod->kmod == NULL
Lucas De Marchi [Fri, 16 Nov 2012 14:05:42 +0000 (12:05 -0200)] 
depmod: fix asserting mod->kmod == NULL

If we are replacing a lower priority module (due to its location), we
already created a kmod_module, but didn't open the file for reading its
symbols. This means mod->kmod won't be NULL, and this is just ok. Since
all the functions freeing stuff below the previous assert already takes
NULL into consideration, it's safe to just unref mod->kmod and let the
right thing happens.

11 years agodepmod: fix hash lookup by relpath instead of uncrelpath
Lucas De Marchi [Fri, 16 Nov 2012 13:35:30 +0000 (11:35 -0200)] 
depmod: fix hash lookup by relpath instead of uncrelpath

We index modules in depmod by it's uncompressed relative path, not
relative path. We didn't notice this bug before since this function is
only triggered if we release a module to be replaced by one of higher
priority.

Also fix a leftover log message referring to relpath instead of
uncrelpath.

11 years agokmod 11 v11
Lucas De Marchi [Thu, 8 Nov 2012 04:30:21 +0000 (02:30 -0200)] 
kmod 11

11 years agoTODO: remove completed action
Lucas De Marchi [Thu, 8 Nov 2012 04:01:59 +0000 (02:01 -0200)] 
TODO: remove completed action

11 years agotools: use program_invocation_short_name provided by libc
Lucas De Marchi [Tue, 6 Nov 2012 21:20:09 +0000 (19:20 -0200)] 
tools: use program_invocation_short_name provided by libc

Thanks to Dave Reisner for pointing this out.

11 years agotools: staticize functions that are now only used in log.c
Lucas De Marchi [Tue, 6 Nov 2012 21:06:11 +0000 (19:06 -0200)] 
tools: staticize functions that are now only used in log.c

11 years agotools: share function for logging
Lucas De Marchi [Tue, 6 Nov 2012 21:01:59 +0000 (19:01 -0200)] 
tools: share function for logging

11 years agotools: share setting up libkmod log
Lucas De Marchi [Tue, 6 Nov 2012 20:26:34 +0000 (18:26 -0200)] 
tools: share setting up libkmod log

This also fixes a bug in "e6996c5 rmmod: route all messages to syslog if
told to" in which "+ verbose" was removed. Instead of letting verbose
add to kmod_get_log_priority(), let it be similar to the other programs
instead.

11 years agotools: use a single function for logging libkmod output
Lucas De Marchi [Tue, 6 Nov 2012 20:04:09 +0000 (18:04 -0200)] 
tools: use a single function for logging libkmod output

11 years agotools: make usage() messages go to stdout rather than stderr
Lucas De Marchi [Tue, 6 Nov 2012 19:32:41 +0000 (17:32 -0200)] 
tools: make usage() messages go to stdout rather than stderr

When user supplied --help/-h, program should output to stdout the usage,
not to stderr. It's the expected behavior, what the user asked for,
not something to log or an error.

11 years agotools: share function to convert prio to string
Lucas De Marchi [Tue, 6 Nov 2012 19:08:43 +0000 (17:08 -0200)] 
tools: share function to convert prio to string

No change is expected in the final binary since right now only an inline
function is shared. Later we expect to share more code.

11 years agotools: share getting program name from argv for all tools
Lucas De Marchi [Tue, 6 Nov 2012 18:54:17 +0000 (16:54 -0200)] 
tools: share getting program name from argv for all tools

11 years agormmod: route all messages to syslog if told to
Lucas De Marchi [Mon, 5 Nov 2012 20:32:05 +0000 (18:32 -0200)] 
rmmod: route all messages to syslog if told to

11 years agormmod: prefer ERR over plain fprintf
Lucas De Marchi [Mon, 5 Nov 2012 19:51:32 +0000 (17:51 -0200)] 
rmmod: prefer ERR over plain fprintf

11 years agomodinfo: prefer ERR over plain fprintf
Lucas De Marchi [Mon, 5 Nov 2012 19:58:57 +0000 (17:58 -0200)] 
modinfo: prefer ERR over plain fprintf

11 years agoinsmod: prefer ERR over plain fprintf
Lucas De Marchi [Mon, 5 Nov 2012 17:08:54 +0000 (15:08 -0200)] 
insmod: prefer ERR over plain fprintf

11 years agodepmod: add depmod prefix to log messages
Lucas De Marchi [Mon, 5 Nov 2012 04:07:09 +0000 (02:07 -0200)] 
depmod: add depmod prefix to log messages

11 years agodepmod: remove inline from _log
Lucas De Marchi [Mon, 5 Nov 2012 04:06:38 +0000 (02:06 -0200)] 
depmod: remove inline from _log

11 years agoTODO: update file with tasks
Lucas De Marchi [Mon, 5 Nov 2012 04:04:44 +0000 (02:04 -0200)] 
TODO: update file with tasks

11 years agodepmod: prefer ERR and WRN over plain fprintf
Lucas De Marchi [Mon, 5 Nov 2012 04:01:06 +0000 (02:01 -0200)] 
depmod: prefer ERR and WRN over plain fprintf

11 years agomodprobe: use ERR() instead of fprintf(stderr, ...)
Lucas De Marchi [Thu, 1 Nov 2012 15:02:10 +0000 (13:02 -0200)] 
modprobe: use ERR() instead of fprintf(stderr, ...)

11 years agomodprobe: prefix log messages to stderr with modprobe
Lucas De Marchi [Thu, 1 Nov 2012 14:45:23 +0000 (12:45 -0200)] 
modprobe: prefix log messages to stderr with modprobe

11 years agomodprobe: move log function
Lucas De Marchi [Thu, 1 Nov 2012 14:39:18 +0000 (12:39 -0200)] 
modprobe: move log function

11 years agomodprobe: prefix libkmod messages to stderr with modprobe:
Lucas De Marchi [Thu, 1 Nov 2012 14:24:58 +0000 (12:24 -0200)] 
modprobe: prefix libkmod messages to stderr with modprobe:

When we are logging to stderr we are previously relying on libkmod
sending it to the default location in case we are not asked to log to
syslog. The problem is that modprobe may be used in scripts that don't
want to log to syslog (since they are not daemons, like scripts to
generate initrd) and then it's difficult to know where the message comes
from.

This patch treats only the messages coming from libkmod.

11 years agomodprobe: use prio_to_str() helper
Lucas De Marchi [Thu, 1 Nov 2012 00:00:40 +0000 (22:00 -0200)] 
modprobe: use prio_to_str() helper

11 years agomodprobe: exit in one place
Lucas De Marchi [Wed, 31 Oct 2012 23:29:54 +0000 (21:29 -0200)] 
modprobe: exit in one place

11 years agodepmod: unref kmod_module once we don't need it anymore
Lucas De Marchi [Tue, 30 Oct 2012 05:46:12 +0000 (03:46 -0200)] 
depmod: unref kmod_module once we don't need it anymore

Once we read all we need from a module, unref it so any resource taken
by it (including the mmap to access the file in libkmod) will be
dropped. This drastically reduces the number of open file descriptors
and also the memory needed, with no performance penalties. Rather,
there's a small speedup of ~2.6%.

Running depmod in a laptop with 2973 modules and comparing the number of
open file descriptors for kmod-10, before and after the last patches to
depmod (caaf438cb681c5b5b5b3c32e5b6bd12e96993dd7 and HEAD) we have:

Before: 2980 simultaneously open fds
After: 7    simultaneously open fds
kmod-10: 7    simultaneously open fds

So now we have the speedup of caching the file in kmod_module without
the drawback of increasing the number of open file descriptors.

11 years agodepmod: use our copy of modname instead of calling libkmod
Lucas De Marchi [Tue, 30 Oct 2012 06:08:54 +0000 (04:08 -0200)] 
depmod: use our copy of modname instead of calling libkmod

In depmod_module_add() we already called kmod_module_get_name() and
copied the string to our struct. Use it instead of calling again and
again the libkmod function.

11 years agodepmod: cache dependency_symbol list in struct mod
Lucas De Marchi [Tue, 30 Oct 2012 05:16:10 +0000 (03:16 -0200)] 
depmod: cache dependency_symbol list in struct mod

The overall goal is to coalesce the accesses to a file that is the
backend of a module. This commit addresses the calls to
kmod_module_get_get_dependency_symbols(). Calling it earlier, while we
are iterating the modules allows us to free the struct kmod of each
module much sooner. We are still not freeing it since there are other
places that must be refactored first.

There's a performance penalty of ~2.5% from previous commit.

11 years agodepmod: cache info_list in struct mod
Lucas De Marchi [Tue, 30 Oct 2012 05:16:10 +0000 (03:16 -0200)] 
depmod: cache info_list in struct mod

The overall goal is to coalesce the accesses to a file that is the
backend of a module. This commit addresses the calls to
kmod_module_get_info(). Calling it earlier, while we are iterating the
modules allows us to free the struct kmod of each module much sooner. We
are still not freeing it since there are other places that must be
refactored first.

A nice side effect is that this commit reduces in ~33% the calls to
malloc(), giving a speedup of ~6% for cold caches (reproduced on only 1
laptop).

11 years agodepmod: do not create a hole in struct depmod
Lucas De Marchi [Tue, 30 Oct 2012 04:32:48 +0000 (02:32 -0200)] 
depmod: do not create a hole in struct depmod

11 years agobuild-sys: use AS_IF autoconf macro
Lucas De Marchi [Tue, 23 Oct 2012 12:45:10 +0000 (10:45 -0200)] 
build-sys: use AS_IF autoconf macro

Just for consistency with the rest.

11 years agobuild-sys: require xsltproc when manpages are enabled
Sami Kerola [Mon, 22 Oct 2012 17:40:02 +0000 (18:40 +0100)] 
build-sys: require xsltproc when manpages are enabled

Before this commit the build system failed at late state with
non-helpful message when xsltproc was not available.

Making all in man
  GEN      depmod.d.5
/bin/sh: --nonet: command not found
make[2]: *** [depmod.d.5] Error 127
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

11 years agolibkmod: cache open file for later access
Lucas De Marchi [Thu, 18 Oct 2012 04:36:33 +0000 (01:36 -0300)] 
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.

11 years agormmod: Deprecate --wait option
Lucas De Marchi [Wed, 17 Oct 2012 21:32:56 +0000 (18:32 -0300)] 
rmmod: Deprecate --wait option

Remove --wait from usage() and give a message + sleep(10) if user is in
fact using it.

11 years agolibkmod-hash: Plug possible memory leak when free_value is defined
Leandro Pereira [Fri, 12 Oct 2012 15:28:56 +0000 (12:28 -0300)] 
libkmod-hash: Plug possible memory leak when free_value is defined

Although the hash table implementation allows passing a callback function
to free a value when it is removed from the hash table, hash_del() wasn't
freeing it if it was provided. Now it does.

As a bonus, it now checks if the callback is set in hash_add() as well.

11 years agolibkmod: Add support for '.' in module parameter on kcmdline
Lucas De Marchi [Mon, 8 Oct 2012 22:04:16 +0000 (19:04 -0300)] 
libkmod: Add support for '.' in module parameter on kcmdline

Otherwise we fail to parse arguments in kernel command line like
testmodule.testparam=1.5G

Suggested-by: Selim T. Erdogan <selim@alumni.cs.utexas.edu>
11 years agotestsuite: add depmod test for modules.alias
Lucas De Marchi [Thu, 4 Oct 2012 04:08:13 +0000 (01:08 -0300)] 
testsuite: add depmod test for modules.alias

Check if modules.alias is correctly generated from modules.order if we
have compressed modules.

11 years agotestsuite: allow to check generated files
Lucas De Marchi [Thu, 4 Oct 2012 03:21:52 +0000 (00:21 -0300)] 
testsuite: allow to check generated files

This gives the test cases the ability to supply files that must be
checked after the test is run, rather than just checking stdout/stderr.

This is intended to be used with tools that generate files, like depmod.
It includes a poor's man implementation of a "check for differences in
files". Not really optimized, but it's simple enough and does what it
proposes to.

11 years agodepmod: fix parsing of modules.order with compressed modules
Lucas De Marchi [Wed, 3 Oct 2012 19:28:24 +0000 (16:28 -0300)] 
depmod: fix parsing of modules.order with compressed modules

We now index the modules by uncompressed-relative-path instead of
relative-path. This is because the file modules.order, coming from
kernel, always comes with uncompressed paths. This fixes the issue of
not sorting the aliases correctly due to paths not matching when using
compressed modules.

11 years agobuild-sys: Remove --with-rootprefix option
Dave Reisner [Thu, 27 Sep 2012 15:00:42 +0000 (11:00 -0400)] 
build-sys: Remove --with-rootprefix option

This is a broken option that only leads to misery and incompatabilities
with other systems. Kbuild doesn't come close to supporting directories
other than /lib/modules with several targets simply failing without
hacky fixes. Simply remove the option and all traces of it, as it
doesn't make sense in today's world.

11 years agobuild-sys: Append -Werror when testing flags
Lucas De Marchi [Fri, 14 Sep 2012 14:18:41 +0000 (11:18 -0300)] 
build-sys: Append -Werror when testing flags

Clang doesn't treat unknown warnings flags as an error, but rather as a
warning. The result is that the detection for whic CFLAGS are supported
by this compiler will not work, since the compilation will succeed.

With this patch we now successfully detect clang doesn't support
-Wlogical-op, as opposed to previous behavior:

checking if clang supports flag -Wlogical-op in envvar CFLAGS... no

We use this macro only for LDFLAGS and CFLAGS, so it's safe to stash
-Werror there.

11 years agoNEWS: language corrections
Jan Engelhardt [Thu, 13 Sep 2012 23:55:54 +0000 (01:55 +0200)] 
NEWS: language corrections

11 years agomodinfo: clarify verbiage for field shortcuts
Dave Reisner [Sat, 8 Sep 2012 16:22:11 +0000 (12:22 -0400)] 
modinfo: clarify verbiage for field shortcuts

Cleanup the punctuation and grammar in this blurb, specifically pointing
out what these are shortcuts for.

11 years agoMakefile: remove redundant flags to $(RM)
Dave Reisner [Sat, 8 Sep 2012 15:43:54 +0000 (11:43 -0400)] 
Makefile: remove redundant flags to $(RM)

$(RM) will always expand to 'rm -f' which means we don't need to ignore
errors or pass this flag again.

11 years agoDefine rootfs as dependency of check-am
Dave Reisner [Sat, 8 Sep 2012 18:08:50 +0000 (14:08 -0400)] 
Define rootfs as dependency of check-am

This should actually fix the problem of ensuring that the rootfs is
created every time that 'make check' is run.

11 years agoRevert "build-sys: disable jobserver for rootfs target"
Dave Reisner [Sat, 8 Sep 2012 15:50:56 +0000 (11:50 -0400)] 
Revert "build-sys: disable jobserver for rootfs target"

This is bogus and does not work.

This reverts commit 4e7f0f204bc82ce749cad6613b066993f530cbe6.

11 years agotestsuite: Fix double definition of 64-bits variant
Lucas De Marchi [Fri, 7 Sep 2012 17:59:35 +0000 (14:59 -0300)] 
testsuite: Fix double definition of 64-bits variant

If _FILE_OFFSET_BITS is defined we should not be wrapping these 64
variants, since they are macros in libc.