platform/upstream/kmod.git
10 years agoman: Change my contact email address
Lucas De Marchi [Thu, 2 Jan 2014 19:13:38 +0000 (17:13 -0200)]
man: Change my contact email address

10 years agokmod 16 v16
Lucas De Marchi [Sun, 22 Dec 2013 21:45:19 +0000 (19:45 -0200)]
kmod 16

10 years agoUse C11's noreturn
Lucas De Marchi [Tue, 17 Dec 2013 21:10:16 +0000 (19:10 -0200)]
Use C11's noreturn

Also define noreturn w/o <stdnoreturn.h> and move it to macro.h instead
of in the testsuite.

Based on similar commit on systemd by Shawn Landden
<shawn@churchofgit.com>.

10 years agomodule: use _cleanup_free and remove useless call to free()
Lucas De Marchi [Mon, 18 Nov 2013 13:52:53 +0000 (11:52 -0200)]
module: use _cleanup_free and remove useless call to free()

10 years agofile: use _cleanup_free_
Lucas De Marchi [Mon, 18 Nov 2013 13:43:10 +0000 (11:43 -0200)]
file: use _cleanup_free_

10 years agoarray: avoid duplicate code to reallocate
Lucas De Marchi [Mon, 18 Nov 2013 13:28:28 +0000 (11:28 -0200)]
array: avoid duplicate code to reallocate

10 years agoutil: Be OOM-safe and use _cleanup_free_
Lucas De Marchi [Mon, 18 Nov 2013 07:31:14 +0000 (05:31 -0200)]
util: Be OOM-safe and use _cleanup_free_

10 years agotestsuite: add basic test for getline_wrapped
Lucas De Marchi [Mon, 18 Nov 2013 07:13:59 +0000 (05:13 -0200)]
testsuite: add basic test for getline_wrapped

10 years agoutil: use _cleanup_free_ on path_make_absolute_cwd()
Lucas De Marchi [Thu, 14 Nov 2013 06:16:16 +0000 (04:16 -0200)]
util: use _cleanup_free_ on path_make_absolute_cwd()

10 years agoconfig: Use _cleanup_free_
Lucas De Marchi [Thu, 14 Nov 2013 02:33:28 +0000 (00:33 -0200)]
config: Use _cleanup_free_

10 years agoutil: Add cleanup attribute
Lucas De Marchi [Thu, 14 Nov 2013 02:19:15 +0000 (00:19 -0200)]
util: Add cleanup attribute

10 years agotestsuite: Move test-alias to test-util
Lucas De Marchi [Mon, 18 Nov 2013 06:32:45 +0000 (04:32 -0200)]
testsuite: Move test-alias to test-util

Move file so we can use the same file to test other functions from
libkmod-util.c

10 years agobuild: Allow disabling maintainer mode
Anders Olofsson [Mon, 11 Nov 2013 01:41:25 +0000 (23:41 -0200)]
build: Allow disabling maintainer mode

This allows make rules for generated build files (i.e.  configure,
Makefile.in, ... ) to be skipped.  This is useful when
the source is stored without timestamps (for example in CVS or GIT).

When the build rules trigger to regenerate the build files, it tries to
use the same autotools version (currently 1.14) as was originally used
for the release.  Since many of our build machines run Debian Squeeze,
they only have autotools 1.11 available and the build fails.

Currently, we have to work around this by touching all the generated
files before building to avoid triggering the make rule. With this
patch, we would be able to just run configure with
--disable-maintainer-mode instead.  The patch sets the default to enable
to not change the default behavior.

10 years agobuild-sys: enable colored diagnostics if available
Lucas De Marchi [Sat, 26 Oct 2013 04:51:05 +0000 (02:51 -0200)]
build-sys: enable colored diagnostics if available

10 years agoMakefile.am: add mkdir testsuite
Saul Wold [Thu, 10 Oct 2013 06:49:48 +0000 (23:49 -0700)]
Makefile.am: add mkdir testsuite

If we are note building in the existing source tree and have disabled
dependency-tracking then the testsuite directory is not created during
the configure phase and will not exist when the cp of ROOTFS_PRISTINE
occurs, thus causing an error and fail.

