aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2013-09-20NEWS: add entriesHEADmasterLucas 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 15v15Lucas 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 14v14Lucas 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 13v13Lucas 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
2012-11-01modprobe: move log functionLucas De Marchi1-29/+29
2012-11-01modprobe: prefix libkmod messages to stderr with modprobe:Lucas De Marchi1-7/+18
When we are logging to stderr we are previously relying on libkmod sending it to the default location in case we are not asked to log to syslog. The problem is that modprobe may be used in scripts that don't want to log to syslog (since they are not daemons, like scripts to generate initrd) and then it's difficult to know where the message comes from. This patch treats only the messages coming from libkmod.
2012-10-31modprobe: use prio_to_str() helperLucas De Marchi1-39/+25
2012-10-31modprobe: exit in one placeLucas De Marchi1-8/+5
2012-10-30depmod: unref kmod_module once we don't need it anymoreLucas De Marchi1-3/+6
Once we read all we need from a module, unref it so any resource taken by it (including the mmap to access the file in libkmod) will be dropped. This drastically reduces the number of open file descriptors and also the memory needed, with no performance penalties. Rather, there's a small speedup of ~2.6%. Running depmod in a laptop with 2973 modules and comparing the number of open file descriptors for kmod-10, before and after the last patches to depmod (caaf438cb681c5b5b5b3c32e5b6bd12e96993dd7 and HEAD) we have: Before: 2980 simultaneously open fds After: 7 simultaneously open fds kmod-10: 7 simultaneously open fds So now we have the speedup of caching the file in kmod_module without the drawback of increasing the number of open file descriptors.
2012-10-30depmod: use our copy of modname instead of calling libkmodLucas De Marchi1-10/+6
In depmod_module_add() we already called kmod_module_get_name() and copied the string to our struct. Use it instead of calling again and again the libkmod function.
2012-10-30depmod: cache dependency_symbol list in struct modLucas De Marchi1-11/+15
The overall goal is to coalesce the accesses to a file that is the backend of a module. This commit addresses the calls to kmod_module_get_get_dependency_symbols(). Calling it earlier, while we are iterating the modules allows us to free the struct kmod of each module much sooner. We are still not freeing it since there are other places that must be refactored first. There's a performance penalty of ~2.5% from previous commit.
2012-10-30depmod: cache info_list in struct modLucas De Marchi1-32/+22
The overall goal is to coalesce the accesses to a file that is the backend of a module. This commit addresses the calls to kmod_module_get_info(). Calling it earlier, while we are iterating the modules allows us to free the struct kmod of each module much sooner. We are still not freeing it since there are other places that must be refactored first. A nice side effect is that this commit reduces in ~33% the calls to malloc(), giving a speedup of ~6% for cold caches (reproduced on only 1 laptop).
2012-10-30depmod: do not create a hole in struct depmodLucas De Marchi1-1/+1
2012-10-23build-sys: use AS_IF autoconf macroLucas De Marchi1-2/+2
Just for consistency with the rest.
2012-10-22build-sys: require xsltproc when manpages are enabledSami Kerola1-1/+4
Before this commit the build system failed at late state with non-helpful message when xsltproc was not available. Making all in man GEN depmod.d.5 /bin/sh: --nonet: command not found make[2]: *** [depmod.d.5] Error 127 make[1]: *** [all-recursive] Error 1 make: *** [all] Error 2
2012-10-18libkmod: cache open file for later accessLucas De Marchi3-112/+54
If we are accessing several times the modules and reading some sections by sucessive calls to the functions below, we are incurring in a penalty of having to open, parse the header and close the file. For each function. - kmod_module_get_info() - kmod_module_get_versions() - kmod_module_get_symbols() - kmod_module_get_dependency_symbols() These functions are particularly important to depmod. It calls all of them, for each module. Moreover there's a huge bottleneck in the open operation if we are using compression. Every time we open the module we need to uncompress the file and after getting the information we need we discard the result. This is clearly shown by profiling depmod with perf (record + report), using compressed modules: 64.07% depmod libz.so.1.2.7 [.] 0x00000000000074b8 ◆ 18.18% depmod libz.so.1.2.7 [.] crc32 ▒ 2.42% depmod libz.so.1.2.7 [.] inflate ▒ 1.17% depmod libc-2.16.so [.] __memcpy_ssse3_back ▒ 0.96% depmod [kernel.kallsyms] [k] copy_user_generic_string ▒ 0.89% depmod libc-2.16.so [.] __strcmp_sse42 ▒ 0.82% depmod [kernel.kallsyms] [k] hrtimer_interrupt ▒ 0.77% depmod libc-2.16.so [.] _int_malloc ▒ 0.44% depmod kmod-nolib [.] kmod_elf_get_strings ▒ 0.41% depmod kmod-nolib [.] kmod_elf_get_dependency_symbols ▒ 0.37% depmod kmod-nolib [.] kmod_elf_get_section ▒ 0.36% depmod kmod-nolib [.] kmod_elf_get_symbols ... Average of running depmod 5 times, dropping caches between them, in a slow spinning disk: Before: 12.25 +- 0.20 After: 8.20 +- 0.21 m-i-t: 9.62 +- 0.27 So this patch leads to an improvement of ~33% over unpatched version, ending up with 15% speedup over module-init-tools.
2012-10-17rmmod: Deprecate --wait optionLucas De Marchi2-5/+5
Remove --wait from usage() and give a message + sleep(10) if user is in fact using it.
2012-10-12libkmod-hash: Plug possible memory leak when free_value is definedLeandro Pereira1-1/+5
Although the hash table implementation allows passing a callback function to free a value when it is removed from the hash table, hash_del() wasn't freeing it if it was provided. Now it does. As a bonus, it now checks if the callback is set in hash_add() as well.
2012-10-09libkmod: Add support for '.' in module parameter on kcmdlineLucas De Marchi1-2/+4
Otherwise we fail to parse arguments in kernel command line like testmodule.testparam=1.5G Suggested-by: Selim T. Erdogan <selim@alumni.cs.utexas.edu>
2012-10-04testsuite: add depmod test for modules.aliasLucas De Marchi9-1/+113
Check if modules.alias is correctly generated from modules.order if we have compressed modules.
2012-10-04testsuite: allow to check generated filesLucas De Marchi2-0/+106
This gives the test cases the ability to supply files that must be checked after the test is run, rather than just checking stdout/stderr. This is intended to be used with tools that generate files, like depmod. It includes a poor's man implementation of a "check for differences in files". Not really optimized, but it's simple enough and does what it proposes to.
2012-10-03depmod: fix parsing of modules.order with compressed modulesLucas De Marchi1-17/+29
We now index the modules by uncompressed-relative-path instead of relative-path. This is because the file modules.order, coming from kernel, always comes with uncompressed paths. This fixes the issue of not sorting the aliases correctly due to paths not matching when using compressed modules.
2012-10-02build-sys: Remove --with-rootprefix optionDave Reisner6-19/+11
This is a broken option that only leads to misery and incompatabilities with other systems. Kbuild doesn't come close to supporting directories other than /lib/modules with several targets simply failing without hacky fixes. Simply remove the option and all traces of it, as it doesn't make sense in today's world.
2012-09-14build-sys: Append -Werror when testing flagsLucas De Marchi1-1/+1
Clang doesn't treat unknown warnings flags as an error, but rather as a warning. The result is that the detection for whic CFLAGS are supported by this compiler will not work, since the compilation will succeed. With this patch we now successfully detect clang doesn't support -Wlogical-op, as opposed to previous behavior: checking if clang supports flag -Wlogical-op in envvar CFLAGS... no We use this macro only for LDFLAGS and CFLAGS, so it's safe to stash -Werror there.
2012-09-13NEWS: language correctionsJan Engelhardt1-15/+14
2012-09-08modinfo: clarify verbiage for field shortcutsDave Reisner1-5/+5
Cleanup the punctuation and grammar in this blurb, specifically pointing out what these are shortcuts for.
2012-09-08Makefile: remove redundant flags to $(RM)Dave Reisner1-2/+2
$(RM) will always expand to 'rm -f' which means we don't need to ignore errors or pass this flag again.
2012-09-08Define rootfs as dependency of check-amDave Reisner1-1/+1
This should actually fix the problem of ensuring that the rootfs is created every time that 'make check' is run.
2012-09-08Revert "build-sys: disable jobserver for rootfs target"Dave Reisner1-2/+1
This is bogus and does not work. This reverts commit 4e7f0f204bc82ce749cad6613b066993f530cbe6.
2012-09-07testsuite: Fix double definition of 64-bits variantLucas De Marchi1-3/+7
If _FILE_OFFSET_BITS is defined we should not be wrapping these 64 variants, since they are macros in libc.
2012-09-06kmod 10v10Lucas De Marchi3-4/+23
2012-08-31Remove test directoryLucas De Marchi8-586/+0
All tests should be in testsuite. The remaining tests in this directory are not relevant enough to be ported. git log can be consulted if in future we decide to put them in testsuite.
2012-08-30TODO: deprecate use of rmmod -wLucas De Marchi1-0/+4
As discussed with Rusty Russel, it would be nice to remove the related code from kernel. Deprecate its use on kmod, so people know they shouldn't be using it.
2012-08-17modprobe: Unconditionally use KMOD_PROBE_APPLY_BLACKLIST_ALIAS_ONLYLucas De Marchi1-0/+1
This fixes a change in behavior regarding kmod and module-init-tools: when trying to load a module by alias, we should check if it's blacklisted, regardless of the command line arguments passed. This was reported by "Dmitry V. Levin <ldv@altlinux.org>".
2012-08-17libkmod-module: Add KMOD_PROBE_APPLY_BLACKLIST_ALIAS_ONLY flagLucas De Marchi2-3/+10
With this flag kmod_module_probe_insert_module() check if module is blacklisted only if it's also an alias. This is needed in order to allow blacklisting a module by name and effectively blacklisting all its aliases as module-init-tools was doing. Before this patch we could load pcspkr module as follows: /etc/modprobe.d/test.conf: alias yay pcspkr blacklist pcspkr $ modprobe yay Now libkmod has support to blacklist "yay" because "pcspkr" is blacklisted.
2012-08-01testsuite preload: Factorize into macros, add more stat and open variantsMartin Pitt1-124/+90
Instead of replicating the same code several times, define and use macros for the various types of wrapped functions in the testsuite's path.c LD_PRELOAD wrapper. Add various __xstat() variants and open64(), which are being used when enabling large file support.
2012-07-31README: let people know they don't need to subscribeLucas De Marchi1-1/+1
People are afraid to CC the mailing list because they think they need to subscribe (and a lot of them are already subscribed to too many lists).
2012-07-31build-sys: add 'man' entry in summaryLucas De Marchi1-0/+1
2012-07-31build-sys: Add --disable-manpages optionColin Walters2-1/+10
1) Embedded systems often don't want man pages on the target; rather than pointlessly building them, then ignoring the result, allow just not building them at all 2) When bootstrapping an operating systems, documentation is the source of many cyclical dependencies, and allowing it to be explicitly disabled is useful for earlier build passes.
2012-07-26man/rmmod: specify each option in separate <term> tagDave Reisner1-3/+15
2012-07-26man/depmod: specify each option in separate <term> tagDave Reisner1-12/+56
2012-07-25man/modprobe: specify each option in separate <term> tagDave Reisner1-10/+69
2012-07-25man/modinfo: specify each option in separate <term> tagDave Reisner1-0/+8
This has the end result of comma delimiting equivalent options in the manpage, similar to many other manuals.
2012-07-25man/modinfo: document longopts for field shortcutsDave Reisner1-0/+13
2012-07-25man/modinfo: document --basedir optionDave Reisner1-0/+11
This was never documented in the manpage of module-init-tools either. The flag is identical in function to modprobe's --dirname option, so use the same language to describe it.
2012-07-25man/modprobe: clarify --dirname optionDave Reisner1-3/+1
The documentation for this flag leads one to believe that the full path to the module directory is needed. In reality, this flag specifies only the root of the module path.
2012-07-18Use #pragma once instead of #ifndefLucas De Marchi11-41/+11
Only the public header maintains #ifndef in the header, together with pragma. The other ones contain only pragma. As reported by Shawn Landden on systemd mailing list this is compatible with all major compilers and gcc has this since version 3.3.
2012-07-10build-sys: disable jobserver for rootfs targetDave Reisner1-1/+2
2588e3dff5d broke the distcheck target. Fix it by serializing the rootfs (re)creation prior to running the testsuite.
2012-07-10testsuite: re-license under LGPLLucas De Marchi19-138/+658
2012-07-10testsuite: path wrapper: Fix open() with 3 argumentsMartin Pitt1-1/+1
Properly return the original libc return value in the case that open() is called with 3 arguments.
2012-06-29module: support reading coresize from /sys if supportedDave Reisner1-3/+27
Linux 3.3 introduced the coresize attribute in /sys/module/*. When available, use this instead of parsing some portion of /proc/modules.
2012-06-29Implicitly run 'make rootfs' with 'make check'Dave Reisner1-0/+3
Avoid the need for the user to run this manually after a run of the testsuite by adding it.
2012-06-21testsuite: use right offset for module nameLucas De Marchi2-5/+23
We need to cope with the case in which a 32 bits machine is opening a 64 bits kernel module and vice-versa. The offset in `struct module' are different and do not depend on the architecture we are running, but rather on the architecture they were created for. This fixes `make check' in 32 bits machines (since we are shipping 64 bits modules for testing)
2012-06-19kmod 9v9Lucas De Marchi3-2/+15
2012-06-19build-sys: allow compressed modules in testsuiteLucas De Marchi1-1/+1
2012-06-19build-sys: Make dirs writable on rootfs creationLucas De Marchi2-3/+3
Autofoo make the dist dir as readonly. If we copy it, tools needing to create sysfs entries will not be able to do so, because they can't create the needed directories/files. It would be much better if autofoo allowed to let the files as is instead of converting them to read-only.
2012-06-15depmod: use ferror and fclose to check for errorLucas De Marchi1-7/+6
Thanks to hpa for point this out.
2012-06-15bootstrap: remove unnecessary echoDave Reisner1-1/+1
2012-06-15bootstrap-configure: quote command line arg expansionDave Reisner1-1/+1
2012-06-15depmod: return error when index is truncated due to ENOSPCLucas De Marchi1-0/+9
Before: ======= [lucas@vader kmod]$ sudo depmod [lucas@vader kmod]$ echo $? 0 [lucas@vader kmod]$ ls -l /lib/modules/$(uname -r) total 12 drwxr-xr-x 8 root root 160 Jun 13 11:05 kernel -rw-r--r-- 1 root root 12288 Jun 15 21:29 modules.alias -rw-r--r-- 1 root root 0 Jun 15 21:29 modules.alias.bin -rw-r--r-- 1 root root 0 Jun 15 21:29 modules.dep -rw-r--r-- 1 root root 0 Jun 15 21:29 modules.dep.bin -rw-r--r-- 1 root root 0 Jun 15 21:29 modules.devname -rw-r--r-- 1 root root 0 Jun 15 21:29 modules.softdep -rw-r--r-- 1 root root 0 Jun 15 21:29 modules.symbols -rw-r--r-- 1 root root 0 Jun 15 21:29 modules.symbols.bin Note that modules.alias is truncated and the other have size == 0 After: ====== [lucas@vader kmod]$ sudo ./tools/depmod WARNING: could not open /lib/modules/3.5.0-rc2-demarchi-00028-g94fa83c/modules.order: No such file or directory ERROR: Could not create index: output truncated: No space left on device [lucas@vader kmod]$ echo $? 1
2012-06-15depmod: fix coding-style issue in array declarationLucas De Marchi1-29/+29
2012-06-15depmod: fail if any index could not be createdLucas De Marchi1-8/+14
2012-06-15depmod: don't return error if modules.builtin don't existLucas De Marchi1-3/+2
2012-06-15Remove ifdef for building tools not bundledLucas De Marchi7-58/+0
Current build system do not support to build separate tools anymore, so just remove the ifdefs.
2012-06-14build-sys: add missing header to fix distcheckLucas De Marchi1-1/+1
2012-06-14tools: rename source filesLucas De Marchi7-4/+4
There's no point anymore in having "kmod-" prefix. This is a historical thing when we started implementation of these tools.
2012-06-12libkmod-config: refactor functions to get configLucas De Marchi4-53/+28
It makes more sense to have libkmod-config.c deal with the configuration directly and the others get the config from ctx. As a bonus point we get a smaller binary. Following numbers are for x86-64, libkmod + kmod: Before: text data bss dec hex filename 128840 1496 104 130440 1fd88 tools/modprobe After: text data bss dec hex filename 128392 1496 104 129992 1fbc8 tools/modprobe
2012-06-11TODO: update tasksLucas De Marchi1-13/+12
- Remove dependency loop with install commands, since it's done - Add reasoning behind API refactor
2012-06-11testsuite: Fix test descriptionLucas De Marchi1-1/+1
2012-06-06libkmod-index: protect ourselves from corrupted indexesLucas De Marchi1-3/+5
If index is shorter than 12 bytes, we couldn't even read its header. Go to error handling in this case.
2012-06-06testsuite: add test for install-commands loopLucas De Marchi12-0/+167
This loop is similar to the one that comes with install rules of alsa-utils package. It can be easily verified by reverting commit abd5557 and running the testsuite.
2012-06-06testsuite: allow to export custom env varsLucas De Marchi2-0/+9
2012-06-06testsuite: add timeout for each testLucas De Marchi2-6/+37
Each test must run under 2 seconds. Ideally they should run in much less than this; just give an arbitrary number so we don't wait forever in case we reached an infinite loop somewhere.
2012-06-06testsuite: create additional pipe to monitor childLucas De Marchi1-12/+34
2012-06-06libkmod-util: split function for usec conversionLucas De Marchi2-2/+8
2012-06-05testsuite: add test for softdep loopsLucas De Marchi13-0/+94
2012-06-05testsuite: check if module is in kernel for return codeLucas De Marchi1-3/+32
2012-06-05testsuite: set default init_module behavior to mimic kernel'sLucas De Marchi1-7/+17
2012-06-05testsuite: create initstate file upon fake init_module()Lucas De Marchi2-4/+53
2012-06-05testsuite: add mkdir_p implementationLucas De Marchi3-0/+97
2012-06-05testsuite: trap calls to mkdirLucas De Marchi1-0/+17
2012-06-05testsuite: check if rootfs dir is dirty before runningLucas De Marchi3-4/+38
Keep around a stamp-rootfs file that is generated together with the rootfs. testsuite checks each test directory if its mtime is greater than stamp's mtime, deciding if rootfs should be re-generated.
2012-06-05testsuite: separate insert and delete rootfs from modinfoLucas De Marchi11-2/+58
2012-06-05libkmod-util: add missing stdbool.h includeLucas De Marchi1-0/+1
2012-06-05testsuite: rename rootfs dirLucas De Marchi147-8/+10
2012-06-05build-sys: provide --sysconfdir to make distcheck flagsLucas De Marchi1-1/+1
test-blacklist is accessing the wrong location in make distcheck, making the test to fail. Fix is by providing --sysconfdir=/etc in configure flags.
2012-06-05testsuite: fix find_module() finding wrong moduleLucas De Marchi1-1/+1
2012-05-23Silence clang warnings with __unused__ attributeLucas De Marchi2-6/+7
I hate this kind of READV and WRITEV macros that Gustavo seems to love. clang-analyzer hates them as well. I'm not motivated enough to refactor this, but I want a clean clang report, so just shut it up.
2012-05-23Don't use __ for attribute definesLucas De Marchi3-36/+34
System headers use __, don't mess with them.
2012-05-23libkmod-index: use generic function for unaligned accessLucas De Marchi1-1/+1
2012-05-23doc: Don't reference /etc/modprobe.confJosh Boyer1-2/+2
kmod doesn't read /etc/modprobe.conf at all, so don't mention it in the modprobe man page. Point users to modprobe.d(5) instead.
2012-05-21libkmod-hash: use generic function for unaligned accessLucas De Marchi2-14/+6
2012-05-21libkmod-util: copy macros for unaligned access from BlueZLucas De Marchi1-0/+16
2012-05-15libkmod: move function to the only file using itMike Frysinger3-32/+31
If we don't have --gc-sections support, linking kmod fails: libkmod/.libs/libkmod-util.a(libkmod-util.o): In function 'underscores': libkmod/libkmod-util.c:117: undefined reference to 'kmod_log' This is because libkmod-util.la uses kmod_log(), that is in libkmod.la. Move the function so we don't have a dependency loop while building the libraries and it works with compilers with no support for --gc-sections.
2012-05-11test-conversion: convert test-get-dependencies to new infrastructureDan McGee18-53/+169
The test uses the ext4 module dependencies as the testcase, checking both the number and the names of the returned modules.
2012-05-11test-conversion: convert test-blacklist to new infrastructureDan McGee5-77/+114
Add a modprobe.conf with some blacklist entries in a test rootfs, and then ensure our blacklist function actually cuts out the two listed entries (and doesn't cut out the others).
2012-05-11build-sys: copy rootfs to another directoryLucas De Marchi2-2/+11
We can't use the rootfs directory because it breaks out-of-tree build and in future we want to make modifications to the fake filesystem such as adding and removing files. We need to call "chmod -R +w" in the resulting directory because when we distribute the source with make dist all files will be readonly. Fix 'make distcheck'
2012-05-11build-sys: distribute testsuiteLucas De Marchi1-0/+2
Fix 'make dist'