diff -Nru kmod-28/configure.ac kmod-29/configure.ac --- kmod-28/configure.ac 2021-01-07 19:43:36.000000000 +0100 +++ kmod-29/configure.ac 2021-05-21 01:02:57.000000000 +0200 @@ -1,6 +1,6 @@ AC_PREREQ(2.64) AC_INIT([kmod], - [28], + [29], [linux-modules@vger.kernel.org], [kmod], [http://git.kernel.org/?p=utils/kernel/kmod/kmod.git]) @@ -224,6 +224,8 @@ ], [ AM_CONDITIONAL([ENABLE_GTK_DOC], false)]) +# Some tests are skipped when sysconfdir != /etc. +AM_CONDITIONAL([KMOD_SYSCONFDIR_NOT_ETC], [test "x$sysconfdir" != "x/etc"]) ##################################################################### # Default CFLAGS and LDFLAGS diff -Nru kmod-28/debian/changelog kmod-29/debian/changelog --- kmod-28/debian/changelog 2021-06-24 14:42:47.000000000 +0200 +++ kmod-29/debian/changelog 2021-08-17 11:19:53.000000000 +0200 @@ -1,3 +1,18 @@ +kmod (29-1ubuntu1) jammy; urgency=low + + * Merge from Debian unstable. Remaining changes: + - Enable testsuite during build. + - Build with zstd compression enabled. + - Install ubuntu-specific depmod.d and modprobe.d contents. + + -- Alexandre Ghiti Tue, 17 Aug 2021 09:19:53 +0000 + +kmod (29-1) unstable; urgency=medium + + * New upstream release. + + -- Marco d'Itri Tue, 17 Aug 2021 09:04:37 +0200 + kmod (28-1ubuntu4) impish; urgency=medium * Enable testsuite during build. diff -Nru kmod-28/debian/patches/fix_modinfo_F kmod-29/debian/patches/fix_modinfo_F --- kmod-28/debian/patches/fix_modinfo_F 2021-01-08 02:01:04.000000000 +0100 +++ kmod-29/debian/patches/fix_modinfo_F 1970-01-01 01:00:00.000000000 +0100 @@ -1,15 +0,0 @@ ---- a/tools/modinfo.c -+++ b/tools/modinfo.c -@@ -178,7 +178,11 @@ static int modinfo_do(struct kmod_module - is_builtin = (filename == NULL); - - if (is_builtin) { -- printf("%-16s%s%c", "name:", kmod_module_get_name(mod), separator); -+ if (field == NULL) -+ printf("%-16s%s%c", "name:", -+ kmod_module_get_name(mod), separator); -+ else if (field != NULL && streq(field, "name")) -+ printf("%s%c", kmod_module_get_name(mod), separator); - filename = "(builtin)"; - } - diff -Nru kmod-28/debian/patches/series kmod-29/debian/patches/series --- kmod-28/debian/patches/series 2021-06-24 14:42:47.000000000 +0200 +++ kmod-29/debian/patches/series 2021-08-17 11:19:52.000000000 +0200 @@ -1,6 +1,5 @@ # fixes to be pushed upstream -fix_modinfo_F # features to be pushed upstream diff -Nru kmod-28/.gitignore kmod-29/.gitignore --- kmod-28/.gitignore 2021-01-07 19:43:36.000000000 +0100 +++ kmod-29/.gitignore 2021-05-21 01:02:57.000000000 +0200 @@ -3,6 +3,8 @@ *.gcno /*.tar.xz /*.md5sum +/*.mbx +/*.cover .deps/ .libs/ /Makefile diff -Nru kmod-28/libkmod/libkmod-builtin.c kmod-29/libkmod/libkmod-builtin.c --- kmod-28/libkmod/libkmod-builtin.c 2021-01-07 19:43:36.000000000 +0100 +++ kmod-29/libkmod/libkmod-builtin.c 2021-05-21 01:02:57.000000000 +0200 @@ -246,7 +246,7 @@ len = dot - line; - if (len > PATH_MAX) { + if (len >= PATH_MAX) { sv_errno = ENAMETOOLONG; goto fail; } @@ -313,7 +313,7 @@ while (offset < iter->next) { offset = get_string(iter, pos, &line, &linesz); if (offset <= 0) { - count = (offset) ? -errno : -EOF; + count = (offset) ? -errno : -EINVAL; free(*modinfo); goto fail; } diff -Nru kmod-28/libkmod/libkmod.c kmod-29/libkmod/libkmod.c --- kmod-28/libkmod/libkmod.c 2021-01-07 19:43:36.000000000 +0100 +++ kmod-29/libkmod/libkmod.c 2021-05-21 01:02:57.000000000 +0200 @@ -64,6 +64,7 @@ static const char *default_config_paths[] = { SYSCONFDIR "/modprobe.d", "/run/modprobe.d", + "/usr/local/lib/modprobe.d", "/lib/modprobe.d", NULL }; @@ -234,10 +235,11 @@ * Otherwise, give an absolute dirname. * @config_paths: ordered array of paths (directories or files) where * to load from user-defined configuration parameters such as - * alias, blacklists, commands (install, remove). If - * NULL defaults to /run/modprobe.d, /etc/modprobe.d and - * /lib/modprobe.d. Give an empty vector if configuration should - * not be read. This array must be null terminated. + * alias, blacklists, commands (install, remove). If NULL + * defaults to /etc/modprobe.d, /run/modprobe.d, + * /usr/local/lib/modprobe.d and /lib/modprobe.d. Give an empty + * vector if configuration should not be read. This array must + * be null terminated. * * Create kmod library context. This reads the kmod configuration * and fills in the default values. diff -Nru kmod-28/libkmod/libkmod-config.c kmod-29/libkmod/libkmod-config.c --- kmod-28/libkmod/libkmod-config.c 2021-01-07 19:43:36.000000000 +0100 +++ kmod-29/libkmod/libkmod-config.c 2021-05-21 01:02:57.000000000 +0200 @@ -498,8 +498,15 @@ { char buf[KCMD_LINE_SIZE]; int fd, err; - char *p, *modname, *param = NULL, *value = NULL; - bool is_quoted = false, is_module = true; + char *p, *p_quote_start, *modname, *param = NULL, *value = NULL; + bool is_quoted = false, iter = true; + enum state { + STATE_IGNORE, + STATE_MODNAME, + STATE_PARAM, + STATE_VALUE, + STATE_COMPLETE, + } state; fd = open("/proc/cmdline", O_RDONLY|O_CLOEXEC); if (fd < 0) { @@ -516,54 +523,102 @@ return err; } - for (p = buf, modname = buf; *p != '\0' && *p != '\n'; p++) { - if (*p == '"') { + state = STATE_MODNAME; + p_quote_start = NULL; + for (p = buf, modname = buf; iter; p++) { + switch (*p) { + case '"': is_quoted = !is_quoted; - if (is_quoted) { - /* don't consider a module until closing quotes */ - is_module = false; - } else if (param != NULL && value != NULL) { - /* - * If we are indeed expecting a value and - * closing quotes, then this can be considered - * a valid option for a module - */ - is_module = true; + /* + * only allow starting quote as first char when looking + * for a modname: anything else is considered ill-formed + */ + if (is_quoted && state == STATE_MODNAME && p == modname) { + p_quote_start = p; + modname = p + 1; + } else if (state != STATE_VALUE) { + state = STATE_IGNORE; } - continue; - } - if (is_quoted) - continue; - - switch (*p) { + break; + case '\0': + iter = false; + /* fall-through */ case ' ': - *p = '\0'; - if (is_module) - kcmdline_parse_result(config, modname, param, value); - param = value = NULL; - modname = p + 1; - is_module = true; + case '\n': + case '\t': + case '\v': + case '\f': + case '\r': + if (is_quoted && state == STATE_VALUE) { + /* no state change*/; + } else if (is_quoted) { + /* spaces are only allowed in the value part */ + state = STATE_IGNORE; + } else if (state == STATE_VALUE || state == STATE_PARAM) { + *p = '\0'; + state = STATE_COMPLETE; + } else { + /* + * go to next option, ignoring any possible + * partial match we have + */ + modname = p + 1; + state = STATE_MODNAME; + p_quote_start = NULL; + } break; case '.': - if (param == NULL) { + if (state == STATE_MODNAME) { *p = '\0'; param = p + 1; + state = STATE_PARAM; + } else if (state == STATE_PARAM) { + state = STATE_IGNORE; } break; case '=': - if (param != NULL) + if (state == STATE_PARAM) { + /* + * Don't set *p to '\0': the value var shadows + * param + */ value = p + 1; - else - is_module = false; + state = STATE_VALUE; + } else if (state == STATE_MODNAME) { + state = STATE_IGNORE; + } break; } - } - *p = '\0'; - if (is_module) - kcmdline_parse_result(config, modname, param, value); + if (state == STATE_COMPLETE) { + /* + * We may need to re-quote to unmangle what the + * bootloader passed. Example: grub passes the option as + * "parport.dyndbg=file drivers/parport/ieee1284_ops.c +mpf" + * instead of + * parport.dyndbg="file drivers/parport/ieee1284_ops.c +mpf" + */ + if (p_quote_start && p_quote_start < modname) { + /* + * p_quote_start + * | + * |modname param value + * || | | + * vv v v + * "parport\0dyndbg=file drivers/parport/ieee1284_ops.c +mpf" */ + memmove(p_quote_start, modname, value - modname); + value--; modname--; param--; + *value = '"'; + } + kcmdline_parse_result(config, modname, param, value); + /* start over on next iteration */ + modname = p + 1; + state = STATE_MODNAME; + p_quote_start = NULL; + } + } return 0; } @@ -854,8 +909,10 @@ memcpy(cf->path, path, pathlen); tmp = kmod_list_append(path_list, cf); - if (tmp == NULL) + if (tmp == NULL) { + free(cf); goto oom; + } path_list = tmp; } diff -Nru kmod-28/libkmod/libkmod-module.c kmod-29/libkmod/libkmod-module.c --- kmod-28/libkmod/libkmod-module.c 2021-01-07 19:43:36.000000000 +0100 +++ kmod-29/libkmod/libkmod-module.c 2021-05-21 01:02:57.000000000 +0200 @@ -2277,7 +2277,7 @@ * * After use, free the @list by calling kmod_module_info_free_list(). * - * Returns: 0 on success or < 0 otherwise. + * Returns: number of entries in @list on success or < 0 otherwise. */ KMOD_EXPORT int kmod_module_get_info(const struct kmod_module *mod, struct kmod_list **list) { diff -Nru kmod-28/Makefile.am kmod-29/Makefile.am --- kmod-28/Makefile.am 2021-01-07 19:43:36.000000000 +0100 +++ kmod-29/Makefile.am 2021-05-21 01:02:57.000000000 +0200 @@ -58,7 +58,7 @@ # 6. If any interfaces have been removed or changed since the last public # release, then set age to 0. LIBKMOD_CURRENT=5 -LIBKMOD_REVISION=6 +LIBKMOD_REVISION=7 LIBKMOD_AGE=3 noinst_LTLIBRARIES = shared/libshared.la @@ -249,7 +249,7 @@ find $(ROOTFS) -type d -exec chmod +w {} \; && \ find $(ROOTFS) -type f -name .gitignore -exec rm -f {} \; && \ $(top_srcdir)/testsuite/populate-modules.sh \ - $(MODULE_PLAYGROUND) $(ROOTFS) ) && \ + $(MODULE_PLAYGROUND) $(ROOTFS) $(top_builddir)/config.h ) && \ touch testsuite/stamp-rootfs build-module-playground: @@ -280,13 +280,7 @@ TESTSUITE_OVERRIDE_LIBS_LDFLAGS = \ avoid-version -module -shared -export-dynamic -rpath /nowhere -ldl -check-sysconfdir: - $(AM_V_at)if test "$(sysconfdir)" != "/etc" -a "$(sysconfdir)" != "/etc/"; then \ - echo "warning: Some tests will fail without --sysconfdir=/etc" >&2; \ - fi -.PHONY: check-sysconfdir - -check-am: rootfs check-sysconfdir +check-am: rootfs EXTRA_DIST += \ @@ -341,6 +335,10 @@ testsuite/libtestsuite.la libkmod/libkmod-internal.la \ shared/libshared.la +if KMOD_SYSCONFDIR_NOT_ETC +TESTSUITE_CPPFLAGS += -DKMOD_SYSCONFDIR_NOT_ETC +endif + check_LTLIBRARIES += testsuite/libtestsuite.la testsuite_libtestsuite_la_SOURCES = \ testsuite/testsuite.c testsuite/testsuite.h diff -Nru kmod-28/man/depmod.d.xml kmod-29/man/depmod.d.xml --- kmod-28/man/depmod.d.xml 2021-01-07 19:43:36.000000000 +0100 +++ kmod-29/man/depmod.d.xml 2021-05-21 01:02:57.000000000 +0200 @@ -40,8 +40,9 @@ /usr/lib/depmod.d/*.conf - /etc/depmod.d/*.conf + /usr/local/lib/depmod.d/*.conf /run/depmod.d/*.conf + /etc/depmod.d/*.conf DESCRIPTION diff -Nru kmod-28/man/modprobe.d.xml kmod-29/man/modprobe.d.xml --- kmod-28/man/modprobe.d.xml 2021-01-07 19:43:36.000000000 +0100 +++ kmod-29/man/modprobe.d.xml 2021-05-21 01:02:57.000000000 +0200 @@ -41,8 +41,9 @@ /lib/modprobe.d/*.conf - /etc/modprobe.d/*.conf + /usr/local/lib/modprobe.d/*.conf /run/modprobe.d/*.conf + /etc/modprobe.d/*.conf DESCRIPTION diff -Nru kmod-28/NEWS kmod-29/NEWS --- kmod-28/NEWS 2021-01-07 19:43:36.000000000 +0100 +++ kmod-29/NEWS 2021-05-21 01:02:57.000000000 +0200 @@ -1,3 +1,49 @@ +kmod 29 +======= + +- Improvements + - Add support to use /usr/local as a place for configuration files. This makes it easier + to install locally without overriding distro files. + +- Bug fixes + - Fix `modinfo -F` when module is builtin: when we asked by a specific field from modinfo, + it was not working correctly if the module was builtin + + - Documentation fixes on precedence order of /etc and /run: the correct order is + /etc/modprobe.d, /run/modprobe.d, /lib/modprobe.d + + - Fix the priority order that we use for searching configuration files. The + correct one is /etc, /run, /usr/local/lib, /lib, for both modprobe.d + and depmo.d + + - Fix kernel command line parsing when there are quotes present. Grub + mangles the command line and changes it from 'module.option="val with + spaces"' to '"module.option=val with spaces"'. Although this is weird + behavior and grub could have been fixed, the kernel understands it + correctly for builtin modules. So change libkmod to also parse it + correctly. This also brings another hidden behavior from the kernel: + newline in the kernel command line is also allowed and can be used to + separate options. + + - Fix a memory leak, overflow and double free on error path + + - Fix documentation for return value from kmod_module_get_info(): we + return the number of entries we added to the list + + - Fix output of modules.builtin.alias.bin index: we were writing an empty file due to + the misuse of kmod_module_get_info() + +- Infra/internal + - Retire integration with semaphoreci + + - Declare the github mirror also as an official upstream source: now besides accepting + patches via mailing list, PRs on github are also acceptable + + - Misc improvements to testsuite, so we can use it reliably regardless + of the configuration used: now tests will skip if we don't have the + build dependencies) + + kmod 28 ======= diff -Nru kmod-28/README kmod-29/README --- kmod-28/README 2021-01-07 19:43:36.000000000 +0100 +++ kmod-29/README 2021-05-21 01:02:57.000000000 +0200 @@ -3,16 +3,10 @@ Information =========== -Build Status: - https://lucasdemarchi.semaphoreci.com/projects/kmod - Mailing list: linux-modules@vger.kernel.org (no subscription needed) https://lore.kernel.org/linux-modules/ -Patchwork: - https://patchwork.kernel.org/project/linux-modules/ - Signed packages: http://www.kernel.org/pub/linux/utils/kernel/kmod/ @@ -23,6 +17,7 @@ Gitweb: http://git.kernel.org/?p=utils/kernel/kmod/kmod.git + https://github.com/kmod-project/kmod Irc: #kmod on irc.freenode.org diff -Nru kmod-28/README.md kmod-29/README.md --- kmod-28/README.md 2021-01-07 19:43:36.000000000 +0100 +++ kmod-29/README.md 2021-05-21 01:02:57.000000000 +0200 @@ -2,4 +2,128 @@ [![Coverity Scan Status](https://scan.coverity.com/projects/2096/badge.svg)](https://scan.coverity.com/projects/2096) -This is a ***mirror only***. Please see [README](../master/README) file for more information. + +Information +=========== + +Mailing list: + linux-modules@vger.kernel.org (no subscription needed) + https://lore.kernel.org/linux-modules/ + +Signed packages: + http://www.kernel.org/pub/linux/utils/kernel/kmod/ + +Git: + git://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git + http://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git + https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git + +Gitweb: + http://git.kernel.org/?p=utils/kernel/kmod/kmod.git + https://github.com/kmod-project/kmod + +Irc: + #kmod on irc.freenode.org + +License: + LGPLv2.1+ for libkmod, testsuite and helper libraries + GPLv2+ for tools/* + + +OVERVIEW +======== + +kmod is a set of tools to handle common tasks with Linux kernel modules like +insert, remove, list, check properties, resolve dependencies and aliases. + +These tools are designed on top of libkmod, a library that is shipped with +kmod. See libkmod/README for more details on this library and how to use it. +The aim is to be compatible with tools, configurations and indexes from +module-init-tools project. + +Compilation and installation +============================ + +In order to compiler the source code you need following software packages: + - GCC compiler + - GNU C library + +Optional dependencies: + - ZLIB library + - LZMA library + +Typical configuration: + ./configure CFLAGS="-g -O2" --prefix=/usr \ + --sysconfdir=/etc --libdir=/usr/lib + +Configure automatically searches for all required components and packages. + +To compile and install run: + make && make install + +Hacking +======= + +Run 'autogen.sh' script before configure. If you want to accept the recommended +flags, you just need to run 'autogen.sh c'. Note that the recommended +flags require cython be installed to compile successfully. + +Make sure to read the CODING-STYLE file and the other READMEs: libkmod/README +and testsuite/README. + +Compatibility with module-init-tools +==================================== + +kmod replaces module-init-tools, which is end-of-life. Most of its tools are +rewritten on top of libkmod so it can be used as a drop in replacements. +Somethings however were changed. Reasons vary from "the feature was already +long deprecated on module-init-tools" to "it would be too much trouble to +support it". + +There are several features that are being added in kmod, but we don't +keep track of them here. + +modprobe +-------- + +* 'modprobe -l' was marked as deprecated and does not exist anymore + +* 'modprobe -t' is gone, together with 'modprobe -l' + +* modprobe doesn't parse configuration files with names not ending in + '.alias' or '.conf'. modprobe used to warn about these files. + +* modprobe doesn't parse 'config' and 'include' commands in configuration + files. + +* modprobe from m-i-t does not honour softdeps for install commands. E.g.: + config: + + install bli "echo bli" + install bla "echo bla" + softdep bla pre: bli + + With m-i-t, the output of 'modprobe --show-depends bla' will be: + install "echo bla" + + While with kmod: + install "echo bli" + install "echo bla" + +* kmod doesn't dump the configuration as is in the config files. Instead it + dumps the configuration as it was parsed. Therefore, comments and file names + are not dumped, but on the good side we know what the exact configuration + kmod is using. We did this because if we only want to know the entire content + of configuration files, it's enough to use find(1) in modprobe.d directories + +depmod +------ + +* there's no 'depmod -m' option: legacy modules.*map files are gone + +lsmod +----- + +* module-init-tools used /proc/modules to parse module info. kmod uses + /sys/module/*, but there's a fallback to /proc/modules if the latter isn't + available diff -Nru kmod-28/testsuite/module-playground/.gitignore kmod-29/testsuite/module-playground/.gitignore --- kmod-28/testsuite/module-playground/.gitignore 2021-01-07 19:43:36.000000000 +0100 +++ kmod-29/testsuite/module-playground/.gitignore 2021-05-21 01:02:57.000000000 +0200 @@ -1,4 +1,3 @@ -*o.cmd *.ko !mod-simple-*.ko !cache/*.ko @@ -8,6 +7,7 @@ *.mod *.a *.cmd +*.o.d modules.order Module.symvers diff -Nru kmod-28/testsuite/populate-modules.sh kmod-29/testsuite/populate-modules.sh --- kmod-28/testsuite/populate-modules.sh 2021-01-07 19:43:36.000000000 +0100 +++ kmod-29/testsuite/populate-modules.sh 2021-05-21 01:02:57.000000000 +0200 @@ -4,6 +4,12 @@ MODULE_PLAYGROUND=$1 ROOTFS=$2 +CONFIG_H=$3 + +feature_enabled() { + local feature=$1 + grep KMOD_FEATURES $CONFIG_H | head -n 1 | grep -q \+$feature +} declare -A map map=( @@ -66,6 +72,9 @@ gzip_array=( "test-depmod/modules-order-compressed/lib/modules/4.4.4/kernel/drivers/block/cciss.ko" + ) + +xz_array=( "test-depmod/modules-order-compressed/lib/modules/4.4.4/kernel/drivers/scsi/scsi_mod.ko" ) @@ -85,38 +94,47 @@ "test-modinfo/mod-simple-pkcs7.ko" ) -for k in ${!map[@]}; do +for k in "${!map[@]}"; do dst=${ROOTFS}/$k src=${MODULE_PLAYGROUND}/${map[$k]} - if test "${dst: -1}" = "/"; then - install -d $dst - install -t $dst $src + if [[ $dst = */ ]]; then + install -d "$dst" + install -t "$dst" "$src" else - install -D $src $dst + install -D "$src" "$dst" fi done # start poking the final rootfs... -# gzip these modules -for m in "${gzip_array[@]}"; do - gzip $ROOTFS/$m -done - -# zstd-compress these modules -for m in "${zstd_array[@]}"; do - zstd --rm $ROOTFS/$m -done +# compress modules with each format if feature is enabled +if feature_enabled ZLIB; then + for m in "${gzip_array[@]}"; do + gzip "$ROOTFS/$m" + done +fi + +if feature_enabled XZ; then + for m in "${xz_array[@]}"; do + xz "$ROOTFS/$m" + done +fi + +if feature_enabled ZSTD; then + for m in "${zstd_array[@]}"; do + zstd --rm $ROOTFS/$m + done +fi for m in "${attach_sha1_array[@]}"; do - cat ${MODULE_PLAYGROUND}/dummy.sha1 >> ${ROOTFS}/$m + cat "${MODULE_PLAYGROUND}/dummy.sha1" >>"${ROOTFS}/$m" done for m in "${attach_sha256_array[@]}"; do - cat ${MODULE_PLAYGROUND}/dummy.sha256 >> ${ROOTFS}/$m + cat "${MODULE_PLAYGROUND}/dummy.sha256" >>"${ROOTFS}/$m" done for m in "${attach_pkcs7_array[@]}"; do - cat ${MODULE_PLAYGROUND}/dummy.pkcs7 >> ${ROOTFS}/$m + cat "${MODULE_PLAYGROUND}/dummy.pkcs7" >>"${ROOTFS}/$m" done diff -Nru kmod-28/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline7/correct.txt kmod-29/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline7/correct.txt --- kmod-28/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline7/correct.txt 1970-01-01 01:00:00.000000000 +0100 +++ kmod-29/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline7/correct.txt 2021-05-21 01:02:57.000000000 +0200 @@ -0,0 +1,5 @@ +options psmouse foo +options parport dyndbg="file drivers/parport/ieee1284_ops.c +mpf" + +# End of configuration files. Dumping indexes now: + diff -Nru kmod-28/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline7/module-param-kcmdline7/correct.txt kmod-29/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline7/module-param-kcmdline7/correct.txt --- kmod-28/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline7/module-param-kcmdline7/correct.txt 1970-01-01 01:00:00.000000000 +0100 +++ kmod-29/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline7/module-param-kcmdline7/correct.txt 2021-05-21 01:02:57.000000000 +0200 @@ -0,0 +1,5 @@ +options psmouse foo +options parport dyndbg="file drivers/parport/ieee1284_ops.c +mpf" + +# End of configuration files. Dumping indexes now: + diff -Nru kmod-28/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline7/module-param-kcmdline7/proc/cmdline kmod-29/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline7/module-param-kcmdline7/proc/cmdline --- kmod-28/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline7/module-param-kcmdline7/proc/cmdline 1970-01-01 01:00:00.000000000 +0100 +++ kmod-29/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline7/module-param-kcmdline7/proc/cmdline 2021-05-21 01:02:57.000000000 +0200 @@ -0,0 +1 @@ +psmouse.foo parport.dyndbg="file drivers/parport/ieee1284_ops.c +mpf" quiet rw diff -Nru kmod-28/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline7/proc/cmdline kmod-29/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline7/proc/cmdline --- kmod-28/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline7/proc/cmdline 1970-01-01 01:00:00.000000000 +0100 +++ kmod-29/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline7/proc/cmdline 2021-05-21 01:02:57.000000000 +0200 @@ -0,0 +1 @@ +psmouse.foo parport.dyndbg="file drivers/parport/ieee1284_ops.c +mpf" quiet rw diff -Nru kmod-28/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline8/correct.txt kmod-29/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline8/correct.txt --- kmod-28/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline8/correct.txt 1970-01-01 01:00:00.000000000 +0100 +++ kmod-29/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline8/correct.txt 2021-05-21 01:02:57.000000000 +0200 @@ -0,0 +1,5 @@ +options psmouse foo +options parport dyndbg="file drivers/parport/ieee1284_ops.c +mpf" + +# End of configuration files. Dumping indexes now: + diff -Nru kmod-28/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline8/module-param-kcmdline7/correct.txt kmod-29/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline8/module-param-kcmdline7/correct.txt --- kmod-28/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline8/module-param-kcmdline7/correct.txt 1970-01-01 01:00:00.000000000 +0100 +++ kmod-29/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline8/module-param-kcmdline7/correct.txt 2021-05-21 01:02:57.000000000 +0200 @@ -0,0 +1,5 @@ +options psmouse foo +options parport dyndbg="file drivers/parport/ieee1284_ops.c +mpf" + +# End of configuration files. Dumping indexes now: + diff -Nru kmod-28/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline8/module-param-kcmdline7/proc/cmdline kmod-29/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline8/module-param-kcmdline7/proc/cmdline --- kmod-28/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline8/module-param-kcmdline7/proc/cmdline 1970-01-01 01:00:00.000000000 +0100 +++ kmod-29/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline8/module-param-kcmdline7/proc/cmdline 2021-05-21 01:02:57.000000000 +0200 @@ -0,0 +1 @@ +psmouse.foo parport.dyndbg="file drivers/parport/ieee1284_ops.c +mpf" quiet rw diff -Nru kmod-28/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline8/proc/cmdline kmod-29/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline8/proc/cmdline --- kmod-28/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline8/proc/cmdline 1970-01-01 01:00:00.000000000 +0100 +++ kmod-29/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline8/proc/cmdline 2021-05-21 01:02:57.000000000 +0200 @@ -0,0 +1 @@ +psmouse.foo "parport.dyndbg=file drivers/parport/ieee1284_ops.c +mpf" quiet rw diff -Nru kmod-28/testsuite/test-blacklist.c kmod-29/testsuite/test-blacklist.c --- kmod-28/testsuite/test-blacklist.c 2021-01-07 19:43:36.000000000 +0100 +++ kmod-29/testsuite/test-blacklist.c 2021-05-21 01:02:57.000000000 +0200 @@ -95,6 +95,9 @@ } DEFINE_TEST(blacklist_1, +#if defined(KMOD_SYSCONFDIR_NOT_ETC) + .skip = true, +#endif .description = "check if modules are correctly blacklisted", .config = { [TC_ROOTFS] = TESTSUITE_ROOTFS "test-blacklist/", diff -Nru kmod-28/testsuite/test-depmod.c kmod-29/testsuite/test-depmod.c --- kmod-28/testsuite/test-depmod.c 2021-01-07 19:43:36.000000000 +0100 +++ kmod-29/testsuite/test-depmod.c 2021-05-21 01:02:57.000000000 +0200 @@ -25,7 +25,6 @@ #include "testsuite.h" -#ifdef ENABLE_ZLIB #define MODULES_ORDER_UNAME "4.4.4" #define MODULES_ORDER_ROOTFS TESTSUITE_ROOTFS "test-depmod/modules-order-compressed" #define MODULES_ORDER_LIB_MODULES MODULES_ORDER_ROOTFS "/lib/modules/" MODULES_ORDER_UNAME @@ -42,6 +41,9 @@ } DEFINE_TEST(depmod_modules_order_for_compressed, +#if defined(KMOD_SYSCONFDIR_NOT_ETC) + .skip = true, +#endif .description = "check if depmod let aliases in right order when using compressed modules", .config = { [TC_UNAME_R] = MODULES_ORDER_UNAME, @@ -54,7 +56,6 @@ { } }, }); -#endif #define SEARCH_ORDER_SIMPLE_ROOTFS TESTSUITE_ROOTFS "test-depmod/search-order-simple" static noreturn int depmod_search_order_simple(const struct test *t) @@ -121,6 +122,9 @@ exit(EXIT_FAILURE); } DEFINE_TEST(depmod_detect_loop, +#if defined(KMOD_SYSCONFDIR_NOT_ETC) + .skip = true, +#endif .description = "check if depmod detects module loops correctly", .config = { [TC_UNAME_R] = "4.4.4", @@ -144,6 +148,9 @@ exit(EXIT_FAILURE); } DEFINE_TEST(depmod_search_order_external_first, +#if defined(KMOD_SYSCONFDIR_NOT_ETC) + .skip = true, +#endif .description = "check if depmod honor external keyword with higher priority", .config = { [TC_UNAME_R] = "4.4.4", @@ -196,6 +203,9 @@ exit(EXIT_FAILURE); } DEFINE_TEST(depmod_search_order_override, +#if defined(KMOD_SYSCONFDIR_NOT_ETC) + .skip = true, +#endif .description = "check if depmod honor override keyword", .config = { [TC_UNAME_R] = "4.4.4", diff -Nru kmod-28/testsuite/test-modprobe.c kmod-29/testsuite/test-modprobe.c --- kmod-28/testsuite/test-modprobe.c 2021-01-07 19:43:36.000000000 +0100 +++ kmod-29/testsuite/test-modprobe.c 2021-05-21 01:02:57.000000000 +0200 @@ -83,6 +83,9 @@ exit(EXIT_FAILURE); } DEFINE_TEST(modprobe_show_alias_to_none, +#if defined(KMOD_SYSCONFDIR_NOT_ETC) + .skip = true, +#endif .description = "check if modprobe --show-depends doesn't explode with an alias to nothing", .config = { [TC_UNAME_R] = "4.4.4", @@ -172,6 +175,9 @@ exit(EXIT_FAILURE); } DEFINE_TEST(modprobe_softdep_loop, +#if defined(KMOD_SYSCONFDIR_NOT_ETC) + .skip = true, +#endif .description = "check if modprobe breaks softdep loop", .config = { [TC_UNAME_R] = "4.4.4", @@ -207,7 +213,7 @@ .modules_loaded = "mod-loop-b,mod-loop-a", ); -static noreturn int modprobe_param_kcmdline(const struct test *t) +static noreturn int modprobe_param_kcmdline_show_deps(const struct test *t) { const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; const char *const args[] = { @@ -219,7 +225,7 @@ test_spawn_prog(progname, args); exit(EXIT_FAILURE); } -DEFINE_TEST(modprobe_param_kcmdline, +DEFINE_TEST(modprobe_param_kcmdline_show_deps, .description = "check if params from kcmdline are passed to (f)init_module call", .config = { [TC_UNAME_R] = "4.4.4", @@ -231,7 +237,7 @@ .modules_loaded = "", ); -static noreturn int modprobe_param_kcmdline2(const struct test *t) +static noreturn int modprobe_param_kcmdline(const struct test *t) { const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; const char *const args[] = { @@ -243,7 +249,7 @@ test_spawn_prog(progname, args); exit(EXIT_FAILURE); } -DEFINE_TEST(modprobe_param_kcmdline2, +DEFINE_TEST_WITH_FUNC(modprobe_param_kcmdline2, modprobe_param_kcmdline, .description = "check if params with no value are parsed correctly from kcmdline", .config = { [TC_UNAME_R] = "4.4.4", @@ -255,19 +261,7 @@ .modules_loaded = "", ); -static noreturn int modprobe_param_kcmdline3(const struct test *t) -{ - const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; - const char *const args[] = { - progname, - "-c", - NULL, - }; - - test_spawn_prog(progname, args); - exit(EXIT_FAILURE); -} -DEFINE_TEST(modprobe_param_kcmdline3, +DEFINE_TEST_WITH_FUNC(modprobe_param_kcmdline3, modprobe_param_kcmdline, .description = "check if unrelated strings in kcmdline are correctly ignored", .config = { [TC_UNAME_R] = "4.4.4", @@ -279,19 +273,7 @@ .modules_loaded = "", ); -static noreturn int modprobe_param_kcmdline4(const struct test *t) -{ - const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; - const char *const args[] = { - progname, - "-c", - NULL, - }; - - test_spawn_prog(progname, args); - exit(EXIT_FAILURE); -} -DEFINE_TEST(modprobe_param_kcmdline4, +DEFINE_TEST_WITH_FUNC(modprobe_param_kcmdline4, modprobe_param_kcmdline, .description = "check if unrelated strings in kcmdline are correctly ignored", .config = { [TC_UNAME_R] = "4.4.4", @@ -303,19 +285,7 @@ .modules_loaded = "", ); -static noreturn int modprobe_param_kcmdline5(const struct test *t) -{ - const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; - const char *const args[] = { - progname, - "-c", - NULL, - }; - - test_spawn_prog(progname, args); - exit(EXIT_FAILURE); -} -DEFINE_TEST(modprobe_param_kcmdline5, +DEFINE_TEST_WITH_FUNC(modprobe_param_kcmdline5, modprobe_param_kcmdline, .description = "check if params with spaces are parsed correctly from kcmdline", .config = { [TC_UNAME_R] = "4.4.4", @@ -327,20 +297,7 @@ .modules_loaded = "", ); - -static noreturn int modprobe_param_kcmdline6(const struct test *t) -{ - const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; - const char *const args[] = { - progname, - "-c", - NULL, - }; - - test_spawn_prog(progname, args); - exit(EXIT_FAILURE); -} -DEFINE_TEST(modprobe_param_kcmdline6, +DEFINE_TEST_WITH_FUNC(modprobe_param_kcmdline6, modprobe_param_kcmdline, .description = "check if dots on other parts of kcmdline don't confuse our parser", .config = { [TC_UNAME_R] = "4.4.4", @@ -351,6 +308,30 @@ }, .modules_loaded = "", ); + +DEFINE_TEST_WITH_FUNC(modprobe_param_kcmdline7, modprobe_param_kcmdline, + .description = "check if dots on other parts of kcmdline don't confuse our parser", + .config = { + [TC_UNAME_R] = "4.4.4", + [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline7", + }, + .output = { + .out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline7/correct.txt", + }, + .modules_loaded = "", + ); + +DEFINE_TEST_WITH_FUNC(modprobe_param_kcmdline8, modprobe_param_kcmdline, + .description = "check if dots on other parts of kcmdline don't confuse our parser", + .config = { + [TC_UNAME_R] = "4.4.4", + [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline8", + }, + .output = { + .out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline8/correct.txt", + }, + .modules_loaded = "", + ); static noreturn int modprobe_force(const struct test *t) diff -Nru kmod-28/testsuite/testsuite.c kmod-29/testsuite/testsuite.c --- kmod-28/testsuite/testsuite.c 2021-01-07 19:43:36.000000000 +0100 +++ kmod-29/testsuite/testsuite.c 2021-05-21 01:02:57.000000000 +0200 @@ -37,6 +37,7 @@ #include "testsuite.h" static const char *ANSI_HIGHLIGHT_GREEN_ON = "\x1B[1;32m"; +static const char *ANSI_HIGHLIGHT_YELLOW_ON = "\x1B[1;33m"; static const char *ANSI_HIGHLIGHT_RED_ON = "\x1B[1;31m"; static const char *ANSI_HIGHLIGHT_OFF = "\x1B[0m"; @@ -948,6 +949,14 @@ int err; bool matchout, match_modules; + if (t->skip) { + LOG("%sSKIPPED%s: %s\n", + ANSI_HIGHLIGHT_YELLOW_ON, ANSI_HIGHLIGHT_OFF, + t->name); + err = EXIT_SUCCESS; + goto exit; + } + /* Close write-fds */ if (t->output.out != NULL) close(fdout[1]); diff -Nru kmod-28/testsuite/testsuite.h kmod-29/testsuite/testsuite.h --- kmod-28/testsuite/testsuite.h 2021-01-07 19:43:36.000000000 +0100 +++ kmod-29/testsuite/testsuite.h 2021-05-21 01:02:57.000000000 +0200 @@ -109,6 +109,8 @@ const struct keyval *env_vars; bool need_spawn; bool expected_fail; + /* allow to skip tests that don't meet compile-time dependencies */ + bool skip; bool print_outputs; } __attribute__((aligned(8))); @@ -138,14 +140,16 @@ /* Test definitions */ -#define DEFINE_TEST(_name, ...) \ +#define DEFINE_TEST_WITH_FUNC(_name, _func, ...) \ static const struct test UNIQ(s##_name) \ __attribute__((used, section("kmod_tests"), aligned(8))) = { \ .name = #_name, \ - .func = _name, \ + .func = _func, \ ## __VA_ARGS__ \ }; +#define DEFINE_TEST(_name, ...) DEFINE_TEST_WITH_FUNC(_name, _name, __VA_ARGS__) + #define TESTSUITE_MAIN() \ extern struct test __start_kmod_tests[] __attribute__((weak, visibility("hidden"))); \ extern struct test __stop_kmod_tests[] __attribute__((weak, visibility("hidden"))); \ diff -Nru kmod-28/tools/depmod.c kmod-29/tools/depmod.c --- kmod-28/tools/depmod.c 2021-01-07 19:43:36.000000000 +0100 +++ kmod-29/tools/depmod.c 2021-05-21 01:02:57.000000000 +0200 @@ -51,8 +51,9 @@ static const char CFG_BUILTIN_KEY[] = "built-in"; static const char CFG_EXTERNAL_KEY[] = "external"; static const char *default_cfg_paths[] = { - "/run/depmod.d", SYSCONFDIR "/depmod.d", + "/run/depmod.d", + "/usr/local/lib/depmod.d", "/lib/depmod.d", NULL }; @@ -2456,7 +2457,7 @@ out: /* do not bother writing the index if we are going to discard it */ - if (!ret) + if (ret > 0) index_write(idx, out); if (builtin) diff -Nru kmod-28/tools/modinfo.c kmod-29/tools/modinfo.c --- kmod-28/tools/modinfo.c 2021-01-07 19:43:36.000000000 +0100 +++ kmod-29/tools/modinfo.c 2021-05-21 01:02:57.000000000 +0200 @@ -178,7 +178,11 @@ is_builtin = (filename == NULL); if (is_builtin) { - printf("%-16s%s%c", "name:", kmod_module_get_name(mod), separator); + if (field == NULL) + printf("%-16s%s%c", "name:", + kmod_module_get_name(mod), separator); + else if (field != NULL && streq(field, "name")) + printf("%s%c", kmod_module_get_name(mod), separator); filename = "(builtin)"; }