]> git.ipfire.org Git - thirdparty/kmod.git/log
thirdparty/kmod.git
9 years agotestsuite: port signature-check modules to module-playground
Lucas De Marchi [Sat, 21 Feb 2015 17:47:16 +0000 (15:47 -0200)] 
testsuite: port signature-check modules to module-playground

We use a "fake signature" to sign the modules. As far as kmod is
concerned the signature fields are informational only. It's the kernel
the responsible for checking it's valid.

So what we are doing here is: pick the signatures of the ext4-x86_64.ko
module and save as dummy.{hashalgo}. This signature is appended to the
mod-simple.ko module so the ext4-x86_64.ko module can be removed from
tree.

9 years agotestsuite: port arch-specific tests to module-playground
Lucas De Marchi [Sat, 21 Feb 2015 17:09:12 +0000 (15:09 -0200)] 
testsuite: port arch-specific tests to module-playground

Rename modinfo_jonsmodules() to test_modinfo_signature(): now this test
is responsible only for the signed modules.

The other tests use specific flags to modinfo in order to print only
one field, so we can filter out those fields that are expect to change
if the module is recompiled.

9 years agofixup! module-playground: allow to cross-compile modules
Lucas De Marchi [Sat, 21 Feb 2015 17:08:19 +0000 (15:08 -0200)] 
fixup! module-playground: allow to cross-compile modules

9 years agotestsuite: leave arch-specific modules in tree
Lucas De Marchi [Sat, 21 Feb 2015 17:02:55 +0000 (15:02 -0200)] 
testsuite: leave arch-specific modules in tree

This is for convenience for development and testing since we don't want
to needlessly cross-compile the modules. There's a README file
explaining the building process for those who want to update them.

These files are compiled from their respective .c and thus have LPGL
license.

9 years agotestsuite: add option to copy output from test
Lucas De Marchi [Sat, 21 Feb 2015 15:39:36 +0000 (13:39 -0200)] 
testsuite: add option to copy output from test

This is helpful while debugging the tests: copy the output from test
(both stdout and stderr) to the stdout of the parent process.

9 years agotestsuite: fix exiting with success on no output activity
Lucas De Marchi [Sat, 21 Feb 2015 15:07:42 +0000 (13:07 -0200)] 
testsuite: fix exiting with success on no output activity

If we were expecting output on stdout or stderr but the test didn't
produce any, we were incorrectly assuming the test was successful.
Now test on exit if there was activity on the monitored fd. If there
was, check also if the file size to check for output is > 0 for the
cases in which we want to assert there was no activity on certain fd.

9 years agomodule-playground: allow to cross-compile modules
Lucas De Marchi [Sat, 21 Feb 2015 05:22:54 +0000 (03:22 -0200)] 
module-playground: allow to cross-compile modules

This adds the needed infra to cross-compile modules so we can test them
in our testsuite. Right now we are only compiling mod-simple.ko for x86,
x86_64 and sparc64.

The makefiles are organized in a way it's easy to force a rebuild of a
module by calling the Makefile.arch directly and that allows the rule in
Makefile to not trigger in case we want to ship the modules
pre-compiled.

9 years agotestsuite: port modules-order-compressed to module-playground
Lucas De Marchi [Thu, 19 Feb 2015 21:50:16 +0000 (19:50 -0200)] 
testsuite: port modules-order-compressed to module-playground

9 years agoUpdate TODO
Lucas De Marchi [Thu, 19 Feb 2015 03:00:05 +0000 (01:00 -0200)] 
Update TODO

9 years agolibkmod: better explain a signed module layout
Lucas De Marchi [Wed, 18 Feb 2015 18:47:14 +0000 (16:47 -0200)] 
libkmod: better explain a signed module layout

9 years agolibkmod: consider empty signature key as invalid
Lucas De Marchi [Wed, 18 Feb 2015 18:15:45 +0000 (16:15 -0200)] 
libkmod: consider empty signature key as invalid

A segmentation fault occurs if a module has an empty key attached to
its signature. This is mostly likely due to a corrupted module.

