aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2014-04-01config: also parse softdeps from modulesHEADmasterTom Gundersen2-2/+2
This information can be found in /lib/modules/`uname -r`/modules.softdep, and has only recently been exported by the kernel. Also remove the advice about copying modules.softdep to /lib/modules as it is not clear how to do this correctly with several kernels installed with potentially conflicting soft dependencies.
2014-04-01libkmod: Ignore errors from softdepsMichal Marek3-4/+48
Before we had softdeps, the usual idiom was install foo /sbin/modprobe bar; /sbin/modprobe --ignore-install foo ignoring errors from the first modprobe invocation. This also matches the behavior of module-init-tools' implementation of softdep.
2014-03-26build-sys: add hooks to build python bindingsLucas De Marchi4-3/+89
Add --enable-python configure switch so we build the python bindings. We also pass version.py through SED_PROCESS macro, so the version is kept in sync with kmod. Acked-by: Andy Grover <agrover@redhat.com>
2014-03-26python: Remove unused files from importLucas De Marchi10-964/+0
Acked-by: Andy Grover <agrover@redhat.com>
2014-03-26Merge branch 'master' of python-kmodLucas De Marchi22-0/+1611
This is python-kmod is found in git@github.com:agrover/kmod.git d5b6f22639c077b86659828bcc78dcedc9daaa94 Its history has being rewritten to prepare for a merge: - Every commit has been prefixed with "python: " in its commit message - s-o-b's have been removed - Every file has been moved to libkmod/python directory Some files don't make much sense anymore and are being removed in this merge. Acked-by: Andy Grover <agrover@redhat.com>
2014-03-25python: Issue #15: resovled by using setuptools_cythonGuy Rozendorn1-9/+7
2014-03-25python: Issue #15: Cython needs to be in setup_requiresGuy Rozendorn1-1/+1
We need Cython BEFORE installing kmod (done with setup_requires), and AFTER installation - during runtime (done with install_requires)
2014-03-25python: Issue #15 Cython is now a dependencyGuy Rozendorn1-3/+9
2014-03-25python: update version to 0.9.1Andy Grover1-1/+1
2014-03-25python: Issue #13 skipping building extensions on non-Linux platformsGuy Rozendorn2-10/+16
2014-03-25python: Make kmod.modprobe() raise an error if no modules foundAndy Grover1-2/+12
Add 'quiet' option to override. Add docstring.
2014-03-25python: Add self as maintainer to setup.pyAndy Grover1-0/+2
2014-03-25python: Correct building for python 2.6Andy Grover1-1/+1
Reported-by: Oz Nahum Tiram <nahumoz@gmail.com>
2014-03-25python: add docstring to insert and remove methodsOz1-0/+14
2014-03-25python: add docstring to rmmodOz1-0/+4
2014-03-25python: update version to 0.9Andy Grover1-1/+1
2014-03-25python: Update READMEAndy Grover1-4/+4
Last update changed API slightly: * loaded_modules renamed to modules * returns a module object instead of (name, size)
2014-03-25python: MANIFEST.in: add AUTHORS to distibuted source files.W. Trevor King1-0/+1
2014-03-25python: Ran update-copyright.py.W. Trevor King14-93/+161
2014-03-25python: .update-copyright.conf: update to pipe separators.W. Trevor King1-2/+2
This brings the config file up to speed with the following update-copyright commit: commit 3c68a1a48419d8b2bbc2ce0e7f1700b996ec30e9 Author: W. Trevor King <wking@tremily.us> Date: Fri Oct 19 21:52:48 2012 -0400 project: for consistency, also separate ignored paths with pipes.
2014-03-25python: .update-copyright.conf: add MANIFEST.in to ignored files.W. Trevor King1-2/+5
2014-03-25python: .update-copyright.conf: add Red Hat alias for Andy Grover.W. Trevor King1-0/+3
He seems to be assigning copyright of files he writes to Red Hat. Avoiding .mailmap so the git log will still attribute changes to him. I'm not sure which name should go in the AUTHORS file.
2014-03-25python: .update-copyright.conf: add README.rst to ignored files.W. Trevor King1-1/+2
2014-03-25python: .mailmap: consolidate Andy Grover email addresses.W. Trevor King1-0/+1
2014-03-25python: .update-copyright.conf: add copyright configuration.W. Trevor King1-0/+18
Use my external update-copyright package to maintain copyright blurbs. http://pypi.python.org/pypi/update-copyright/
2014-03-25python: module: fix versions -> info typo in Module._info_get() error message.W. Trevor King1-1/+1
2014-03-25python: Initialize Kmod.mod_dir to None in __cinit__().W. Trevor King1-0/+1
2014-03-25python: Use an OrderedDict for Module.info (preserving modinfo ordering).W. Trevor King1-1/+3
2014-03-25python: Add Module.info attribute.W. Trevor King2-0/+26
2014-03-25python: Use Cython's libc.errno for EEXIST.W. Trevor King2-5/+3
2014-03-25python: Add Module.versions attribute.W. Trevor King2-0/+29
2014-03-25python: README.rst: add .rst symlink for GitHub.W. Trevor King1-0/+1
2014-03-25python: README: mention Cython dependency.W. Trevor King1-1/+1
2014-03-25python: README: cleanup reStructuredText syntax.W. Trevor King1-20/+13
2014-03-25python: Add missing copyright blurbs.W. Trevor King11-0/+122
2014-03-25python: Add docstrings to kmod.kmod and kmod.kmod.Kmod.W. Trevor King1-0/+3
2014-03-25python: MANIFEST.in: add missing source to the sdist tarball.W. Trevor King2-0/+4
2014-03-25python: Add additional out Module attributes (path, refcnt, ...).W. Trevor King4-8/+52
2014-03-25python: Convert to Cython.W. Trevor King13-277/+356
With Cython we get easier memory handling and Python 3 compatibility.
2014-03-25python: update FSF address in COPYING and COPYING.LESSERAndy Grover2-2/+2
Please FSF, never move again.
2014-03-25python: whitespaceAndy Grover1-31/+30
2014-03-25python: add proper error handling to loaded_modules()Andy Grover1-2/+19
We need to check the result of basically all Py* calls and cleanup properly if they fail.
2014-03-25python: Improve README's description of kmodAndy Grover1-3/+6
Based on text from kmod's README.
2014-03-25python: Make setup.py version match version in .cAndy Grover1-1/+1
2014-03-25python: Add READMEAndy Grover1-0/+44
2014-03-25python: More cleanup and renaming of stuff. Add docstrings.Andy Grover1-27/+40
2014-03-25python: Add support for listing loaded modules, modprobe, rmmodAndy Grover2-25/+140
And other misc. cleanups and changes.
2014-03-25python: use c99 init for struct initAndy Grover1-52/+25
move casts of pyobject -> kmodobject to the functions from the struct init.
2014-03-25python: a skeleton that compilesAndy Grover1-183/+3
2014-03-25python: initial checkinAndy Grover4-0/+1190
2014-03-24build-sys: try harder to shut up compiler wrt strict-aliasingLucas De Marchi1-1/+1
With -Wstrict-aliasing=2 we get the following warning: libkmod/libkmod-signature.c:124:20: note: in expansion of macro 'get_unaligned' sig_len = be32toh(get_unaligned(&modsig->sig_len)); However there's nothing wrong with it. modsig->sig_len is uint32_t and get_unaligned in this case returns uint32_t. There's notstrict aliasing violation.
2014-03-24libkmod: Fix unaligned accessLucas De Marchi1-1/+1
From Jan Engelhardt: Program received signal SIGBUS, Bus error. [Switching to process 11100] 0x00035278 in kmod_module_signature_info (file=0x4eeb8, sig_info=0xffffc254) at libkmod/libkmod-signature.c:124 124 sig_len = be32toh(modsig->sig_len); (gdb) p modsig $1 = (const struct module_signature *) 0xf7dfe143 modsig->sig_len can be unaligned if modsig is unaligned, so the padding in the struct has no effect since we are mapping it to the mem buffer.
2014-03-24build-sys: Remove -Werror from CFLAGSLucas De Marchi2-2/+2
Just let the warnings be emmited, but don't fail on them.
2014-03-24build-sys: Remove bogus line causing warningLucas De Marchi1-1/+0
./configure: line 14316: xyes: command not found We are not using have_manpages, so remove it.
2014-03-19Add test for depmod using search dirs with same prefixLucas De Marchi9-0/+59
Test depmod with search dirs "foo" and "foobar". Previously to 49b33c1 ("depmod: do not allow partial matches with "search" directive") we were failing this test due to matching the prefix without checking if it's the full dir name. We are adding 2 tests here in order to catch the case we only pass the test due to processing the directories in a favourable order.
2014-03-19depmod: do not allow partial matches with "search" directiveAnssi Hannula1-2/+2
Currently e.g. "search foo foobar built-in" will cause unpredictable results if baz.ko is in both foo/ and foobar/, since "foo" in search may match both of those directories and the preferred module therefore depends on processing order. Fix the code to ensure that the match is performed on full pathname components only.
2014-03-19Add test for simple search order in depmodLucas De Marchi5-0/+29
2014-03-19depmod: fix debug print parameter orderAnssi Hannula1-1/+1
2014-03-07libkmod-elf: Fix check by class in get_modversions()Lucas De Marchi1-1/+1
Commit 51c409b ("Cache the offset of crc") unintentinally changed the comparison "if (elf->class & KMOD_ELF_32)" to "if (elf->class == KMOD_ELF_32)". This has been reported by Serge Voilokov <serge0x76@gmail.com>: On Raspberry PI elf->class equals KMOD_ELF_32|KMOD_ELF_LSB so valid condition should be (elf->class & KMOD_ELF_32) instead of (elf->class == KMOD_ELF_32). This fixes "modprobe --dump-modversions" failing on 32b systems.
2014-03-06testsuite: Fix uname() during glibc startupMichal Marek1-8/+16
In a specific configuration (chroot with the linux32 personality), the modprobe_install_cmd_loop test failed, because the bash process handling the install command segfaulted. The backtrace showed a uname() call during libpthread initialization, at which point the environ pointer hadn't been initialized yet: Program terminated with signal SIGSEGV, Segmentation fault. #0 0x080c1591 in getenv (name=<optimized out>, name@entry=0xf775f850 "TESTSUITE_UNAME_R") at getenv.c:81 81 for (i = 0, len = strlen (name); environ[i]; i++) (gdb) bt #0 0x080c1591 in getenv (name=<optimized out>, name@entry=0xf775f850 "TESTSUITE_UNAME_R") at getenv.c:81 #1 0xf775f754 in uname (u=u@entry=0xff946350) at testsuite/uname.c:32 #2 0xf74ffc6c in is_smp_system () at ../nptl/sysdeps/unix/sysv/linux/i386/smp.h:39 #3 __pthread_initialize_minimal_internal () at nptl-init.c:460 #4 0xf74fe32c in _init () at ../sysdeps/i386/crti.S:74 #5 0x00000000 in ?? () (gdb) p environ $1 = (char **) 0x0 I don't know why it only happend in the chroot, but glibc can call its own functions and impose any restrictions before main() is started, so we have to adapt. Also, do not return error if there is an environment, but the environment variable is not found. If uname() is called by kmod, then the respective test will simply fail later. If it's something else calling uname(), then we do not want to disturb the program.
2014-03-06man: use systemd as example instead of udevLucas De Marchi1-3/+5
Nowadays udev doesn't create nodes in /dev anymore. This role is rather taken by systemd-tmpfiles on early boot so reference it generically as systemd.
2014-03-06man: clarify the support to modules.dep fileLucas De Marchi2-11/+11
2014-03-06build-sys: Do not require xsltproc for installation of man pagesLucas De Marchi1-4/+2
Same reason as found in this commit to systemd: commit 4ca39b280fce3c60d2fdecbd478fd9bf7f9d3e64 Author: Mike Gilbert <floppym@gentoo.org> Date: Sun Feb 23 11:21:13 2014 -0500 configure: Do not require xsltproc for installation of man pages The release tarballs ship with pre-generated man pages, so we do not need xsltproc for a typical end-user build. Developers will probably have xsltproc anyway, but if not they will now encounter a build-time failure instead of an error in configure.
2014-03-06build-sys: add small redirecting MakefilesLucas De Marchi6-2/+47
These redirecting makefiles simplifies compiling from some editors and when CWD is not the root of the source tree. This is similar to what was introduced in systemd in 340d89e ("build-sys: add small redirecting Makefiles to simplify compilation from within emacs")
2014-03-06testsuite: add test for '.' correctly parsed in param's valueLucas De Marchi3-0/+30
In kcmdline it's possible to have a dot in the param's value. The support for this was added in 66f3228 ("libkmod: Add support for '.' in module parameter on kcmdline") and is needed to correctly support some modules that depend on it. This test was added in order to make sure the commit aa87854 ("libkmod-config: Only match dot before '=' in /proc/cmdline") didn't break it. Although that commit message says it's allowing to match a dot before '=' it's actually enforcing the first part of the string to be always in the format "<module-name>.param". Dots after '=' are still correctly allowed.
2014-03-06testsuite: add test to ignore unrelated strings in kcmdlineLucas De Marchi3-0/+31
Strings unrelated to modules and modprobe should be ignored and not appear in the output of "modprobe -c". This adds a test for the fix provided in aa87854 ("libkmod-config: Only match dot before '=' in /proc/cmdline").
2014-03-06testsuite: give a more suitable description to testLucas De Marchi1-1/+1
We are not only checking if those options are correctly parsed from kcmdline, but if in fact they are being passed to the final (f)init_module call. This is why we use 'modprobe --show-depends' instead of the simpler 'modprobe -c'.
2014-03-06testsuite: add test for kcmdline params with no valueLucas De Marchi3-0/+31
Use "modprobe -c" to dump the configuration. Since we configure our rootfs to have only a /proc/cmdline file, this should dump the knowledge we have from its parsed content. Test if <module>.option, without any value is correctly parsed, as fixed in commit 493dc65 ("libkmod: Fix getting param with no value from kcmdline")
2014-03-05libkmod-config: Only match dot before '=' in /proc/cmdlineMichal Marek1-3/+8
Otherwise, we also parse strings like BOOT_IMAGE=/boot/vmlinuz-3.12.12-57.g5f654cf-default In practice, this is not a problem, because there is no module named BOOT_IMAGE=/boot/vmlinuz-3. It just disturbs in modprobe -c output.
2014-03-05libkmod-config,depmod: Accept special files as configuration files, tooMichal Marek2-9/+2
If we can open it and read it, it's good enough for us. Otherwise, we cannot use -C /dev/null to skip the system configuration for instance: $ ./tools/modprobe -C /dev/null -c libkmod: ERROR libkmod/libkmod-config.c:821 conf_files_list: unsupported file mode /dev/null: 0x21b6 ...
2014-03-05libkmod-module: Simplify kmod_module_insert_module()Michal Marek1-17/+10
Store the file and elf pointer in the kmod_module structure and have it freed together with the module.
2014-03-05Add some tests for kernels without finit_module(2)Michal Marek23-0/+62
2014-03-05testsuite: Do not provide finit_module(2) on older kernelsMichal Marek1-0/+24
If the test's uname -r is less that 3.8, return -ENOSYS from finit_module(), so that the fallback is tested.
2014-03-05testsuite: Add test for modprobe --forceMichal Marek12-0/+31
There is no check if the correct flags are passed to finit_module, but at least we cover the respective code path in kmod.
2014-03-05testsuite: Check the list of loaded modules after a testMichal Marek4-6/+199
Add a ->modules_loaded member to struct test, which is a comma-separated list of modules that should be present after the test finishes. Both missing and excess modules cause an error.
2014-01-26Remove "rmmod -w" documentation and getopt entryStephen Kitt2-18/+0
This patch removes the cmdopts declaration and the documentation. They were leftover from the -w removal.
2014-01-24man: insmod documentation fixLukas Berk1-1/+1
Add comma between lsmod(8) and modinfo(8) Signed-off-by: Lukas Berk <lberk@redhat.com>
2014-01-21Remove duplicate includesLucas De Marchi1-1/+0
Found by https://raw.github.com/karelzak/util-linux/master/tools/checkincludes.pl
2014-01-02man: Change my contact email addressLucas De Marchi9-9/+9
2013-12-22kmod 16Lucas De Marchi3-2/+4
2013-12-17Use C11's noreturnLucas De Marchi7-14/+32
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>.
2013-11-18module: use _cleanup_free and remove useless call to free()Lucas De Marchi1-9/+5
2013-11-18file: use _cleanup_free_Lucas De Marchi1-4/+4
2013-11-18array: avoid duplicate code to reallocateLucas De Marchi1-19/+19
2013-11-18util: Be OOM-safe and use _cleanup_free_Lucas De Marchi1-14/+25
2013-11-18testsuite: add basic test for getline_wrappedLucas De Marchi3-0/+43
2013-11-18util: use _cleanup_free_ on path_make_absolute_cwd()Lucas De Marchi1-7/+6
2013-11-18config: Use _cleanup_free_Lucas De Marchi1-40/+22
2013-11-18util: Add cleanup attributeLucas De Marchi2-0/+8
2013-11-18testsuite: Move test-alias to test-utilLucas De Marchi4-8/+8
Move file so we can use the same file to test other functions from libkmod-util.c
2013-11-10build: Allow disabling maintainer modeAnders Olofsson1-0/+1
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.
2013-10-26build-sys: enable colored diagnostics if availableLucas De Marchi1-0/+1
2013-10-10Makefile.am: add mkdir testsuiteSaul Wold1-1/+1
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.
2013-10-10Makefile.am: Add target to all cross-compilation of testsuiteSaul Wold1-0/+3
The buildtest-TESTS target allows for cross-compilation of the testsuites without the actual running of the tests that check normally does.
2013-09-20NEWS: add entriesLucas De Marchi1-0/+8
2013-09-20rmmod: remove --wait optionLucas De Marchi1-11/+5
Let libkmod enforce KMOD_REMOVE_NOWAIT.
2013-09-20libkmod: always pass O_NONBLOCK to kernelLucas De Marchi3-11/+16
Not passsing O_NONBLOCK to delete_module() is deprecated since kmod 11 and is being removed from the kernel. Force this flag in libkmod.
2013-09-20libkmod-hash: always align n_buckets to power of 2Lucas De Marchi1-6/+9
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.
2013-09-20util: Add ALIGN_POWER2Lucas De Marchi1-0/+5
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
2013-09-10depmod: warn on invalid devname specificationTom Gundersen1-3/+10
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>
2013-09-06build: remove check for typeofLucas De Marchi2-7/+0
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.
2013-09-06Add configure check for _Static_assert()Thomas Petazzoni2-0/+11
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.
2013-08-29Fix usage of readdir_r()Lucas De Marchi3-64/+26
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.
2013-08-29testsuite: fix usage of reserved namesJohn Spencer7-26/+26
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.
2013-08-22kmod 15Lucas De Marchi3-3/+9
2013-08-13libkmod: Fix getting param with no value from kcmdlineLucas De Marchi1-1/+1
2013-08-13testsuite: Add test for parameter with no value in kcmdlineLucas De Marchi14-0/+33
Currently we fail to add the module option if the parameter doesn't have a value.
2013-08-09depmod: add missing "else" clauseJan Engelhardt2-2/+2
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.
2013-08-02shell-completion: Make options accept '=' as last charLucas De Marchi1-7/+29
2013-07-30build: Install bash completion dataLucas De Marchi2-2/+17
2013-07-30shell-completion: Add kmod static-nodesLucas De Marchi1-0/+25
2013-07-30shell-completion: Add initial completion for kmodLucas De Marchi2-1/+57
Based on journalctl and udevadm from systemd and adapted to kmod needs.
2013-07-17NEWS: Add entriesLucas De Marchi1-0/+10
2013-07-17README: Move items from TODOLucas De Marchi3-52/+58
Put the differences between kmod and module-init-tools in the README file so it's more visible.
2013-07-15static-nodes: create parent directories of output fileTom Gundersen1-3/+9
Allows us to drop call to "mkdir -p" from the systemd service file.
2013-07-15util: Add mkdir_parents()Lucas De Marchi2-0/+12
Like mkdir_p, but discards the leaf, creating the parent directories.
2013-07-15util: Add len arg to mkdir_p()Lucas De Marchi3-6/+7
2013-07-15static-nodes: don't fail if modules.devname not foundTom Gundersen1-12/+19
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.
2013-07-15util: Add mkdir_p implementation from testsuiteLucas De Marchi6-109/+62
2013-07-15testsuite: Fix mkdir_p corner casesLucas De Marchi1-19/+32
- 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)
2013-07-04Use "-internal" suffix instead of "-private"Lucas De Marchi14-21/+21
2013-07-04tools: Do not link dynamically with libkmodLucas De Marchi4-18/+13
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.
2013-07-03kmod 14Lucas De Marchi3-2/+21
2013-07-02tools: Use test/kmod instead of kmod-nolibLucas De Marchi5-16/+16
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
2013-07-01static-nodes: Better -f option descriptionLucas De Marchi1-1/+1
2013-06-06build-sys: do not allow --enable staticLucas De Marchi1-0/+4
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.
2013-05-11Add travis-ci config fileLucas De Marchi1-0/+17
Experiment with a build bot.
2013-05-11libkmod: Avoid calling syscall() with -1Jan Luebbe1-0/+7
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.
2013-05-11Revert "missing: Don't call syscall() with syscallno == -1"Lucas De Marchi1-6/+4
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.
2013-05-04Add document for exported enumsChengwei Yang2-6/+44
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<----------
2013-05-04Several minor fixes for documentationChengwei Yang2-9/+9
2013-05-02modprobe: don't check refcount with remove commandJohannes Berg1-1/+1
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>
2013-05-02missing: Don't call syscall() with syscallno == -1Lucas De Marchi1-4/+6
Reported-by: Jean-Francis Roy <jeanfrancis@funtoo.org> Reported-by: Jan Luebbe <jlu@pengutronix.de>
2013-04-30Fix coding styleLucas De Marchi1-2/+2
Either with space or without, not a mix of both.
2013-04-30TODO: Add some entriesLucas De Marchi1-0/+6
2013-04-23libkmod-index: Return early if readroot failedLucas De Marchi2-2/+10
2013-04-23libkmod-module: Don't pass NULL ctx to kmod_logLucas De Marchi1-1/+1
2013-04-23libkmod-module: Don't pass NULL pointer to memcpyLucas De Marchi2-3/+9
When passing n=0, don't pass a NULL pointer, but instead pass anything else (like the pointer to the start of the string).
2013-04-21build-sys: Add AM_V_XSLT to rule creating man pagesLucas De Marchi1-1/+5
2013-04-21Add format attribute and fix issuesLucas De Marchi5-9/+13
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.
2013-04-19static-nodes: Fix indentationLucas De Marchi1-162/+170
kmod uses tab instead of spaces and tries to honour 80chr limit, when that doesn't worsen the readability.
2013-04-19static-nodes: tmpfiles - also create parents directories of device nodesTom Gundersen1-3/+11
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
2013-04-17kmod: It's an error not to have modules.devnameLucas De Marchi1-2/+3
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.
2013-04-16tools: add static-nodes toolTom Gundersen4-1/+250
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'.
2013-04-15Use static assertions for sizeof checksLucas De Marchi1-5/+5
2013-04-15Use _Static_assertLucas De Marchi1-29/+7
Both GCC and clang already supports C11's _Static_assert, so use it instead of defining our own macro.
2013-04-12testsuite: errno is a positive numberLucas De Marchi1-1/+1
2013-04-09TODO: update and reorderLucas De Marchi1-11/+10
2013-04-09kmod 13Lucas De Marchi3-2/+24
2013-04-09build-sys: Always enable parallel testsLucas De Marchi1-1/+1
Automake < 1.13 doesn't enable parallel tests by default, so add it to our automake options.
2013-04-09testsuite: Fix checking __sysnoLucas De Marchi1-5/+5
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.
2013-04-09testsuite: Wrap syscall() to get calls to finit_module()Lucas De Marchi1-0/+36
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.
2013-04-09libkmod: Move finit_module() definition to missing.hLucas De Marchi4-8/+19
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
2013-04-09libkmod: Add missing definitionsLucas De Marchi4-2/+15
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.
2013-04-04libkmod: Use secure_getenv if availableCristian Rodríguez3-1/+11
"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."
2013-03-21modprobe: Fix assertion on --show-depends with bogus config fileLucas De Marchi2-3/+6
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.
2013-03-21testsuite: Add test to check if modprobe explodes on bogus configLucas De Marchi14-0/+36
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.
2013-03-21testsuite: Exit with success on signal if test has expected_fail=trueLucas De Marchi1-1/+1
2013-03-19libkmod-util: Add missing include fileLucas De Marchi1-0/+1
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]
2013-03-18rmmod: Teach rmmod about builtin modulesJosh Boyer1-1/+7
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.
2013-02-19libkmod: fix address argument to mmap callsKees Cook2-3/+4
The first argument to mmap should be "NULL" instead of "0".
2013-02-19testsuite: handle finit_moduleKees Cook1-0/+24
This adds the finit_module logic to the testsuite.
2013-02-19libkmod: add finit_module logicKees Cook4-0/+47
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.
2013-01-17testsuite: Add modinfo test for module signaturesMichal Marek4-1/+26
2013-01-17libkmod: Return module signature information in kmod_module_get_info()Michal Marek4-2/+196
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.
2013-01-17libkmod-module: Do not free the list in kmod_module_info_appendMichal Marek1-7/+8
In error case, just return NULL and let the caller free the list.
2013-01-16Update copyright noticesLucas De Marchi39-39/+39
2013-01-16libkmod-module: Add helper for building the module info listMichal Marek1-19/+22
2013-01-15gitignore: ignore files generated by Automake's testsuiteLucas De Marchi2-0/+21
These files are generated by Automake 1.13 when running the testsuite.
2013-01-07man: fix lib dir in which we look for configLucas De Marchi1-1/+1
Thanks to William Hubbs <w.d.hubbs@gmail.com> for spotting the bug.
2012-12-31depmod: fix builtin symbols resolution when the prefix symbol is setAndrey Mazo1-7/+12
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.
2012-12-13depmod: --symbol-prefix actually requires an argumentAndrey Mazo1-1/+1
-P requires and uses an argument but its long counterpart --symbol-prefix does not: depmod: option '--symbol-prefix' doesn't allow an argument
2012-12-05kmod 12v12Lucas De Marchi3-2/+12
2012-11-28depmod: fix checking file extensionLucas De Marchi1-2/+3
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.
2012-11-28Use bool instead of intLucas De Marchi2-3/+3
Also change the last field initializer in array to be empty.
2012-11-28fix is_module_filename()Aleksey Makarov4-46/+37
modinfo fails if there is a ".ko" substring in the path to the module
2012-11-21libkmod-module: mangle the section header, not the sectionLucas De Marchi1-13/+41
When we are told to remove the "__versions" section we were mangling that section instead of tweaking the SHF_ALLOC flag in its header.
2012-11-21libkmod-module: Remove key+value vermagic from .modinfo sectionLucas De Marchi1-1/+0
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.
2012-11-16depmod: fix asserting mod->kmod == NULLLucas De Marchi1-1/+1
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.
2012-11-16depmod: fix hash lookup by relpath instead of uncrelpathLucas De Marchi1-3/+3
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.
2012-11-08kmod 11v11Lucas De Marchi3-2/+30
2012-11-08TODO: remove completed actionLucas De Marchi1-2/+0
2012-11-06tools: use program_invocation_short_name provided by libcLucas De Marchi8-19/+17
Thanks to Dave Reisner for pointing this out.
2012-11-06tools: staticize functions that are now only used in log.cLucas De Marchi2-51/+43
2012-11-06tools: share function for loggingLucas De Marchi7-122/+36
2012-11-06tools: share setting up libkmod logLucas De Marchi5-5/+17
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.
2012-11-06tools: use a single function for logging libkmod outputLucas De Marchi5-75/+86
2012-11-06tools: make usage() messages go to stdout rather than stderrLucas De Marchi5-10/+5
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.
2012-11-06tools: share function to convert prio to stringLucas De Marchi6-66/+61
No change is expected in the final binary since right now only an inline function is shared. Later we expect to share more code.
2012-11-06tools: share getting program name from argv for all toolsLucas De Marchi8-28/+34
2012-11-05rmmod: route all messages to syslog if told toLucas De Marchi1-20/+73
2012-11-05rmmod: prefer ERR over plain fprintfLucas De Marchi1-16/+13
2012-11-05modinfo: prefer ERR over plain fprintfLucas De Marchi1-16/+14
2012-11-05insmod: prefer ERR over plain fprintfLucas De Marchi1-11/+11
2012-11-05depmod: add depmod prefix to log messagesLucas De Marchi1-1/+1
2012-11-05depmod: remove inline from _logLucas De Marchi1-1/+1
2012-11-05TODO: update file with tasksLucas De Marchi1-10/+3
2012-11-05depmod: prefer ERR and WRN over plain fprintfLucas De Marchi1-11/+7
2012-11-01modprobe: use ERR() instead of fprintf(stderr, ...)Lucas De Marchi1-30/+32
2012-11-01modprobe: prefix log messages to stderr with modprobeLucas De Marchi1-3/+3