10 years agoMakefile.am: Add target to all cross-compilation of testsuite
Saul Wold [Thu, 10 Oct 2013 01:09:52 +0000 (18:09 -0700)]
Makefile.am: Add target to all cross-compilation of testsuite

The buildtest-TESTS target allows for cross-compilation of the testsuites
without the actual running of the tests that check normally does.

10 years agoNEWS: add entries
Lucas De Marchi [Fri, 20 Sep 2013 06:50:40 +0000 (01:50 -0500)]
NEWS: add entries

10 years agormmod: remove --wait option
Lucas De Marchi [Fri, 20 Sep 2013 06:40:58 +0000 (01:40 -0500)]
rmmod: remove --wait option

Let libkmod enforce KMOD_REMOVE_NOWAIT.

10 years agolibkmod: always pass O_NONBLOCK to kernel
Lucas De Marchi [Fri, 20 Sep 2013 06:30:07 +0000 (01:30 -0500)]
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.

10 years agolibkmod-hash: always align n_buckets to power of 2
Lucas De Marchi [Thu, 22 Aug 2013 04:36:45 +0000 (01:36 -0300)]
libkmod-hash: always align n_buckets to power of 2

By aligning n_buckets to power of 2 we can turn the "bucket = hashval %
n_buckets" into a less expensive bucket = hashval & (n_buckets - 1).
This removes the DIV instruction as shown below.

Before:
xor    %edx,%edx
divl   0x8(%rbx)
mov    %edx,%eax
add    $0x1,%rax
shl    $0x4,%rax
add    %rbx,%rax

After:
lea    -0x1(%rdi),%edx
and    %edx,%eax
add    $0x1,%rax
shl    $0x4,%rax
add    %rbx,%rax

With a microbenchmark, measuring the time to locate the bucket (i.e.
time_to_calculate_hashval + time_to_calculate_bucket_position) we have
the results below (time in clock cycles):

keylen      before   after
2-10          79.0    61.9 (-21.65%)
11-17         81.0    64.4 (-20.48%)
18-25         90.0    73.2 (-18.69%)
26-32        104.7    87.0 (-16.82%)
33-40        108.4    89.6 (-17.37%)
41-48        111.2    91.9 (-17.38%)
49-55        120.1   102.1 (-15.04%)
56-63        134.4   115.7 (-13.91%)

As expected the gain is constant, regardless of the key length.
The time to clculate the hashval varies with the key length, which
explains the bigger gains for short keys.

10 years agoutil: Add ALIGN_POWER2
Lucas De Marchi [Thu, 22 Aug 2013 04:10:13 +0000 (01:10 -0300)]
util: Add ALIGN_POWER2

Add static inline function to align a value to it's next power of 2.
This is commonly done by a SWAR like the one in:

http://aggregate.org/MAGIC/#Next Largest Power of 2

However a microbench shows that the implementation herer is a faster.
It doesn't really impact the possible user of this function, but it's
interesting nonetheless.

Using a x86_64 i7 Ivy Bridge it shows a ~4% advantage by using clz
instead instead of the OR and SHL chain. And this is by using a BSR
since Ivy Bridge doesn't have LZCNT. New Haswell processors have the
LZCNT instruction which can make this even better. ARM also has a CLZ
instruction so it should be better, too.

Code used to test:

...
v = val[i];
t1 = get_cycles(0);
a = ALIGN_POWER2(v);
t1 = get_cycles(t1);

t2 = get_cycles(0);
v = nlpo2(v);
t2 = get_cycles(t2);

printf("%u\t%llu\t%llu\t%d\n", v, t1, t2, v == a);
...

In which val is an array of 20 random unsigned int, nlop2 is the SWAR
implementation and get_cycles uses RDTSC to measure the performance.

Averages:
ALIGN_POWER2:  30 cycles
nlop2: 31.4 cycles

10 years agodepmod: warn on invalid devname specification
Tom Gundersen [Mon, 9 Sep 2013 18:01:01 +0000 (20:01 +0200)]
depmod: warn on invalid devname specification

During the last merge window (3.12) a couple of modules gained devname
aliases, but without the necessary major and minor information. These were
then silently ignored when generating modules.devname.

Complain loudly to avoid such errors sneaking in undetected in the future:

    depmod: ERROR: Module 'zram' has devname (zram) but lacks major and minor information. Ignoring.
    depmod: ERROR: Module 'uhid' has devname (uhid) but lacks major and minor information. Ignoring.