The crash happens because kmod_module_get_info() assumes that
kmod_module_signature_info() returns a signature of at least 1 byte.

The fix is based on a patch from Tobias Stoeckmann
<tobias@stoeckmann.org>, but rather than changing kmod_module_get_info()
to fix the crash, this changes kmod_module_signature_info() to
consider the signature as invalid.

9 years agoFix out of bounds signature access with 32 bit off_t
Tobias Stoeckmann [Sat, 14 Feb 2015 23:35:47 +0000 (00:35 +0100)] 
Fix out of bounds signature access with 32 bit off_t

If kmod has been configured with --disable-largefile on a 32 bit
system, off_t will be 32 bit. In that case, the parsed sig_len can
bypass a validation check (it's _unsigned_ 32 bit).

Due to the unlikeliness of people using --disable-largefile, this is
a mere validation fix. With an explicit signed 64 bit cast, there is
no binary change for 99.9% of Linux systems out there. ;)

9 years agolibkmod: properly validate file size
Tobias Stoeckmann [Tue, 10 Feb 2015 18:46:40 +0000 (19:46 +0100)] 
libkmod: properly validate file size

In function kmod_elf_new, the file size has to be properly validated against
section offset. Currently, the file size is considered valid based on
ELF header size + section header size * section count. That is not sufficient.

In fact, ELF specifies a section header offset, which doesn't have to be the
size of the ELF header. The supplied test cases even cover this.

The correct test is: section offset + section header size * section count

This patch also verifies that this value won't overflow.  I don't know a way
to crash a tool due to this bug, because later on the offset check would
prevent out-of-bounds access. An overflow would just mean to access a wrong
part in elf->memory. Yet it's a validation error.

Please note: The file size does not have to be validated against the size
of the ELF header again, elf_identify did this already.

9 years agotestsuite: port kcmdline test to module-playground
Lucas De Marchi [Wed, 11 Feb 2015 04:59:08 +0000 (02:59 -0200)] 
testsuite: port kcmdline test to module-playground

9 years agotestsuite: port install-cmd-loop test to module-playground
Lucas De Marchi [Wed, 11 Feb 2015 04:50:06 +0000 (02:50 -0200)] 
testsuite: port install-cmd-loop test to module-playground

9 years agotestsuite: port alias-to-none test to module-playground
Lucas De Marchi [Wed, 11 Feb 2015 00:19:53 +0000 (22:19 -0200)] 
testsuite: port alias-to-none test to module-playground

9 years agotestsuite: port tests without finit_module() to module-playground
Lucas De Marchi [Wed, 11 Feb 2015 00:11:25 +0000 (22:11 -0200)] 
testsuite: port tests without finit_module() to module-playground

9 years agotestsuite: port modprobe --force test to module-playground
Lucas De Marchi [Wed, 11 Feb 2015 00:01:42 +0000 (22:01 -0200)] 
testsuite: port modprobe --force test to module-playground

9 years agotestsuite: port softdep-loop test to module-playground
Lucas De Marchi [Tue, 10 Feb 2015 23:45:09 +0000 (21:45 -0200)] 
testsuite: port softdep-loop test to module-playground

9 years agolibkmod: use helper function to check for overflow
Lucas De Marchi [Tue, 10 Feb 2015 12:46:26 +0000 (10:46 -0200)] 
libkmod: use helper function to check for overflow

9 years agoshared: add helper function to add and check for overflow
Lucas De Marchi [Tue, 10 Feb 2015 12:41:47 +0000 (10:41 -0200)] 
shared: add helper function to add and check for overflow

Use _builtin_uaddll_overflow/_builtin_uaddl_overflow when available,
abstracting the type to use it with uint64_t.