Cc: Kay Sievers <kay@vrfy.org>
Cc: Lucas De Marchi <lucas.demarchi@profusion.mobi>
10 years agobuild: remove check for typeof
Lucas De Marchi [Fri, 6 Sep 2013 14:15:02 +0000 (11:15 -0300)]
build: remove check for typeof

It's used in so many places without checking, that's really pointless to
check for it in macro.h.

Also remove AC_C_TYPEOF from configure.ac since we don't use -ansi.

10 years agoAdd configure check for _Static_assert()
Thomas Petazzoni [Fri, 6 Sep 2013 13:27:04 +0000 (15:27 +0200)]
Add configure check for _Static_assert()

Commit 8efede20ef ("Use _Static_assert") introduced the usage of
_Static_assert(). However, _Static_assert() is a fairly new thing,
since it was introduced only in gcc 4.6. In order to support older
compilers, this patch adds a configure.in test that checks whether
_Static_assert() is usable or not, and adjust the behavior of the
assert_cc() macro accordingly.

10 years agoFix usage of readdir_r()
Lucas De Marchi [Wed, 28 Aug 2013 02:29:47 +0000 (23:29 -0300)]
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.

10 years agotestsuite: fix usage of reserved names
John Spencer [Mon, 26 Aug 2013 23:38:11 +0000 (01:38 +0200)]
testsuite: fix usage of reserved names

stdout and stderr are names reserved for the implementation
and musl uses them rightfully as macro - and the expansion
causes (of course) unexpected results.

rename the struct members stdout to out and stderr
to err, to be 1) compliant 2) cause compilation to
succeed.

fixes build with musl libc.

10 years agokmod 15 v15
Lucas De Marchi [Thu, 22 Aug 2013 13:44:08 +0000 (10:44 -0300)]
kmod 15

10 years agolibkmod: Fix getting param with no value from kcmdline
Lucas De Marchi [Wed, 14 Aug 2013 01:04:46 +0000 (22:04 -0300)]
libkmod: Fix getting param with no value from kcmdline

10 years agotestsuite: Add test for parameter with no value in kcmdline
Lucas De Marchi [Wed, 14 Aug 2013 01:03:26 +0000 (22:03 -0300)]
testsuite: Add test for parameter with no value in kcmdline

Currently we fail to add the module option if the parameter doesn't have
a value.

11 years agodepmod: add missing "else" clause
Jan Engelhardt [Wed, 7 Aug 2013 21:58:58 +0000 (23:58 +0200)]
depmod: add missing "else" clause

It occurred to an openSUSE user that our mkinitrd would throw a
warning when used with kmod:

libkmod: conf_files_list: unsupported file mode /dev/null: 0x21b6

Grepping for the error message revealed that there might be a missing
"else" keyword here, since it is unusual to put an "if" directly after
closing brace.

11 years agoshell-completion: Make options accept '=' as last char
Lucas De Marchi [Fri, 2 Aug 2013 15:07:39 +0000 (12:07 -0300)]
shell-completion: Make options accept '=' as last char

11 years agobuild: Install bash completion data
Lucas De Marchi [Tue, 30 Jul 2013 06:47:19 +0000 (03:47 -0300)]
build: Install bash completion data

11 years agoshell-completion: Add kmod static-nodes
Lucas De Marchi [Tue, 30 Jul 2013 06:28:41 +0000 (03:28 -0300)]
shell-completion: Add kmod static-nodes

11 years agoshell-completion: Add initial completion for kmod
Lucas De Marchi [Mon, 29 Jul 2013 16:23:54 +0000 (13:23 -0300)]
shell-completion: Add initial completion for kmod

Based on journalctl and udevadm from systemd and adapted to kmod needs.

11 years agoNEWS: Add entries
Lucas De Marchi [Wed, 17 Jul 2013 05:31:36 +0000 (02:31 -0300)]
NEWS: Add entries

11 years agoREADME: Move items from TODO
Lucas De Marchi [Wed, 17 Jul 2013 05:26:47 +0000 (02:26 -0300)]
README: Move items from TODO

Put the differences between kmod and module-init-tools in the README
file so it's more visible.