Otherwise fallback to the implementation as added in 67466f2 ("Prevent
offset + size overflow.").

This also adds the tests for this new helper in the testsuite.

9 years agobuild: define to 0 if builtin is not available
Lucas De Marchi [Tue, 10 Feb 2015 12:32:10 +0000 (10:32 -0200)] 
build: define to 0 if builtin is not available

In order to let us use "#if HAVE__BUILTIN_*" without checking if it's
actually define, make sure we define it to 0 in config.h when the
function is not available.

9 years agoPrevent offset + size overflow.
Tobias Stoeckmann [Mon, 9 Feb 2015 22:22:51 +0000 (23:22 +0100)] 
Prevent offset + size overflow.

it is possible to overflow uint64_t by summing variables offset and
size up in elf_get_section_info. Thee values are extracted from module
file and are possibly maliciously tampered with.

If offset is in valid range and size very large, the result will
overflow and the size check passes. Later on, this will most likely
lead to a segmentation fault due to accessing uninitialized memory.

Attached please find a proof of concept module, which will trigger
a segmentation fault on modinfo. Tested on amd64:

tobias:~$ modinfo poc.ko
filename:       /home/tobias/poc.ko
Segmentation fault

There are more errors of this type in the ELF handling code that will be
fixed in other patches.

9 years agotestsuite: port show-depends tests to module-playground
Lucas De Marchi [Tue, 10 Feb 2015 11:30:49 +0000 (09:30 -0200)] 
testsuite: port show-depends tests to module-playground

Another test, modprobe_show_alias_to_none was wrongly checking the
output in the show-depends namespace so it needed changing as well.

9 years agobuild: check for required builtin functions
Lucas De Marchi [Tue, 10 Feb 2015 02:45:11 +0000 (00:45 -0200)] 
build: check for required builtin functions

These builtins are implemented by both gcc and clang since a long time
and we don't provide fallback for them. Let the configure phase check
for them.

9 years agobuild: add better check for builtin function
Lucas De Marchi [Tue, 10 Feb 2015 02:31:08 +0000 (00:31 -0200)] 
build: add better check for builtin function

It's not used right now in kmod, but may be used in future for other
builtins, so let the macro generic.

9 years agotestsuite: port detect-loop test to module-playground
Lucas De Marchi [Mon, 9 Feb 2015 16:07:31 +0000 (14:07 -0200)] 
testsuite: port detect-loop test to module-playground

9 years agotravis: also test with gcc 4.8 and 4.9
Lucas De Marchi [Wed, 4 Feb 2015 07:44:04 +0000 (05:44 -0200)] 
travis: also test with gcc 4.8 and 4.9

9 years agotravis: use kernel headers for testsuite
Lucas De Marchi [Tue, 3 Feb 2015 03:21:11 +0000 (01:21 -0200)] 
travis: use kernel headers for testsuite

Install kernel headers and export KDIR variable to point to right dir.

9 years agotestsuite: convert test-init function to use mod-simple.ko
Lucas De Marchi [Tue, 3 Feb 2015 07:17:10 +0000 (05:17 -0200)] 
testsuite: convert test-init function to use mod-simple.ko

9 years agobuild: let touch on directory as last step
Lucas De Marchi [Tue, 3 Feb 2015 07:17:49 +0000 (05:17 -0200)] 
build: let touch on directory as last step

We need to let these instructions in kmod to be the last executed ones.
Otherwise the subdirectory containing the modules could propagate up the
time access.

9 years agotestsuite: port test-dependencies to module-playground
Lucas De Marchi [Tue, 3 Feb 2015 02:24:33 +0000 (00:24 -0200)] 
testsuite: port test-dependencies to module-playground

9 years agotestsuite: make test-dependencies use DEFINE_TEST
Lucas De Marchi [Tue, 3 Feb 2015 01:55:56 +0000 (23:55 -0200)] 
testsuite: make test-dependencies use DEFINE_TEST

It went missing from previous conversions.

9 years agotestsuite: use mod-simple.ko for search-order-same-prefix test
Lucas De Marchi [Tue, 3 Feb 2015 00:35:02 +0000 (22:35 -0200)] 
testsuite: use mod-simple.ko for search-order-same-prefix test

9 years agotestsuite: beef up module-playground in the build system
Lucas De Marchi [Tue, 3 Feb 2015 00:26:06 +0000 (22:26 -0200)] 
testsuite: beef up module-playground in the build system

Instead of shipping pre-compiled module, this prepares the build system
to be able to compile the necessary modules from module-playground. This
preparations starts by replacing md5.ko with our own dummy
mod-simple.ko, built from source. It works by copying the modules to
their final location while preparing the rootfs.

9 years agoUpdate TODO
Lucas De Marchi [Tue, 27 Jan 2015 01:31:04 +0000 (23:31 -0200)] 
Update TODO

9 years agotestsuite: add tests for kmod_list
Caio Marcelo de Oliveira Filho [Mon, 26 Jan 2015 11:47:09 +0000 (09:47 -0200)] 
testsuite: add tests for kmod_list

Some tests cover internal API that wasn't used
elsewhere. The choice here was to test and keep the
list implementation complete instead of removing it.

9 years agoRevert "build: enable LTO and _FORTIFY_SOURCE with optimization"
Lucas De Marchi [Mon, 26 Jan 2015 21:07:12 +0000 (19:07 -0200)] 
Revert "build: enable LTO and _FORTIFY_SOURCE with optimization"

This reverts commit 27bcc9111b63e94d091c3fa47e81fe52b806cd3e.

Let the distro decide about this flag. It's relatively recent and
doesn't work well with gcc 4.[678] making the testsuite to fail.

9 years agoFix uninitialized warning
Lucas De Marchi [Mon, 26 Jan 2015 01:54:05 +0000 (23:54 -0200)] 
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;

9 years agobuild: pass --no-undefined to linker
Lucas De Marchi [Mon, 26 Jan 2015 01:29:50 +0000 (23:29 -0200)] 
build: pass --no-undefined to linker

Do not allow undefined symbols.

9 years agobuild: enable LTO and _FORTIFY_SOURCE with optimization
Lucas De Marchi [Mon, 26 Jan 2015 01:28:46 +0000 (23:28 -0200)] 
build: enable LTO and _FORTIFY_SOURCE with optimization

If building with optimization enabled, enable LTO.

9 years agoutil: remove dead code in freadline_wrapped
Caio Marcelo de Oliveira Filho [Wed, 21 Jan 2015 11:37:23 +0000 (09:37 -0200)] 
util: remove dead code in freadline_wrapped

Each loop iteration starts with 'i < size'. When i is changed
the invariant is kept by checking if 'i == size' and growing the
buffer.

9 years agotestsuite: add more input cases to freadline_wrapped test
Caio Marcelo de Oliveira Filho [Wed, 21 Jan 2015 11:37:22 +0000 (09:37 -0200)] 
testsuite: add more input cases to freadline_wrapped test

9 years agotestsuite: add test for growing then shrinking a hash
Caio Marcelo de Oliveira Filho [Wed, 21 Jan 2015 11:37:21 +0000 (09:37 -0200)] 
testsuite: add test for growing then shrinking a hash

9 years agotestsuite: add test for hash_add_unique
Caio Marcelo de Oliveira Filho [Wed, 21 Jan 2015 11:37:20 +0000 (09:37 -0200)] 
testsuite: add test for hash_add_unique

9 years agotestsuite: improve coverage of shared/util.h
Lucas De Marchi [Wed, 14 Jan 2015 19:25:45 +0000 (17:25 -0200)] 
testsuite: improve coverage of shared/util.h

Add tests to improve coverage of shared/util.h functions.

9 years agotestsuite: improve assert report
Lucas De Marchi [Wed, 14 Jan 2015 18:28:16 +0000 (16:28 -0200)] 
testsuite: improve assert report

9 years agotools: prefer the use of streq()
Lucas De Marchi [Wed, 14 Jan 2015 16:22:23 +0000 (14:22 -0200)] 
tools: prefer the use of streq()

9 years agotestsuite: prefer the use of streq()
Lucas De Marchi [Wed, 14 Jan 2015 16:22:09 +0000 (14:22 -0200)] 
testsuite: prefer the use of streq()

9 years agotestsuite: test kmod_module_remove_module for failure
Lucas De Marchi [Wed, 14 Jan 2015 16:08:56 +0000 (14:08 -0200)] 
testsuite: test kmod_module_remove_module for failure

9 years agoshared: add STRINGFY macro
Lucas De Marchi [Wed, 14 Jan 2015 16:31:34 +0000 (14:31 -0200)] 
shared: add STRINGFY macro

9 years agotestsuite: fix retcodes parsing
Lucas De Marchi [Wed, 14 Jan 2015 16:05:24 +0000 (14:05 -0200)] 
testsuite: fix retcodes parsing

It was not saving _modules in modules and thus all check were falling in
the fallback "consider a success if module is not in the list". Also the
name check wasn't right: replace with streq().

The parsing could be better implemented, but this is left for later.

9 years agotools: kmod: use streq
Lucas De Marchi [Wed, 14 Jan 2015 14:28:02 +0000 (12:28 -0200)] 
tools: kmod: use streq

9 years agoCODING-STYLE: add include order
Lucas De Marchi [Wed, 14 Jan 2015 14:33:10 +0000 (12:33 -0200)] 
CODING-STYLE: add include order

9 years agotools: kmod: break iteration once a command is executed
Caio Marcelo de Oliveira Filho [Wed, 14 Jan 2015 14:02:16 +0000 (12:02 -0200)] 
tools: kmod: break iteration once a command is executed

9 years agoUpdate TODO
Lucas De Marchi [Wed, 14 Jan 2015 13:10:53 +0000 (11:10 -0200)] 
Update TODO

9 years agotestsuite: add test for array_pop()
Lucas De Marchi [Thu, 8 Jan 2015 19:10:18 +0000 (17:10 -0200)] 
testsuite: add test for array_pop()

9 years agobuild-sys: integrate coverage report
Lucas De Marchi [Wed, 7 Jan 2015 21:17:15 +0000 (19:17 -0200)] 
build-sys: integrate coverage report

Just pass --enable-coverage to configure and then "make coverage" to
have the coverage report at coverage dir.

9 years agotestsuite: do not overrid paths inside build
Lucas De Marchi [Wed, 7 Jan 2015 21:14:20 +0000 (19:14 -0200)] 
testsuite: do not overrid paths inside build

If we are accessing a file inside the build directory we should really
not trap the path. Right now this isn't important because we never do
such accesses. However it will be needed when gcov is integrated because
it dumps files to the same place where the binaries are located.

9 years agobuild-sys: rename cflags/ldflags variable
Lucas De Marchi [Fri, 2 Jan 2015 18:32:03 +0000 (16:32 -0200)] 
build-sys: rename cflags/ldflags variable

Not all of them are for warnings or gc.

9 years agoFix include in python bindings
Lucas De Marchi [Fri, 2 Jan 2015 15:10:52 +0000 (13:10 -0200)] 
Fix include in python bindings

Prefix the include of libkmod in python bindings.

9 years agolibkmod-elf: Remove unused variables
Lucas De Marchi [Fri, 2 Jan 2015 14:44:59 +0000 (12:44 -0200)] 
libkmod-elf: Remove unused variables

libkmod/libkmod-elf.c:52:34: warning: unused variable 'native_endianess'
      [-Wunused-const-variable]
static const enum kmod_elf_class native_endianess = KMOD_ELF_LSB;

9 years agoFix includes after change to build-sys
Lucas De Marchi [Fri, 2 Jan 2015 14:38:27 +0000 (12:38 -0200)] 
Fix includes after change to build-sys

Make the includes be libkmod/libkmod.h for code outside of library. This
fixes the broken build after 1315123 ('build-sys: Don't add libkmod
subdirectory to include path').

9 years agoRemove FSF mailing address
Lucas De Marchi [Fri, 26 Dec 2014 01:32:03 +0000 (23:32 -0200)] 
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.

9 years agobuild-sys: set -e separately, rather than putting -e in the shebang line
Lucas De Marchi [Fri, 26 Dec 2014 01:12:22 +0000 (23:12 -0200)] 
build-sys: set -e separately, rather than putting -e in the shebang line

Like a008d76 (autogen.sh: set -e separately, rather than putting -e in
the shebang line) in libabc by Josh Triplett.

9 years agobuild-sys: Don't define LIBEXECDIR
Lucas De Marchi [Fri, 26 Dec 2014 01:11:04 +0000 (23:11 -0200)] 
build-sys: Don't define LIBEXECDIR

Like b2fd181 (Makefile.am: Don't define LIBEXECDIR) in libabc by Josh
Triplett.

9 years agobuild-sys: Don't add libkmod subdirectory to include path
Lucas De Marchi [Fri, 26 Dec 2014 01:07:48 +0000 (23:07 -0200)] 
build-sys: Don't add libkmod subdirectory to include path

Like 05437b8 (Makefile.am: Don't add abc subdirectory to include path)
in libabc by Josh Triplett.

9 years agobuild: Do not force diagnostics-color flag
Mike Auty [Fri, 5 Dec 2014 00:49:13 +0000 (00:49 +0000)] 
build: Do not force diagnostics-color flag

The -fdiagnostics-color flag is only available on GCC >= 4.9, for
older versions this could raise an error in certain circumstances
(such as when using ccache).  Instead, since -fdiagnostic-color=auto
by default  in gcc-4.9, simply set the required environment variable
to the default one if it's undefined.

Based mostly on the systemd commit f44541bc by Michal Schmidt.

9 years agoREADME: move mailing list information to top
Lucas De Marchi [Sat, 13 Dec 2014 13:55:05 +0000 (11:55 -0200)] 
README: move mailing list information to top

It seems people are missing the information about the mailing list, so
let's move it to the top in hope it's more visible.

9 years agoutil: fix build on systems missing strndupa
Natanael Copa [Mon, 17 Nov 2014 08:36:29 +0000 (09:36 +0100)] 
util: fix build on systems missing strndupa

we need include shared/missing.h to be able to compile on sysmtes that
lacks strndupa.

9 years agoNEWS: Fix typos
Lucas De Marchi [Sun, 16 Nov 2014 12:37:45 +0000 (10:37 -0200)] 
NEWS: Fix typos

9 years agokmod 19 v19
Lucas De Marchi [Sun, 16 Nov 2014 12:24:50 +0000 (10:24 -0200)] 
kmod 19

9 years agolibkmod-index: move comment to include the includes
Lucas De Marchi [Tue, 28 Oct 2014 03:58:11 +0000 (01:58 -0200)] 
libkmod-index: move comment to include the includes

9 years agolibkmod-index: remove invalid comment
Lucas De Marchi [Tue, 28 Oct 2014 03:56:42 +0000 (01:56 -0200)] 
libkmod-index: remove invalid comment

9 years agodepmod: point to documentation in libkmod
Lucas De Marchi [Tue, 28 Oct 2014 03:52:49 +0000 (01:52 -0200)] 
depmod: point to documentation in libkmod

Instead of repeating all documentation, point to the documentation
available in libkmod-index.c

This also removes INDEX_PRIORITY_MIN that was not being used.

9 years agolibkmod-index: keep index and comments in .c
Lucas De Marchi [Tue, 28 Oct 2014 03:47:50 +0000 (01:47 -0200)] 
libkmod-index: keep index and comments in .c

Just like other source files, keep the index and comments in the source
file rather than the header.

This also removes INDEX_PRIORITY_MIN that was never being used.

9 years agostatic-nodes: indicate that creation of static nodes should only happen at boot
Tom Gundersen [Mon, 27 Oct 2014 16:55:03 +0000 (17:55 +0100)] 
static-nodes: indicate that creation of static nodes should only happen at boot

udev will only manage static nodes that exist at the time udev is started, so
creating static nodes later on will likely not behave as expected. In
particular, recreating the static nodes at run-time will reset any permissions
udev may have applied to the nodes at boot.

See <https://bugzilla.redhat.com/show_bug.cgi?id=1147248> and the discussion
following <http://permalink.gmane.org/gmane.comp.sysutils.systemd.devel/23795>.

Note that this requires (the yet to be released) systemd v217 or a backport
of systemd patch 8c94052ee543c3598a3c7b0c46688150aa2c6168.

9 years agostrbuf: make strbuf_pushchars() a little less dumb
Lucas De Marchi [Fri, 17 Oct 2014 00:39:33 +0000 (21:39 -0300)] 
strbuf: make strbuf_pushchars() a little less dumb

Do not push one char at a time. We have strlen() and memcpy() to rely
on.

9 years agostrbuf: do not calculate next step in size on all calls
Lucas De Marchi [Fri, 17 Oct 2014 00:22:32 +0000 (21:22 -0300)] 
strbuf: do not calculate next step in size on all calls

We only need to check if the new size is less or equal than the current
size. We don't really need to calculate the next step.

9 years agostrbuf: reduce default buffer size
Lucas De Marchi [Fri, 17 Oct 2014 00:02:13 +0000 (21:02 -0300)] 
strbuf: reduce default buffer size

Using 2048 as buffer sizer for strbuf is a bit exaggerated. strbuf is
used much more when we are not using mmapped indexes, but it's used for
mmapped when for example searching for an alias. A quick and dirty hack
to output the size of our strbufs is to print buf->used inside
strbuf_str(). Doing this and creating some statistics with:

while read xxx alias xxx; do
    tools/modprobe -R "$alias" > /dev/null;
done < /lib/modules/$(uname -r)/modules.alias 2>&1 | \
     Rscript -e 'summary (as.numeric (readLines ("stdin")))'

   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's
   1.00   29.00   31.00   31.55   38.00   92.00      26

So, reduce the step to 128, which is still greater than the maximum in
these cases. In the worst case this can only create a few calls to
realloc(), while keeping the memory footprint low for the common cases.

9 years agotestsuite: add tests for strbuf
Lucas De Marchi [Mon, 13 Oct 2014 21:42:01 +0000 (18:42 -0300)] 
testsuite: add tests for strbuf

9 years agoshared: rename prefixes of strbuf functions
Lucas De Marchi [Sat, 11 Oct 2014 16:25:51 +0000 (13:25 -0300)] 
shared: rename prefixes of strbuf functions

Use strbuf_ prefix instead of buf_.

9 years agoMove strbuf implementation to shared/
Lucas De Marchi [Sat, 11 Oct 2014 16:03:21 +0000 (13:03 -0300)] 
Move strbuf implementation to shared/

Just move the strbuf-like implementation to shared/. No renames were
made yet to avoid cluttering the diff. It will come in a separate patch.

9 years agotestsuite: remove now unused array of tests
Lucas De Marchi [Thu, 9 Oct 2014 17:29:04 +0000 (14:29 -0300)] 
testsuite: remove now unused array of tests

Remove the arrays and let each test with a guaranteed unique name.

9 years agotestsuite: use a section to put tests in instead of array
Lucas De Marchi [Thu, 9 Oct 2014 17:14:58 +0000 (14:14 -0300)] 
testsuite: use a section to put tests in instead of array

Intead of having to declare an array of tests, tweak the definition of
DEFINE_TEST and TESTSUITE_MAIN so they know the tests are put in a
particular section of the ELF file.

This avoids the mistake of adding a test and forgetting to add it to the
array. Now once a test is defined, it's ready to run, so one less step
to define new tests.

The removal of the arrays is left for another patch so not to clutter
the diff on this one.

9 years agoMove static keyword to DEFINE_TEST macro
Lucas De Marchi [Thu, 9 Oct 2014 16:00:30 +0000 (13:00 -0300)] 
Move static keyword to DEFINE_TEST macro

9 years agolibkmod: remove unused inline functions
Lucas De Marchi [Thu, 9 Oct 2014 14:07:33 +0000 (11:07 -0300)] 
libkmod: remove unused inline functions

libkmod/libkmod-list.c:39:33: warning: unused function 'list_node_next' [-Wunused-function]
static inline struct list_node *list_node_next(const struct list_node *node)
                                ^
libkmod/libkmod-list.c:47:33: warning: unused function 'list_node_prev' [-Wunused-function]
static inline struct list_node *list_node_prev(const struct list_node *node)
                                ^

It doesn't really matter in the end result since the compiler won't
generate any code for it. But let's keep it clean. It wasn't needed
until now, so probably it won't be anymore.

9 years agoChange parameter from int to char
Lucas De Marchi [Thu, 9 Oct 2014 14:03:29 +0000 (11:03 -0300)] 
Change parameter from int to char

It's a char not an int.

9 years agoLog error on failed underscores(), moving it to shared/
Lucas De Marchi [Thu, 9 Oct 2014 13:59:08 +0000 (10:59 -0300)] 
Log error on failed underscores(), moving it to shared/

Move underscores() to shared/. It's the same as alias_normalize(), but
it rather operates in place, with the same string being passed.

The difference now that it's in shared/ is that it's a non-logging
function.

This makes us a little bit more verbose: we don't accept partially
correct module and aliases names in kcmdline and in configuration files.
We log an error instead.

9 years agobuild-sys: rename libkmod-util convenience library
Lucas De Marchi [Thu, 9 Oct 2014 04:20:35 +0000 (01:20 -0300)] 
build-sys: rename libkmod-util convenience library

Now that all source code from libkmod-util has been moved to shared/
directory, rename also the convenience library to libshared.

9 years agoMove remaining functions from libkmod-util to shared
Lucas De Marchi [Thu, 9 Oct 2014 04:14:16 +0000 (01:14 -0300)] 
Move remaining functions from libkmod-util to shared

9 years agodepmod: use alias_normalize() from shared
Lucas De Marchi [Thu, 9 Oct 2014 03:54:29 +0000 (00:54 -0300)] 
depmod: use alias_normalize() from shared

Remove underscores2() function which is essentially the same as
alias_normalize() and the latter, which is now in shared/.

9 years agoMove alias_normalize() to shared
Lucas De Marchi [Thu, 9 Oct 2014 03:43:01 +0000 (00:43 -0300)] 
Move alias_normalize() to shared

9 years agoDo not rely on prio_to_str() being always inline
Lucas De Marchi [Thu, 9 Oct 2014 03:01:45 +0000 (00:01 -0300)] 
Do not rely on prio_to_str() being always inline

This function was declared as always-inline so there was not really a
problem in returning prioname, that could possibly point to the local
buf[] variable.

However static analysis tools are often confused about this and being
always-inline was just a workaround to make it work.

So, let's move the buffer to the caller. We have only 2 callers so it
doesn't matter much. This always reduce the size of log.o, since now the
function is not inlined anymore. Below is the size for "-g -O2" with
gcc:

before:
   text    data     bss     dec     hex filename
   1325       4       1    1330     532 tools/log.o

after:
   text    data     bss     dec     hex filename
   1171       4       1    1176     498 tools/log.o

9 years agoDo not export array of kmod extensions
Lucas De Marchi [Wed, 8 Oct 2014 17:33:42 +0000 (14:33 -0300)] 
Do not export array of kmod extensions

The only user outside of libkmod-util is depmod, which really only needs
to get the string for the extension of uncompressed modules. It doesn't
need to access the array itself.

9 years agotestsuite: add tests for array implementation
Lucas De Marchi [Wed, 8 Oct 2014 04:12:15 +0000 (01:12 -0300)] 
testsuite: add tests for array implementation

9 years agoClarify what licences apply where
Lucas De Marchi [Wed, 8 Oct 2014 02:23:11 +0000 (23:23 -0300)] 
Clarify what licences apply where

This doesn't change any license, just clarifies what's licensed under
LGPL and what's under GPL.

9 years agoRename getline_wrapped() to freadline_wrapped()
Lucas De Marchi [Fri, 3 Oct 2014 06:25:06 +0000 (03:25 -0300)] 
Rename getline_wrapped() to freadline_wrapped()

9 years agoPrefer inttypes.h over stdint.h
Lucas De Marchi [Fri, 3 Oct 2014 05:03:55 +0000 (02:03 -0300)] 
Prefer inttypes.h over stdint.h

9 years agoReorder and reorganize header files
Lucas De Marchi [Fri, 3 Oct 2014 04:41:42 +0000 (01:41 -0300)] 
Reorder and reorganize header files

Let the includes in the following order:

< system headers >
< libkmod >
< tool >
< local headers >