11 years agostatic-nodes: create parent directories of output file
Tom Gundersen [Sun, 14 Jul 2013 13:13:34 +0000 (15:13 +0200)]
static-nodes: create parent directories of output file

Allows us to drop call to "mkdir -p" from the systemd service file.

11 years agoutil: Add mkdir_parents()
Lucas De Marchi [Mon, 15 Jul 2013 05:05:52 +0000 (02:05 -0300)]
util: Add mkdir_parents()

Like mkdir_p, but discards the leaf, creating the parent directories.

11 years agoutil: Add len arg to mkdir_p()
Lucas De Marchi [Mon, 15 Jul 2013 04:58:44 +0000 (01:58 -0300)]
util: Add len arg to mkdir_p()

11 years agostatic-nodes: don't fail if modules.devname not found
Tom Gundersen [Sun, 14 Jul 2013 13:13:33 +0000 (15:13 +0200)]
static-nodes: don't fail if modules.devname not found

In containers/VM's/initrd one might not have installed any modules and
accompanying modules.devname Don't fail if this is the case, just warn.

When used in systemd this means we don't get a failing unit on booting
containers.

11 years agoutil: Add mkdir_p implementation from testsuite
Lucas De Marchi [Mon, 15 Jul 2013 04:41:19 +0000 (01:41 -0300)]
util: Add mkdir_p implementation from testsuite

11 years agotestsuite: Fix mkdir_p corner cases
Lucas De Marchi [Mon, 15 Jul 2013 04:21:27 +0000 (01:21 -0300)]
testsuite: Fix mkdir_p corner cases

 - Fix infinite loop when path is relative
 - Fix not considering EEXIST as a success
 - General refactor to mkdir_p so it never calls mkdir for an existing
   dir (given no one creates it from outside)

11 years agoUse "-internal" suffix instead of "-private"
Lucas De Marchi [Thu, 4 Jul 2013 19:13:11 +0000 (16:13 -0300)]
Use "-internal" suffix instead of "-private"

11 years agotools: Do not link dynamically with libkmod
Lucas De Marchi [Thu, 4 Jul 2013 19:01:55 +0000 (16:01 -0300)]
tools: Do not link dynamically with libkmod

Instead of linking dynamically with libkmod, use libkmod-private.la. We
disallow creating a static libkmod because we can't hide symbols there
and it cause problems with external programs. However this should not
prevent users that are only interested in the tools we provide not being
able to ship only them keeping the library alone.

Other projects also do this to allow our tools to use certain functions
that should not be used outside of the project.

11 years agokmod 14 v14
Lucas De Marchi [Wed, 3 Jul 2013 15:42:04 +0000 (12:42 -0300)]
kmod 14

11 years agotools: Use test/kmod instead of kmod-nolib
Lucas De Marchi [Wed, 3 Jul 2013 00:03:20 +0000 (21:03 -0300)]
tools: Use test/kmod instead of kmod-nolib

The reason to have a kmod-nolib binary is that we need to call kmod on
test cases (or a symlink to it) and for testing things in tree. Since
we are using libtool if we are dinamically linking to libkmod what we
end up having is a shell script that (depending on the version *)
changes argv[0] to contain an "lt-" prefix. Since this screws with our
compat stuff, we had a kmod-nolib that links statically.

This all workaround works fine iff we are using one of the compat
commands, i.e. we are using the symlinks insmod, rmmod, modprobe, etc.
However if we are actually trying the kmod binary, this doesn't work
because we can't create a kmod symlink since there's already a kmod
binary.

So, completely give up on libtool fixing their mess. Now we create a
tool/test/ directory and the symlinks and kmod is put there.

* http://lists.gnu.org/archive/html/bug-libtool/2011-12/msg00023.html

11 years agostatic-nodes: Better -f option description
Lucas De Marchi [Tue, 2 Jul 2013 02:00:20 +0000 (23:00 -0300)]
static-nodes: Better -f option description

11 years agobuild-sys: do not allow --enable static
Lucas De Marchi [Thu, 6 Jun 2013 14:43:19 +0000 (11:43 -0300)]
build-sys: do not allow --enable static

Do the same as done in systemd by Cristian Rodríguez
<crrodriguez@opensuse.org>. We use private symbols, not namespaced. So
don't pretend we support static linking.

11 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.

11 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.

11 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.

11 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<----------

11 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.