Snap for 8426163 from 9271b26ce33f744b2f0d3dde6ed9609e345cc710 to mainline-tzdata2-release
Change-Id: Ibf98c0b7a5d56c7c1a2e1673915f11591f10481a
diff --git a/.gitignore b/.gitignore
index 2347858..aa02fbf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,9 +16,10 @@
/config.log
/config.status
/configure
-/cov-int
/coverage
-/kmod-*.tar.*
+/cov-int
+/doltcompile
+/doltlibtool
/libtool
/stamp-h1
/test-suite.log
diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml
new file mode 100644
index 0000000..db47ca1
--- /dev/null
+++ b/.semaphore/semaphore.yml
@@ -0,0 +1,46 @@
+version: v1.0
+name: Build and Check
+agent:
+ machine:
+ type: e1-standard-2
+ os_image: ubuntu1804
+
+blocks:
+ - name: "Build"
+ task:
+ jobs:
+ - name: Build gcc-8
+ commands:
+ - sem-version c 8
+ - name: Build gcc-7
+ commands:
+ - sem-version c 7
+ - name: Build gcc-6
+ commands:
+ - sem-version c 6
+
+ prologue:
+ commands:
+ - sudo apt update
+ - sudo apt --yes install docbook-xsl liblzma-dev zlib1g-dev cython linux-headers-generic libssl-dev
+ - checkout
+
+ epilogue:
+ commands:
+ - ./autogen.sh c
+ - make
+
+ - name: "Unit tests"
+ task:
+ jobs:
+ - name: check
+ commands:
+ - sem-version c 8
+ - ./autogen.sh c
+ - make check
+
+ prologue:
+ commands:
+ - sudo apt update
+ - sudo apt --yes install docbook-xsl liblzma-dev zlib1g-dev cython linux-headers-generic libssl-dev
+ - checkout
diff --git a/.travis.yml b/.travis.yml
index 2adb3c6..4b36e1f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,30 +1,28 @@
language: c
-dist: focal
-
-matrix:
- include:
- - compiler: gcc
- env: CC=gcc
- - compiler: clang
- env: CC=clang
-
before_install:
+ - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
- sudo apt-get update -qq
- - sudo apt-get install -qq libzstd-dev zstd
- sudo apt-get install -qq liblzma-dev
- sudo apt-get install -qq zlib1g-dev
- sudo apt-get install -qq xsltproc docbook-xsl
- sudo apt-get install -qq cython
- sudo apt-get install -qq linux-headers-generic
-
+ - if [ "$MYCC" = "gcc-4.8" ]; then sudo apt-get install -qq gcc-4.8; sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 90; gcc --version; fi
+ - if [ "$MYCC" = "gcc-4.9" ]; then sudo apt-get install -qq gcc-4.9; sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 90; gcc --version; fi
before_script:
- unset PYTHON_CFLAGS # hack to broken travis setup
- export KDIR="$(find /lib/modules/* -maxdepth 1 -name build | sort -n --reverse | head -1)"
-
-script:
- - ./autogen.sh c --without-openssl && make -j
- - make -j check
-
+matrix:
+ include:
+ - compiler: gcc
+ env: MYCC=gcc
+ - compiler: gcc
+ env: MYCC=gcc-4.8
+ - compiler: gcc
+ env: MYCC=gcc-4.9
+ - compiler: clang
+ env: MYCC=clang
+script: ./autogen.sh c --without-openssl && make -j && make -j check
notifications:
irc:
channels:
diff --git a/Android.bp b/Android.bp
index 466f34c..f6edaa0 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,43 +1,3 @@
-package {
- default_applicable_licenses: ["external_kmod_license"],
-}
-
-// Added automatically by a large-scale-change that took the approach of
-// 'apply every license found to every target'. While this makes sure we respect
-// every license restriction, it may not be entirely correct.
-//
-// e.g. GPL in an MIT project might only apply to the contrib/ directory.
-//
-// Please consider splitting the single license below into multiple licenses,
-// taking care not to lose any license_kind information, and overriding the
-// default license using the 'licenses: [...]' property on targets as needed.
-//
-// For unused files, consider creating a 'fileGroup' with "//visibility:private"
-// to attach the license to, and including a comment whether the files may be
-// used in the current project.
-//
-// large-scale-change included anything that looked like it might be a license
-// text as a license_text. e.g. LICENSE, NOTICE, COPYING etc.
-//
-// Please consider removing redundant or irrelevant files from 'license_text:'.
-// See: http://go/android-license-faq
-license {
- name: "external_kmod_license",
- visibility: [":__subpackages__"],
- license_kinds: [
- "SPDX-license-identifier-GPL",
- "SPDX-license-identifier-GPL-2.0",
- "SPDX-license-identifier-LGPL",
- "SPDX-license-identifier-LGPL-2.1",
- "SPDX-license-identifier-LGPL-3.0",
- "legacy_unencumbered",
- ],
- license_text: [
- "COPYING",
- "NOTICE",
- ],
-}
-
cc_defaults {
name: "libkmod_cflags_common",
local_include_dirs: ["port-gnu"],
@@ -70,7 +30,6 @@
name: "libkmod",
srcs: [
"libkmod/libkmod.c",
- "libkmod/libkmod-builtin.c",
"libkmod/libkmod-file.c",
"libkmod/libkmod-module.c",
"libkmod/libkmod-config.c",
diff --git a/METADATA b/METADATA
index 6422324..11a0872 100644
--- a/METADATA
+++ b/METADATA
@@ -5,11 +5,10 @@
type: GIT
value: "https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git"
}
- version: "v28"
- license_type: RESTRICTED
+ version: "v26"
last_upgrade_date {
- year: 2021
- month: 1
+ year: 2019
+ month: 2
day: 7
}
}
diff --git a/Makefile.am b/Makefile.am
index acde92b..ddb25f0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -31,34 +31,19 @@
-e 's,@exec_prefix\@,$(exec_prefix),g' \
-e 's,@libdir\@,$(libdir),g' \
-e 's,@includedir\@,$(includedir),g' \
- -e 's,@libzstd_CFLAGS\@,${libzstd_CFLAGS},g' \
- -e 's,@libzstd_LIBS\@,${libzstd_LIBS},g' \
-e 's,@liblzma_CFLAGS\@,${liblzma_CFLAGS},g' \
-e 's,@liblzma_LIBS\@,${liblzma_LIBS},g' \
-e 's,@zlib_CFLAGS\@,${zlib_CFLAGS},g' \
-e 's,@zlib_LIBS\@,${zlib_LIBS},g' \
- -e 's,@libcrypto_CFLAGS\@,${libcrypto_CFLAGS},g' \
- -e 's,@libcrypto_LIBS\@,${libcrypto_LIBS},g' \
+ -e 's,@openssl_CFLAGS\@,${openssl_CFLAGS},g' \
+ -e 's,@openssl_LIBS\@,${openssl_LIBS},g' \
< $< > $@ || rm $@
%.pc: %.pc.in Makefile
$(SED_PROCESS)
-# Rules for libtool versioning (from https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html)
-# 1. Start with version information of ‘0:0:0’ for each libtool library.
-# 2. Update the version information only immediately before a public release of
-# your software. More frequent updates are unnecessary, and only guarantee that
-# the current interface number gets larger faster.
-# 3. If the library source code has changed at all since the last update, then
-# increment revision (‘c:r:a’ becomes ‘c:r+1:a’).
-# 4. If any interfaces have been added, removed, or changed since the last
-# update, increment current, and set revision to 0.
-# 5. If any interfaces have been added since the last public release, then
-# increment age.
-# 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=4
LIBKMOD_AGE=3
noinst_LTLIBRARIES = shared/libshared.la
@@ -83,7 +68,6 @@
libkmod/libkmod.h \
libkmod/libkmod-internal.h \
libkmod/libkmod.c \
- libkmod/libkmod-builtin.c \
libkmod/libkmod-list.c \
libkmod/libkmod-config.c \
libkmod/libkmod-index.c \
@@ -105,7 +89,7 @@
${top_srcdir}/libkmod/libkmod.sym
libkmod_libkmod_la_LIBADD = \
shared/libshared.la \
- ${libzstd_LIBS} ${liblzma_LIBS} ${zlib_LIBS} ${libcrypto_LIBS}
+ ${liblzma_LIBS} ${zlib_LIBS} ${openssl_LIBS}
noinst_LTLIBRARIES += libkmod/libkmod-internal.la
libkmod_libkmod_internal_la_SOURCES = $(libkmod_libkmod_la_SOURCES)
@@ -189,10 +173,7 @@
$(AM_CFLAGS) -DCPYTHON_COMPILING_IN_PYPY=0 \
$(PYTHON_NOWARN) $(PYTHON_CFLAGS) \
-fvisibility=default
-# Filter -Wl,--no-undefined to fix build with python 3.8
-comma = ,
-CPYTHON_MODULE_LDFLAGS = $(subst -Wl$(comma)--no-undefined,,$(AM_LDFLAGS))
-CPYTHON_MODULE_LDFLAGS += -module -avoid-version -shared
+CPYTHON_MODULE_LDFLAGS = $(AM_LDFLAGS) -module -avoid-version -shared
if BUILD_PYTHON
pkgpyexec_LTLIBRARIES = \
@@ -426,7 +407,7 @@
EXTRA_DIST += testsuite/rootfs-pristine
DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc --enable-python --sysconfdir=/etc \
- --with-zlib --with-zstd --with-openssl \
+ --with-zlib --with-openssl \
--with-bashcompletiondir=$$dc_install_base/$(bashcompletiondir)
distclean-local: $(DISTCLEAN_LOCAL_HOOKS)
@@ -434,6 +415,8 @@
buildtest-TESTS:
$(MAKE) $(AM_MAKEFLAGS) $(check_LTLIBRARIES) $(check_PROGRAMS)
+DISTCLEANFILES += $(DOLT_CLEANFILES)
+
# ------------------------------------------------------------------------------
# coverage
# ------------------------------------------------------------------------------
diff --git a/NEWS b/NEWS
index ae56657..58c4e2f 100644
--- a/NEWS
+++ b/NEWS
@@ -1,65 +1,3 @@
-kmod 28
-=======
-
-- Improvements
- - Add Zstandard to the supported compression formats using libzstd
- (pass --with-zstd to configure)
-
-- Bug fixes
- - Ignore ill-formed kernel command line, e.g. with "ivrs_acpihid[00:14.5]=AMD0020:0"
- option in it
- - Fix some memory leaks
- - Fix 0-length builtin.alias.bin: it needs at least the index header
-
-kmod 27
-=======
-
-- Improvements
- - Link to libcrypto rather than requiring openssl
-
- - Print a better error message when kernel doesn't support module unload
-
- - Use PKCS#7 instead of CMS for parsing module signature to be
- compatible with LibreSSL and OpenSSL < 1.1.0
-
- - Teach modinfo to parse modules.builtin.modinfo. When using Linux kernel
- >= v5.2-rc1 it's possible to get module information from this new file. Now
- modinfo is able to show it instead of an error message that the module is
- built-in:
-
- Before:
- $ modinfo ext4
- modinfo: ERROR: Module ext4 not found.
-
- After:
- $ modinfo ext4
- name: ext4
- filename: (builtin)
- softdep: pre: crc32c
- license: GPL
- description: Fourth Extended Filesystem
- author: Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others
- alias: fs-ext4
- alias: ext3
- alias: fs-ext3
- alias: ext2
- alias: fs-ext2
-
-- Bug fixes
- - Do not link python bindings with libpython to be compatible with
- python3.8
-
- - Fix module removal with `modprobe -r` when a dependency is built-in.
- Now it properly ignores them and proceed with removal of other
- dependencies
-
- - Fix propagation of return code from install/remove commands to the
- the probe function. The return values of kmod_module_probe_insert_module()
- have very specific meanings, do not confuse the caller by return codes
- from system()
-
- - Fix softdep config parsing leading to buffer overflow
-
kmod 26
=======
@@ -428,7 +366,7 @@
- New features:
- libkmod now keeps a file opened after the first call to
kmod_module_get_{info,versions,symbols,dependency_symbols}. This
- reduces significantly the amount of time depmod tool takes to
+ reduces signficantly the amount of time depmod tool takes to
execute. Particularly if compressed modules are used.
- Remove --with-rootprefix from build system. It was not a great idea
after all and should not be use since it causes more harm then
diff --git a/autogen.sh b/autogen.sh
index e4997c4..67b119f 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -32,14 +32,7 @@
cd $oldpwd
-hackargs="\
---enable-debug \
---enable-python \
---with-zstd \
---with-xz \
---with-zlib \
---with-openssl \
-"
+hackargs="--enable-debug --enable-python --with-xz --with-zlib --with-openssl"
if [ "x$1" = "xc" ]; then
shift
diff --git a/configure.ac b/configure.ac
index 0cf2eda..ee72283 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
AC_PREREQ(2.64)
AC_INIT([kmod],
- [28],
+ [26],
[linux-modules@vger.kernel.org],
[kmod],
[http://git.kernel.org/?p=utils/kernel/kmod/kmod.git])
@@ -17,6 +17,7 @@
AM_INIT_AUTOMAKE([check-news foreign 1.11 silent-rules tar-pax no-dist-gzip dist-xz subdir-objects color-tests parallel-tests])
AM_SILENT_RULES([yes])
LT_INIT([disable-static pic-only])
+DOLT
AS_IF([test "x$enable_static" = "xyes"], [AC_MSG_ERROR([--enable-static is not supported by kmod])])
AS_IF([test "x$enable_largefile" = "xno"], [AC_MSG_ERROR([--disable-largefile is not supported by kmod])])
@@ -83,17 +84,6 @@
[], [with_rootlibdir=$libdir])
AC_SUBST([rootlibdir], [$with_rootlibdir])
-AC_ARG_WITH([zstd],
- AS_HELP_STRING([--with-zstd], [handle Zstandard-compressed modules @<:@default=disabled@:>@]),
- [], [with_zstd=no])
-AS_IF([test "x$with_zstd" != "xno"], [
- PKG_CHECK_MODULES([libzstd], [libzstd >= 1.4.4])
- AC_DEFINE([ENABLE_ZSTD], [1], [Enable Zstandard for modules.])
-], [
- AC_MSG_NOTICE([Zstandard support not requested])
-])
-CC_FEATURE_APPEND([with_features], [with_zstd], [ZSTD])
-
AC_ARG_WITH([xz],
AS_HELP_STRING([--with-xz], [handle Xz-compressed modules @<:@default=disabled@:>@]),
[], [with_xz=no])
@@ -120,12 +110,12 @@
AS_HELP_STRING([--with-openssl], [handle PKCS7 signatures @<:@default=disabled@:>@]),
[], [with_openssl=no])
AS_IF([test "x$with_openssl" != "xno"], [
- PKG_CHECK_MODULES([libcrypto], [libcrypto >= 1.1.0])
+ PKG_CHECK_MODULES([openssl], [openssl >= 1.1.0])
AC_DEFINE([ENABLE_OPENSSL], [1], [Enable openssl for modinfo.])
], [
AC_MSG_NOTICE([openssl support not requested])
])
-CC_FEATURE_APPEND([with_features], [with_openssl], [LIBCRYPTO])
+CC_FEATURE_APPEND([with_features], [with_openssl], [OPENSSL])
AC_ARG_WITH([bashcompletiondir],
AS_HELP_STRING([--with-bashcompletiondir=DIR], [Bash completions directory]),
@@ -318,7 +308,7 @@
tools: ${enable_tools}
python bindings: ${enable_python}
logging: ${enable_logging}
- compression: zstd=${with_zstd} xz=${with_xz} zlib=${with_zlib}
+ compression: xz=${with_xz} zlib=${with_zlib}
debug: ${enable_debug}
coverage: ${enable_coverage}
doc: ${enable_gtk_doc}
diff --git a/libkmod/libkmod-builtin.c b/libkmod/libkmod-builtin.c
deleted file mode 100644
index fc9a376..0000000
--- a/libkmod/libkmod-builtin.c
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- * libkmod - interface to kernel built-in modules
- *
- * Copyright (C) 2019 Alexey Gladkov <gladkov.alexey@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-
-#include "libkmod.h"
-#include "libkmod-internal.h"
-
-#define MODULES_BUILTIN_MODINFO "modules.builtin.modinfo"
-
-struct kmod_builtin_iter {
- struct kmod_ctx *ctx;
-
- // The file descriptor.
- int file;
-
- // The total size in bytes.
- ssize_t size;
-
- // The offset of current module.
- off_t pos;
-
- // The offset at which the next module is located.
- off_t next;
-
- // Number of strings in the current block.
- ssize_t nstrings;
-
- // Internal buffer and its size.
- size_t bufsz;
- char *buf;
-};
-
-struct kmod_builtin_iter *kmod_builtin_iter_new(struct kmod_ctx *ctx)
-{
- char path[PATH_MAX];
- int file, sv_errno;
- struct stat sb;
- struct kmod_builtin_iter *iter = NULL;
- const char *dirname = kmod_get_dirname(ctx);
- size_t len = strlen(dirname);
-
- file = -1;
-
- if ((len + 1 + strlen(MODULES_BUILTIN_MODINFO) + 1) >= PATH_MAX) {
- sv_errno = ENAMETOOLONG;
- goto fail;
- }
-
- snprintf(path, PATH_MAX, "%s/%s", dirname, MODULES_BUILTIN_MODINFO);
-
- file = open(path, O_RDONLY|O_CLOEXEC);
- if (file < 0) {
- sv_errno = errno;
- goto fail;
- }
-
- if (fstat(file, &sb) < 0) {
- sv_errno = errno;
- goto fail;
- }
-
- iter = malloc(sizeof(*iter));
- if (!iter) {
- sv_errno = ENOMEM;
- goto fail;
- }
-
- iter->ctx = ctx;
- iter->file = file;
- iter->size = sb.st_size;
- iter->nstrings = 0;
- iter->pos = 0;
- iter->next = 0;
- iter->bufsz = 0;
- iter->buf = NULL;
-
- return iter;
-fail:
- if (file >= 0)
- close(file);
-
- errno = sv_errno;
-
- return iter;
-}
-
-void kmod_builtin_iter_free(struct kmod_builtin_iter *iter)
-{
- close(iter->file);
- free(iter->buf);
- free(iter);
-}
-
-static off_t get_string(struct kmod_builtin_iter *iter, off_t offset,
- char **line, size_t *size)
-{
- int sv_errno;
- char *nullp = NULL;
- size_t linesz = 0;
-
- while (!nullp) {
- char buf[BUFSIZ];
- ssize_t sz;
- size_t partsz;
-
- sz = pread(iter->file, buf, BUFSIZ, offset);
- if (sz < 0) {
- sv_errno = errno;
- goto fail;
- } else if (sz == 0) {
- offset = 0;
- break;
- }
-
- nullp = memchr(buf, '\0', (size_t) sz);
- partsz = (size_t)((nullp) ? (nullp - buf) + 1 : sz);
- offset += (off_t) partsz;
-
- if (iter->bufsz < linesz + partsz) {
- iter->bufsz = linesz + partsz;
- iter->buf = realloc(iter->buf, iter->bufsz);
-
- if (!iter->buf) {
- sv_errno = errno;
- goto fail;
- }
- }
-
- strncpy(iter->buf + linesz, buf, partsz);
- linesz += partsz;
- }
-
- if (linesz) {
- *line = iter->buf;
- *size = linesz;
- }
-
- return offset;
-fail:
- errno = sv_errno;
- return -1;
-}
-
-bool kmod_builtin_iter_next(struct kmod_builtin_iter *iter)
-{
- char *line, *modname;
- size_t linesz;
- off_t pos, offset, modlen;
-
- modname = NULL;
-
- iter->nstrings = 0;
- offset = pos = iter->next;
-
- while (offset < iter->size) {
- char *dot;
- off_t len;
-
- offset = get_string(iter, pos, &line, &linesz);
- if (offset <= 0) {
- if (offset)
- ERR(iter->ctx, "get_string: %s\n", strerror(errno));
- pos = iter->size;
- break;
- }
-
- dot = strchr(line, '.');
- if (!dot) {
- ERR(iter->ctx, "kmod_builtin_iter_next: unexpected string without modname prefix\n");
- pos = iter->size;
- break;
- }
-
- len = dot - line;
-
- if (!modname) {
- modname = strdup(line);
- modlen = len;
- } else if (modlen != len || strncmp(modname, line, len)) {
- break;
- }
-
- iter->nstrings++;
- pos = offset;
- }
-
- iter->pos = iter->next;
- iter->next = pos;
-
- free(modname);
-
- return (iter->pos < iter->size);
-}
-
-bool kmod_builtin_iter_get_modname(struct kmod_builtin_iter *iter,
- char modname[static PATH_MAX])
-{
- int sv_errno;
- char *line, *dot;
- size_t linesz, len;
- off_t offset;
-
- if (iter->pos == iter->size)
- return false;
-
- line = NULL;
-
- offset = get_string(iter, iter->pos, &line, &linesz);
- if (offset <= 0) {
- sv_errno = errno;
- if (offset)
- ERR(iter->ctx, "get_string: %s\n", strerror(errno));
- goto fail;
- }
-
- dot = strchr(line, '.');
- if (!dot) {
- sv_errno = errno;
- ERR(iter->ctx, "kmod_builtin_iter_get_modname: unexpected string without modname prefix\n");
- goto fail;
- }
-
- len = dot - line;
-
- if (len > PATH_MAX) {
- sv_errno = ENAMETOOLONG;
- goto fail;
- }
-
- strncpy(modname, line, len);
- modname[len] = '\0';
-
- return true;
-fail:
- errno = sv_errno;
- return false;
-}
-
-/* array will be allocated with strings in a single malloc, just free *array */
-ssize_t kmod_builtin_get_modinfo(struct kmod_ctx *ctx, const char *modname,
- char ***modinfo)
-{
- ssize_t count = 0;
- char *s, *line = NULL;
- size_t i, n, linesz, modlen, size;
- off_t pos, offset;
-
- char *name = NULL;
- char buf[PATH_MAX];
-
- struct kmod_builtin_iter *iter = kmod_builtin_iter_new(ctx);
-
- if (!iter)
- return -errno;
-
- while (!name && kmod_builtin_iter_next(iter)) {
- if (!kmod_builtin_iter_get_modname(iter, buf)) {
- count = -errno;
- goto fail;
- }
-
- if (strcmp(modname, buf))
- continue;
-
- name = buf;
- }
-
- if (!name) {
- count = -ENOSYS;
- goto fail;
- }
-
- modlen = strlen(modname) + 1;
- count = iter->nstrings;
- size = iter->next - iter->pos - (modlen * count);
-
- *modinfo = malloc(size + sizeof(char *) * (count + 1));
- if (!*modinfo) {
- count = -errno;
- goto fail;
- }
-
- s = (char *)(*modinfo + count + 1);
- i = 0;
-
- n = 0;
- offset = pos = iter->pos;
-
- while (offset < iter->next) {
- offset = get_string(iter, pos, &line, &linesz);
- if (offset <= 0) {
- count = (offset) ? -errno : -EOF;
- free(*modinfo);
- goto fail;
- }
-
- strcpy(s + i, line + modlen);
- (*modinfo)[n++] = s + i;
- i += linesz - modlen;
-
- pos = offset;
- }
-fail:
- kmod_builtin_iter_free(iter);
- return count;
-}
diff --git a/libkmod/libkmod-config.c b/libkmod/libkmod-config.c
index 971f20b..aaac0a1 100644
--- a/libkmod/libkmod-config.c
+++ b/libkmod/libkmod-config.c
@@ -335,7 +335,6 @@
n_pre = 0;
n_post = 0;
mode = S_NONE;
- was_space = false;
for (p = s = line; ; s++) {
size_t plen;
@@ -488,9 +487,8 @@
if (underscores(modname) < 0) {
ERR(config->ctx, "Ignoring bad option on kernel command line while parsing module name: '%s'\n",
modname);
- } else {
- kmod_config_add_options(config, modname, param);
}
+ kmod_config_add_options(config, modname, param);
}
}
diff --git a/libkmod/libkmod-file.c b/libkmod/libkmod-file.c
index b6a8cc9..5eeba6a 100644
--- a/libkmod/libkmod-file.c
+++ b/libkmod/libkmod-file.c
@@ -26,9 +26,6 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
-#ifdef ENABLE_ZSTD
-#include <zstd.h>
-#endif
#ifdef ENABLE_XZ
#include <lzma.h>
#endif
@@ -48,9 +45,6 @@
};
struct kmod_file {
-#ifdef ENABLE_ZSTD
- bool zstd_used;
-#endif
#ifdef ENABLE_XZ
bool xz_used;
#endif
@@ -66,141 +60,6 @@
struct kmod_elf *elf;
};
-#ifdef ENABLE_ZSTD
-static int zstd_read_block(struct kmod_file *file, size_t block_size,
- ZSTD_inBuffer *input, size_t *input_capacity)
-{
- ssize_t rdret;
- int ret;
-
- if (*input_capacity < block_size) {
- free((void *)input->src);
- input->src = malloc(block_size);
- if (input->src == NULL) {
- ret = -errno;
- ERR(file->ctx, "zstd: %m\n");
- return ret;
- }
- *input_capacity = block_size;
- }
-
- rdret = read(file->fd, (void *)input->src, block_size);
- if (rdret < 0) {
- ret = -errno;
- ERR(file->ctx, "zstd: %m\n");
- return ret;
- }
-
- input->pos = 0;
- input->size = rdret;
- return 0;
-}
-
-static int zstd_ensure_outbuffer_space(ZSTD_outBuffer *buffer, size_t min_free)
-{
- uint8_t *old_buffer = buffer->dst;
- int ret = 0;
-
- if (buffer->size - buffer->pos >= min_free)
- return 0;
-
- buffer->size += min_free;
- buffer->dst = realloc(buffer->dst, buffer->size);
- if (buffer->dst == NULL) {
- ret = -errno;
- free(old_buffer);
- }
-
- return ret;
-}
-
-static int zstd_decompress_block(struct kmod_file *file, ZSTD_DStream *dstr,
- ZSTD_inBuffer *input, ZSTD_outBuffer *output,
- size_t *next_block_size)
-{
- size_t out_buf_min_size = ZSTD_DStreamOutSize();
- int ret = 0;
-
- do {
- ssize_t dsret;
-
- ret = zstd_ensure_outbuffer_space(output, out_buf_min_size);
- if (ret) {
- ERR(file->ctx, "zstd: %s\n", strerror(-ret));
- break;
- }
-
- dsret = ZSTD_decompressStream(dstr, output, input);
- if (ZSTD_isError(dsret)) {
- ret = -EINVAL;
- ERR(file->ctx, "zstd: %s\n", ZSTD_getErrorName(dsret));
- break;
- }
- if (dsret > 0)
- *next_block_size = (size_t)dsret;
- } while (input->pos < input->size
- || output->pos > output->size
- || output->size - output->pos < out_buf_min_size);
-
- return ret;
-}
-
-static int load_zstd(struct kmod_file *file)
-{
- ZSTD_DStream *dstr;
- size_t next_block_size;
- size_t zst_inb_capacity = 0;
- ZSTD_inBuffer zst_inb = { 0 };
- ZSTD_outBuffer zst_outb = { 0 };
- int ret;
-
- dstr = ZSTD_createDStream();
- if (dstr == NULL) {
- ret = -EINVAL;
- ERR(file->ctx, "zstd: Failed to create decompression stream\n");
- goto out;
- }
-
- next_block_size = ZSTD_initDStream(dstr);
-
- while (true) {
- ret = zstd_read_block(file, next_block_size, &zst_inb,
- &zst_inb_capacity);
- if (ret != 0)
- goto out;
- if (zst_inb.size == 0) /* EOF */
- break;
-
- ret = zstd_decompress_block(file, dstr, &zst_inb, &zst_outb,
- &next_block_size);
- if (ret != 0)
- goto out;
- }
-
- ZSTD_freeDStream(dstr);
- free((void *)zst_inb.src);
- file->zstd_used = true;
- file->memory = zst_outb.dst;
- file->size = zst_outb.pos;
- return 0;
-out:
- if (dstr != NULL)
- ZSTD_freeDStream(dstr);
- free((void *)zst_inb.src);
- free((void *)zst_outb.dst);
- return ret;
-}
-
-static void unload_zstd(struct kmod_file *file)
-{
- if (!file->zstd_used)
- return;
- free(file->memory);
-}
-
-static const char magic_zstd[] = {0x28, 0xB5, 0x2F, 0xFD};
-#endif
-
#ifdef ENABLE_XZ
static void xz_uncompress_belch(struct kmod_file *file, lzma_ret ret)
{
@@ -379,9 +238,6 @@
const char *magic_bytes;
const struct file_ops ops;
} comp_types[] = {
-#ifdef ENABLE_ZSTD
- {sizeof(magic_zstd), magic_zstd, {load_zstd, unload_zstd}},
-#endif
#ifdef ENABLE_XZ
{sizeof(magic_xz), magic_xz, {load_xz, unload_xz}},
#endif
diff --git a/libkmod/libkmod-index.c b/libkmod/libkmod-index.c
index 2383e7e..05669dc 100644
--- a/libkmod/libkmod-index.c
+++ b/libkmod/libkmod-index.c
@@ -611,7 +611,7 @@
static const char _idx_empty_str[] = "";
struct index_mm {
- const struct kmod_ctx *ctx;
+ struct kmod_ctx *ctx;
void *mm;
uint32_t root_offset;
size_t size;
@@ -739,10 +739,10 @@
free(node);
}
-int index_mm_open(const struct kmod_ctx *ctx, const char *filename,
- unsigned long long *stamp, struct index_mm **pidx)
+struct index_mm *index_mm_open(struct kmod_ctx *ctx, const char *filename,
+ unsigned long long *stamp)
{
- int fd, err;
+ int fd;
struct stat st;
struct index_mm *idx;
struct {
@@ -752,32 +752,28 @@
} hdr;
void *p;
- assert(pidx != NULL);
-
DBG(ctx, "file=%s\n", filename);
idx = malloc(sizeof(*idx));
if (idx == NULL) {
ERR(ctx, "malloc: %m\n");
- return -ENOMEM;
+ return NULL;
}
if ((fd = open(filename, O_RDONLY|O_CLOEXEC)) < 0) {
DBG(ctx, "open(%s, O_RDONLY|O_CLOEXEC): %m\n", filename);
- err = -errno;
goto fail_open;
}
- if (fstat(fd, &st) < 0 || (size_t) st.st_size < sizeof(hdr)) {
- err = -EINVAL;
+ if (fstat(fd, &st) < 0)
goto fail_nommap;
- }
+ if ((size_t) st.st_size < sizeof(hdr))
+ goto fail_nommap;
- idx->mm = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
- if (idx->mm == MAP_FAILED) {
+ if ((idx->mm = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0))
+ == MAP_FAILED) {
ERR(ctx, "mmap(NULL, %"PRIu64", PROT_READ, %d, MAP_PRIVATE, 0): %m\n",
st.st_size, fd);
- err = -errno;
goto fail_nommap;
}
@@ -789,14 +785,12 @@
if (hdr.magic != INDEX_MAGIC) {
ERR(ctx, "magic check fail: %x instead of %x\n", hdr.magic,
INDEX_MAGIC);
- err = -EINVAL;
goto fail;
}
if (hdr.version >> 16 != INDEX_VERSION_MAJOR) {
ERR(ctx, "major version check fail: %u instead of %u\n",
hdr.version >> 16, INDEX_VERSION_MAJOR);
- err = -EINVAL;
goto fail;
}
@@ -806,9 +800,8 @@
close(fd);
*stamp = stat_mstamp(&st);
- *pidx = idx;
- return 0;
+ return idx;
fail:
munmap(idx->mm, st.st_size);
@@ -816,7 +809,7 @@
close(fd);
fail_open:
free(idx);
- return err;
+ return NULL;
}
void index_mm_close(struct index_mm *idx)
diff --git a/libkmod/libkmod-index.h b/libkmod/libkmod-index.h
index db671b0..52aebac 100644
--- a/libkmod/libkmod-index.h
+++ b/libkmod/libkmod-index.h
@@ -40,8 +40,8 @@
/* Implementation using mmap */
struct index_mm;
-int index_mm_open(const struct kmod_ctx *ctx, const char *filename,
- unsigned long long *stamp, struct index_mm **pidx);
+struct index_mm *index_mm_open(struct kmod_ctx *ctx, const char *filename,
+ unsigned long long *stamp);
void index_mm_close(struct index_mm *index);
char *index_mm_search(struct index_mm *idx, const char *key);
struct index_value *index_mm_searchwild(struct index_mm *idx, const char *key);
diff --git a/libkmod/libkmod-internal.h b/libkmod/libkmod-internal.h
index 398af9c..a65ddd1 100644
--- a/libkmod/libkmod-internal.h
+++ b/libkmod/libkmod-internal.h
@@ -11,7 +11,7 @@
#include "libkmod.h"
static _always_inline_ _printf_format_(2, 3) void
- kmod_log_null(const struct kmod_ctx *ctx, const char *format, ...) {}
+ kmod_log_null(struct kmod_ctx *ctx, const char *format, ...) {}
#define kmod_log_cond(ctx, prio, arg...) \
do { \
@@ -89,7 +89,6 @@
int kmod_lookup_alias_from_symbols_file(struct kmod_ctx *ctx, const char *name, struct kmod_list **list) __attribute__((nonnull(1, 2, 3)));
int kmod_lookup_alias_from_aliases_file(struct kmod_ctx *ctx, const char *name, struct kmod_list **list) __attribute__((nonnull(1, 2, 3)));
int kmod_lookup_alias_from_moddep_file(struct kmod_ctx *ctx, const char *name, struct kmod_list **list) __attribute__((nonnull(1, 2, 3)));
-int kmod_lookup_alias_from_kernel_builtin_file(struct kmod_ctx *ctx, const char *name, struct kmod_list **list) __attribute__((nonnull(1, 2, 3)));
int kmod_lookup_alias_from_builtin_file(struct kmod_ctx *ctx, const char *name, struct kmod_list **list) __attribute__((nonnull(1, 2, 3)));
bool kmod_lookup_alias_is_builtin(struct kmod_ctx *ctx, const char *name) __attribute__((nonnull(1, 2)));
int kmod_lookup_alias_from_commands(struct kmod_ctx *ctx, const char *name, struct kmod_list **list) __attribute__((nonnull(1, 2, 3)));
@@ -146,7 +145,6 @@
void kmod_module_set_builtin(struct kmod_module *mod, bool builtin) __attribute__((nonnull((1))));
void kmod_module_set_required(struct kmod_module *mod, bool required) __attribute__((nonnull(1)));
bool kmod_module_is_builtin(struct kmod_module *mod) __attribute__((nonnull(1)));
-int kmod_module_get_builtin(struct kmod_ctx *ctx, struct kmod_list **list) __attribute__((nonnull(1, 2)));
/* libkmod-file.c */
struct kmod_file *kmod_file_open(const struct kmod_ctx *ctx, const char *filename) _must_check_ __attribute__((nonnull(1,2)));
@@ -195,11 +193,3 @@
};
bool kmod_module_signature_info(const struct kmod_file *file, struct kmod_signature_info *sig_info) _must_check_ __attribute__((nonnull(1, 2)));
void kmod_module_signature_info_free(struct kmod_signature_info *sig_info) __attribute__((nonnull));
-
-/* libkmod-builtin.c */
-struct kmod_builtin_iter;
-struct kmod_builtin_iter *kmod_builtin_iter_new(struct kmod_ctx *ctx) __attribute__((nonnull(1)));
-void kmod_builtin_iter_free(struct kmod_builtin_iter *iter) __attribute__((nonnull(1)));
-bool kmod_builtin_iter_next(struct kmod_builtin_iter *iter) __attribute__((nonnull(1)));
-bool kmod_builtin_iter_get_modname(struct kmod_builtin_iter *iter, char modname[static PATH_MAX]) __attribute__((nonnull(1, 2)));
-ssize_t kmod_builtin_get_modinfo(struct kmod_ctx *ctx, const char *modname, char ***modinfo) __attribute__((nonnull(1, 2, 3)));
diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index 76a6dc3..bffe715 100644
--- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c
@@ -575,16 +575,10 @@
err = kmod_lookup_alias_from_aliases_file(ctx, alias, list);
CHECK_ERR_AND_FINISH(err, fail, list, finish);
- DBG(ctx, "lookup modules.builtin.modinfo %s\n", alias);
- err = kmod_lookup_alias_from_kernel_builtin_file(ctx, alias, list);
- if (err == -ENOSYS) {
- /* Optional index missing, try the old one */
- DBG(ctx, "lookup modules.builtin %s\n", alias);
- err = kmod_lookup_alias_from_builtin_file(ctx, alias, list);
- }
+ DBG(ctx, "lookup modules.builtin %s\n", alias);
+ err = kmod_lookup_alias_from_builtin_file(ctx, alias, list);
CHECK_ERR_AND_FINISH(err, fail, list, finish);
-
finish:
DBG(ctx, "lookup %s=%d, list=%p\n", alias, err, *list);
return err;
@@ -980,19 +974,14 @@
err = system(cmd);
unsetenv("MODPROBE_MODULE");
- if (err == -1) {
- ERR(mod->ctx, "Could not run %s command '%s' for module %s: %m\n",
- type, cmd, modname);
- return -EINVAL;
+ if (err == -1 || WEXITSTATUS(err)) {
+ ERR(mod->ctx, "Error running %s command for %s\n",
+ type, modname);
+ if (err != -1)
+ err = -WEXITSTATUS(err);
}
- if (WEXITSTATUS(err)) {
- ERR(mod->ctx, "Error running %s command '%s' for module %s: retcode %d\n",
- type, cmd, modname, WEXITSTATUS(err));
- return -EINVAL;
- }
-
- return 0;
+ return err;
}
struct probe_insert_cb {
@@ -2291,22 +2280,13 @@
assert(*list == NULL);
- /* remove const: this can only change internal state */
- if (kmod_module_is_builtin((struct kmod_module *)mod)) {
- count = kmod_builtin_get_modinfo(mod->ctx,
- kmod_module_get_name(mod),
- &strings);
- if (count < 0)
- return count;
- } else {
- elf = kmod_module_get_elf(mod);
- if (elf == NULL)
- return -errno;
+ elf = kmod_module_get_elf(mod);
+ if (elf == NULL)
+ return -errno;
- count = kmod_elf_get_strings(elf, ".modinfo", &strings);
- if (count < 0)
- return count;
- }
+ count = kmod_elf_get_strings(elf, ".modinfo", &strings);
+ if (count < 0)
+ return count;
for (i = 0; i < count; i++) {
struct kmod_list *n;
@@ -2330,7 +2310,7 @@
goto list_error;
}
- if (mod->file && kmod_module_signature_info(mod->file, &sig_info)) {
+ if (kmod_module_signature_info(mod->file, &sig_info)) {
struct kmod_list *n;
n = kmod_module_info_append(list, "sig_id", strlen("sig_id"),
@@ -2886,43 +2866,3 @@
list = kmod_list_remove(list);
}
}
-
-/**
- * kmod_module_get_builtin:
- * @ctx: kmod library context
- * @list: where to save the builtin module list
- *
- * Returns: 0 on success or < 0 otherwise.
- */
-int kmod_module_get_builtin(struct kmod_ctx *ctx, struct kmod_list **list)
-{
- struct kmod_builtin_iter *iter;
- int err = 0;
-
- iter = kmod_builtin_iter_new(ctx);
- if (!iter)
- return -errno;
-
- while (kmod_builtin_iter_next(iter)) {
- struct kmod_module *mod = NULL;
- char modname[PATH_MAX];
-
- if (!kmod_builtin_iter_get_modname(iter, modname)) {
- err = -errno;
- goto fail;
- }
-
- kmod_module_new_from_name(ctx, modname, &mod);
- kmod_module_set_builtin(mod, true);
-
- *list = kmod_list_append(*list, mod);
- }
-
- kmod_builtin_iter_free(iter);
- return err;
-fail:
- kmod_builtin_iter_free(iter);
- kmod_module_unref_list(*list);
- *list = NULL;
- return err;
-}
diff --git a/libkmod/libkmod-signature.c b/libkmod/libkmod-signature.c
index 9877cf3..27d0a8f 100644
--- a/libkmod/libkmod-signature.c
+++ b/libkmod/libkmod-signature.c
@@ -19,7 +19,7 @@
#include <inttypes.h>
#ifdef ENABLE_OPENSSL
-#include <openssl/pkcs7.h>
+#include <openssl/cms.h>
#include <openssl/ssl.h>
#endif
#include <stdio.h>
@@ -121,7 +121,7 @@
#ifdef ENABLE_OPENSSL
struct pkcs7_private {
- PKCS7 *pkcs7;
+ CMS_ContentInfo *cms;
unsigned char *key_id;
BIGNUM *sno;
};
@@ -131,7 +131,7 @@
struct kmod_signature_info *si = s;
struct pkcs7_private *pvt = si->private;
- PKCS7_free(pvt->pkcs7);
+ CMS_ContentInfo_free(pvt->cms);
BN_free(pvt->sno);
free(pvt->key_id);
free(pvt);
@@ -196,10 +196,11 @@
struct kmod_signature_info *sig_info)
{
const char *pkcs7_raw;
- PKCS7 *pkcs7;
- STACK_OF(PKCS7_SIGNER_INFO) *sis;
- PKCS7_SIGNER_INFO *si;
- PKCS7_ISSUER_AND_SERIAL *is;
+ CMS_ContentInfo *cms;
+ STACK_OF(CMS_SignerInfo) *sis;
+ CMS_SignerInfo *si;
+ int rc;
+ ASN1_OCTET_STRING *key_id;
X509_NAME *issuer;
ASN1_INTEGER *sno;
ASN1_OCTET_STRING *sig;
@@ -218,33 +219,31 @@
in = BIO_new_mem_buf(pkcs7_raw, sig_len);
- pkcs7 = d2i_PKCS7_bio(in, NULL);
- if (pkcs7 == NULL) {
+ cms = d2i_CMS_bio(in, NULL);
+ if (cms == NULL) {
BIO_free(in);
return false;
}
BIO_free(in);
- sis = PKCS7_get_signer_info(pkcs7);
+ sis = CMS_get0_SignerInfos(cms);
if (sis == NULL)
goto err;
- si = sk_PKCS7_SIGNER_INFO_value(sis, 0);
+ si = sk_CMS_SignerInfo_value(sis, 0);
if (si == NULL)
goto err;
- is = si->issuer_and_serial;
- if (is == NULL)
+ rc = CMS_SignerInfo_get0_signer_id(si, &key_id, &issuer, &sno);
+ if (rc == 0)
goto err;
- issuer = is->issuer;
- sno = is->serial;
- sig = si->enc_digest;
+ sig = CMS_SignerInfo_get0_signature(si);
if (sig == NULL)
goto err;
- PKCS7_SIGNER_INFO_get0_algs(si, NULL, &dig_alg, &sig_alg);
+ CMS_SignerInfo_get0_algs(si, NULL, NULL, &dig_alg, &sig_alg);
sig_info->sig = (const char *)ASN1_STRING_get0_data(sig);
sig_info->sig_len = ASN1_STRING_length(sig);
@@ -277,7 +276,7 @@
if (pvt == NULL)
goto err3;
- pvt->pkcs7 = pkcs7;
+ pvt->cms = cms;
pvt->key_id = key_id_str;
pvt->sno = sno_bn;
sig_info->private = pvt;
@@ -290,7 +289,7 @@
err2:
BN_free(sno_bn);
err:
- PKCS7_free(pkcs7);
+ CMS_ContentInfo_free(cms);
return false;
}
diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c
index 43423d6..69fe431 100644
--- a/libkmod/libkmod.c
+++ b/libkmod/libkmod.c
@@ -57,7 +57,6 @@
[KMOD_INDEX_MODULES_DEP] = { .fn = "modules.dep", .prefix = "" },
[KMOD_INDEX_MODULES_ALIAS] = { .fn = "modules.alias", .prefix = "alias " },
[KMOD_INDEX_MODULES_SYMBOL] = { .fn = "modules.symbols", .prefix = "alias "},
- [KMOD_INDEX_MODULES_BUILTIN_ALIAS] = { .fn = "modules.builtin.alias", .prefix = "" },
[KMOD_INDEX_MODULES_BUILTIN] = { .fn = "modules.builtin", .prefix = ""},
};
@@ -523,27 +522,6 @@
return line;
}
-int kmod_lookup_alias_from_kernel_builtin_file(struct kmod_ctx *ctx,
- const char *name,
- struct kmod_list **list)
-{
- struct kmod_list *l;
- int ret;
-
- assert(*list == NULL);
-
- ret = kmod_lookup_alias_from_alias_bin(ctx,
- KMOD_INDEX_MODULES_BUILTIN_ALIAS,
- name, list);
-
- kmod_list_foreach(l, *list) {
- struct kmod_module *mod = l->data;
- kmod_module_set_builtin(mod, true);
- }
-
- return ret;
-}
-
int kmod_lookup_alias_from_builtin_file(struct kmod_ctx *ctx, const char *name,
struct kmod_list **list)
{
@@ -855,7 +833,6 @@
*/
KMOD_EXPORT int kmod_load_resources(struct kmod_ctx *ctx)
{
- int ret = 0;
size_t i;
if (ctx == NULL)
@@ -872,25 +849,17 @@
snprintf(path, sizeof(path), "%s/%s.bin", ctx->dirname,
index_files[i].fn);
- ret = index_mm_open(ctx, path, &ctx->indexes_stamp[i],
- &ctx->indexes[i]);
-
- /*
- * modules.builtin.alias are considered optional since it's
- * recently added and older installations may not have it;
- * we allow failing for any reason
- */
- if (ret) {
- if (i != KMOD_INDEX_MODULES_BUILTIN_ALIAS)
- break;
- ret = 0;
- }
+ ctx->indexes[i] = index_mm_open(ctx, path,
+ &ctx->indexes_stamp[i]);
+ if (ctx->indexes[i] == NULL)
+ goto fail;
}
- if (ret)
- kmod_unload_resources(ctx);
+ return 0;
- return ret;
+fail:
+ kmod_unload_resources(ctx);
+ return -ENOMEM;
}
/**
diff --git a/libkmod/libkmod.h b/libkmod/libkmod.h
index 3cab2e5..352627e 100644
--- a/libkmod/libkmod.h
+++ b/libkmod/libkmod.h
@@ -70,7 +70,6 @@
KMOD_INDEX_MODULES_DEP = 0,
KMOD_INDEX_MODULES_ALIAS,
KMOD_INDEX_MODULES_SYMBOL,
- KMOD_INDEX_MODULES_BUILTIN_ALIAS,
KMOD_INDEX_MODULES_BUILTIN,
/* Padding to make sure enum is not mapped to char */
_KMOD_INDEX_PAD = 1U << 31,
diff --git a/libkmod/libkmod.pc.in b/libkmod/libkmod.pc.in
index 3acca6a..e4fdf21 100644
--- a/libkmod/libkmod.pc.in
+++ b/libkmod/libkmod.pc.in
@@ -7,5 +7,5 @@
Description: Library to deal with kernel modules
Version: @VERSION@
Libs: -L${libdir} -lkmod
-Libs.private: @libzstd_LIBS@ @liblzma_LIBS@ @zlib_LIBS@
+Libs.private: @liblzma_LIBS@ @zlib_LIBS@
Cflags: -I${includedir}
diff --git a/m4/dolt.m4 b/m4/dolt.m4
new file mode 100644
index 0000000..775a572
--- /dev/null
+++ b/m4/dolt.m4
@@ -0,0 +1,181 @@
+dnl dolt, a replacement for libtool
+dnl Copyright © 2007-2010 Josh Triplett <josh@joshtriplett.org>
+dnl Copying and distribution of this file, with or without modification,
+dnl are permitted in any medium without royalty provided the copyright
+dnl notice and this notice are preserved.
+dnl
+dnl To use dolt, invoke the DOLT macro immediately after the libtool macros.
+dnl Optionally, copy this file into acinclude.m4, to avoid the need to have it
+dnl installed when running autoconf on your project.
+
+AC_DEFUN([DOLT], [
+AC_REQUIRE([AC_CANONICAL_HOST])
+# dolt, a replacement for libtool
+# Josh Triplett <josh@freedesktop.org>
+AC_PATH_PROG([DOLT_BASH], [bash])
+AC_MSG_CHECKING([if dolt supports this host])
+dolt_supported=yes
+AS_IF([test x$DOLT_BASH = x], [dolt_supported=no])
+AS_IF([test x$GCC != xyes], [dolt_supported=no])
+
+AS_CASE([$host],
+ [*-*-linux*|*-*-freebsd*], [pic_options='-fPIC'],
+ [*-apple-darwin*], [pic_options='-fno-common'],
+ [*mingw*|*nacl*], [pic_options='']
+ [*], [dolt_supported=no]
+)
+AS_IF([test x$dolt_supported = xno], [
+ AC_MSG_RESULT([no, falling back to libtool])
+ LTCOMPILE='$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(COMPILE)'
+ LTCXXCOMPILE='$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXXCOMPILE)'
+ m4_pattern_allow([AM_V_lt])
+], [
+ AC_MSG_RESULT([yes, replacing libtool])
+
+dnl Start writing out doltcompile.
+ cat <<__DOLTCOMPILE__EOF__ >doltcompile
+#!$DOLT_BASH
+__DOLTCOMPILE__EOF__
+ cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
+args=("$[]@")
+for ((arg=0; arg<${#args@<:@@@:>@}; arg++)) ; do
+ if test x"${args@<:@$arg@:>@}" = x-o ; then
+ objarg=$((arg+1))
+ break
+ fi
+done
+if test x$objarg = x ; then
+ echo 'Error: no -o on compiler command line' 1>&2
+ exit 1
+fi
+lo="${args@<:@$objarg@:>@}"
+obj="${lo%.lo}"
+if test x"$lo" = x"$obj" ; then
+ echo "Error: libtool object file name \"$lo\" does not end in .lo" 1>&2
+ exit 1
+fi
+objbase="${obj##*/}"
+__DOLTCOMPILE__EOF__
+
+dnl Write out shared compilation code.
+ if test x$enable_shared = xyes; then
+ cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
+libobjdir="${obj%$objbase}.libs"
+if test ! -d "$libobjdir" ; then
+ mkdir_out="$(mkdir "$libobjdir" 2>&1)"
+ mkdir_ret=$?
+ if test "$mkdir_ret" -ne 0 && test ! -d "$libobjdir" ; then
+ echo "$mkdir_out" 1>&2
+ exit $mkdir_ret
+ fi
+fi
+pic_object="$libobjdir/$objbase.o"
+args@<:@$objarg@:>@="$pic_object"
+__DOLTCOMPILE__EOF__
+ cat <<__DOLTCOMPILE__EOF__ >>doltcompile
+ pic_options="$pic_options"
+ if test x\$passthrough = xtrue; then
+ pic_options=""
+ fi
+__DOLTCOMPILE__EOF__
+ cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
+"${args@<:@@@:>@}" $pic_options -DPIC || exit $?
+__DOLTCOMPILE__EOF__
+ fi
+
+dnl Write out static compilation code.
+dnl Avoid duplicate compiler output if also building shared objects.
+ if test x$enable_static = xyes; then
+ cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
+non_pic_object="$obj.o"
+args@<:@$objarg@:>@="$non_pic_object"
+__DOLTCOMPILE__EOF__
+ if test x$enable_shared = xyes; then
+ cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
+"${args@<:@@@:>@}" >/dev/null 2>&1 || exit $?
+__DOLTCOMPILE__EOF__
+ else
+ cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
+"${args@<:@@@:>@}" || exit $?
+__DOLTCOMPILE__EOF__
+ fi
+ fi
+
+dnl Write out the code to write the .lo file.
+dnl The second line of the .lo file must match "^# Generated by .*libtool"
+ cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
+{
+echo "# $lo - a libtool object file"
+echo "# Generated by doltcompile, not libtool"
+__DOLTCOMPILE__EOF__
+
+ if test x$enable_shared = xyes; then
+ cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
+echo "pic_object='.libs/${objbase}.o'"
+__DOLTCOMPILE__EOF__
+ else
+ cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
+echo pic_object=none
+__DOLTCOMPILE__EOF__
+ fi
+
+ if test x$enable_static = xyes; then
+ cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
+echo "non_pic_object='${objbase}.o'"
+__DOLTCOMPILE__EOF__
+ else
+ cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
+echo non_pic_object=none
+__DOLTCOMPILE__EOF__
+ fi
+
+ cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
+} > "$lo"
+__DOLTCOMPILE__EOF__
+
+dnl Done writing out doltcompile; substitute it for libtool compilation.
+ chmod +x doltcompile
+ LTCOMPILE='$(top_builddir)/doltcompile $(COMPILE)'
+ LTCXXCOMPILE='$(top_builddir)/doltcompile $(CXXCOMPILE)'
+
+dnl automake ignores LTCOMPILE and LTCXXCOMPILE when it has separate CFLAGS for
+dnl a target, so write out a libtool wrapper to handle that case.
+dnl Note that doltlibtool does not handle inferred tags or option arguments
+dnl without '=', because automake does not use them.
+ cat <<__DOLTLIBTOOL__EOF__ > doltlibtool
+#!$DOLT_BASH
+__DOLTLIBTOOL__EOF__
+ cat <<'__DOLTLIBTOOL__EOF__' >>doltlibtool
+top_builddir_slash="${0%%doltlibtool}"
+: ${top_builddir_slash:=./}
+args=()
+modeok=false
+tagok=false
+for arg in "$[]@"; do
+ case "$arg" in
+ --mode=compile) modeok=true ;;
+ --tag=CC|--tag=CXX) tagok=true ;;
+ --tag=disable-static) tagok=true ;;
+ --tag=ASM|--tag=YASM) tagok=true; passthrough=true;;
+ --silent|--quiet) ;;
+ *) args@<:@${#args[@]}@:>@="$arg" ;;
+ esac
+done
+if $modeok && $tagok ; then
+ . ${top_builddir_slash}doltcompile "${args@<:@@@:>@}"
+else
+ exec ${top_builddir_slash}libtool "$[]@"
+fi
+__DOLTLIBTOOL__EOF__
+
+dnl Done writing out doltlibtool; substitute it for libtool.
+ chmod +x doltlibtool
+ LIBTOOL='$(top_builddir)/doltlibtool'
+
+DOLT_CLEANFILES="doltlibtool doltcompile"
+AC_SUBST(DOLT_CLEANFILES)
+])
+AC_SUBST(LTCOMPILE)
+AC_SUBST(LTCXXCOMPILE)
+# end dolt
+])
diff --git a/man/modules.dep.xml b/man/modules.dep.xml
index ed63369..e53293a 100644
--- a/man/modules.dep.xml
+++ b/man/modules.dep.xml
@@ -48,7 +48,7 @@
libkmod.
</para>
<para>
- Its text counterpart is located in the same directory with the name
+ Its text counterpar is located in the same directory with the name
<filename>modules.dep</filename>. The text version is maintained only
for easy of reading by humans and is in no way used by any kmod tool.
</para>
diff --git a/shared/macro.h b/shared/macro.h
index b59f7dc..4fc5405 100644
--- a/shared/macro.h
+++ b/shared/macro.h
@@ -45,14 +45,9 @@
})
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + _array_size_chk(arr))
-
#define XSTRINGIFY(x) #x
#define STRINGIFY(x) XSTRINGIFY(x)
-#define XCONCATENATE(x, y) x ## y
-#define CONCATENATE(x, y) XCONCATENATE(x, y)
-#define UNIQ(x) CONCATENATE(x, __COUNTER__)
-
/* Temporaries for importing index handling */
#define NOFAIL(x) (x)
#define fatal(x...) do { } while (0)
@@ -74,3 +69,5 @@
#define noreturn __attribute__((noreturn))
#endif
#endif
+
+#define UNIQ __COUNTER__
diff --git a/shared/util.c b/shared/util.c
index b487b5f..fd2028d 100644
--- a/shared/util.c
+++ b/shared/util.c
@@ -46,9 +46,6 @@
#ifdef ENABLE_XZ
{".ko.xz", sizeof(".ko.xz") - 1},
#endif
-#ifdef ENABLE_ZSTD
- {".ko.zst", sizeof(".ko.zst") - 1},
-#endif
{ }
};
diff --git a/testsuite/mkosi/mkosi.fedora b/testsuite/mkosi/mkosi.fedora
index 7a2ee5e..5252f87 100644
--- a/testsuite/mkosi/mkosi.fedora
+++ b/testsuite/mkosi/mkosi.fedora
@@ -19,7 +19,6 @@
make
pkgconf-pkg-config
xml-common
- libzstd-devel
xz-devel
zlib-devel
openssl-devel
diff --git a/testsuite/module-playground/.gitignore b/testsuite/module-playground/.gitignore
index fca12f3..6767e0e 100644
--- a/testsuite/module-playground/.gitignore
+++ b/testsuite/module-playground/.gitignore
@@ -2,15 +2,11 @@
*.ko
!mod-simple-*.ko
!cache/*.ko
-.cache.mk
*.mod.c
.tmp_versions
-*.mod
-*.a
-*.cmd
-
modules.order
Module.symvers
+
mod-simple-x86_64.c
mod-simple-i386.c
mod-simple-sparc64.c
diff --git a/testsuite/populate-modules.sh b/testsuite/populate-modules.sh
index 358e740..5140f7a 100755
--- a/testsuite/populate-modules.sh
+++ b/testsuite/populate-modules.sh
@@ -66,11 +66,8 @@
gzip_array=(
"test-depmod/modules-order-compressed/lib/modules/4.4.4/kernel/drivers/block/cciss.ko"
- "test-depmod/modules-order-compressed/lib/modules/4.4.4/kernel/drivers/scsi/scsi_mod.ko"
- )
-
-zstd_array=(
"test-depmod/modules-order-compressed/lib/modules/4.4.4/kernel/drivers/scsi/hpsa.ko"
+ "test-depmod/modules-order-compressed/lib/modules/4.4.4/kernel/drivers/scsi/scsi_mod.ko"
)
attach_sha256_array=(
@@ -104,11 +101,6 @@
gzip $ROOTFS/$m
done
-# zstd-compress these modules
-for m in "${zstd_array[@]}"; do
- zstd --rm $ROOTFS/$m
-done
-
for m in "${attach_sha1_array[@]}"; do
cat ${MODULE_PLAYGROUND}/dummy.sha1 >> ${ROOTFS}/$m
done
diff --git a/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.alias b/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.alias
deleted file mode 100644
index ba76e18..0000000
--- a/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.alias
+++ /dev/null
@@ -1 +0,0 @@
-# Aliases extracted from modules themselves.
diff --git a/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.alias.bin b/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.alias.bin
deleted file mode 100644
index 7075435..0000000
--- a/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.alias.bin
+++ /dev/null
Binary files differ
diff --git a/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.builtin b/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.builtin
deleted file mode 100644
index 1cbec61..0000000
--- a/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.builtin
+++ /dev/null
@@ -1 +0,0 @@
-kernel/fake_builtin.ko
diff --git a/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.builtin.alias.bin b/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.builtin.alias.bin
deleted file mode 100644
index 7075435..0000000
--- a/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.builtin.alias.bin
+++ /dev/null
Binary files differ
diff --git a/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.builtin.bin b/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.builtin.bin
deleted file mode 100644
index 0423f03..0000000
--- a/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.builtin.bin
+++ /dev/null
Binary files differ
diff --git a/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.dep b/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.dep
deleted file mode 100644
index e69de29..0000000
--- a/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.dep
+++ /dev/null
diff --git a/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.dep.bin b/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.dep.bin
deleted file mode 100644
index 7075435..0000000
--- a/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.dep.bin
+++ /dev/null
Binary files differ
diff --git a/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.devname b/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.devname
deleted file mode 100644
index 58f6d6d..0000000
--- a/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.devname
+++ /dev/null
@@ -1 +0,0 @@
-# Device nodes to trigger on-demand module loading.
diff --git a/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.softdep b/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.softdep
deleted file mode 100644
index 5554ccc..0000000
--- a/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.softdep
+++ /dev/null
@@ -1 +0,0 @@
-# Soft dependencies extracted from modules themselves.
diff --git a/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.symbols b/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.symbols
deleted file mode 100644
index 618c345..0000000
--- a/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.symbols
+++ /dev/null
@@ -1 +0,0 @@
-# Aliases for symbols, used by symbol_request().
diff --git a/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.symbols.bin b/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.symbols.bin
deleted file mode 100644
index 7075435..0000000
--- a/testsuite/rootfs-pristine/test-init-load-resources-empty-builtin-aliases-bin/lib/modules/5.6.0/modules.symbols.bin
+++ /dev/null
Binary files differ
diff --git a/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.alias b/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.alias
deleted file mode 100644
index ba76e18..0000000
--- a/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.alias
+++ /dev/null
@@ -1 +0,0 @@
-# Aliases extracted from modules themselves.
diff --git a/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.alias.bin b/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.alias.bin
deleted file mode 100644
index 7075435..0000000
--- a/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.alias.bin
+++ /dev/null
Binary files differ
diff --git a/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.builtin b/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.builtin
deleted file mode 100644
index 1cbec61..0000000
--- a/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.builtin
+++ /dev/null
@@ -1 +0,0 @@
-kernel/fake_builtin.ko
diff --git a/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.builtin.bin b/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.builtin.bin
deleted file mode 100644
index 0423f03..0000000
--- a/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.builtin.bin
+++ /dev/null
Binary files differ
diff --git a/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.dep b/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.dep
deleted file mode 100644
index e69de29..0000000
--- a/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.dep
+++ /dev/null
diff --git a/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.dep.bin b/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.dep.bin
deleted file mode 100644
index 7075435..0000000
--- a/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.dep.bin
+++ /dev/null
Binary files differ
diff --git a/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.devname b/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.devname
deleted file mode 100644
index 58f6d6d..0000000
--- a/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.devname
+++ /dev/null
@@ -1 +0,0 @@
-# Device nodes to trigger on-demand module loading.
diff --git a/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.softdep b/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.softdep
deleted file mode 100644
index 5554ccc..0000000
--- a/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.softdep
+++ /dev/null
@@ -1 +0,0 @@
-# Soft dependencies extracted from modules themselves.
diff --git a/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.symbols b/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.symbols
deleted file mode 100644
index 618c345..0000000
--- a/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.symbols
+++ /dev/null
@@ -1 +0,0 @@
-# Aliases for symbols, used by symbol_request().
diff --git a/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.symbols.bin b/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.symbols.bin
deleted file mode 100644
index 7075435..0000000
--- a/testsuite/rootfs-pristine/test-init-load-resources/lib/modules/5.6.0/modules.symbols.bin
+++ /dev/null
Binary files differ
diff --git a/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline6/correct.txt b/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline6/correct.txt
deleted file mode 100644
index 7a087ef..0000000
--- a/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline6/correct.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-options psmouse foo=2
-options psmouse bar=1
-options psmouse zinga=test
-
-# End of configuration files. Dumping indexes now:
-
diff --git a/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline6/proc/cmdline b/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline6/proc/cmdline
deleted file mode 100644
index 14bbd2e..0000000
--- a/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline6/proc/cmdline
+++ /dev/null
@@ -1 +0,0 @@
-psmouse.foo=2 ivrs_acpihid[14:00.5]=AMD0020:00 psmouse.bar=1 psmouse.zinga=test
diff --git a/testsuite/test-init.c b/testsuite/test-init.c
index edbfc23..9651280 100644
--- a/testsuite/test-init.c
+++ b/testsuite/test-init.c
@@ -29,44 +29,6 @@
#include "testsuite.h"
-static noreturn int test_load_resources(const struct test *t)
-{
- struct kmod_ctx *ctx;
- const char *null_config = NULL;
- int err;
-
- ctx = kmod_new(NULL, &null_config);
- if (ctx == NULL)
- exit(EXIT_FAILURE);
-
- kmod_set_log_priority(ctx, 7);
-
- err = kmod_load_resources(ctx);
- if (err != 0) {
- ERR("could not load libkmod resources: %s\n", strerror(-err));
- exit(EXIT_FAILURE);
- }
-
- kmod_unref(ctx);
-
- exit(EXIT_SUCCESS);
-}
-DEFINE_TEST(test_load_resources,
- .description = "test if kmod_load_resources works (recent modprobe on kernel without modules.builtin.modinfo)",
- .config = {
- [TC_ROOTFS] = TESTSUITE_ROOTFS "test-init-load-resources/",
- [TC_UNAME_R] = "5.6.0",
- },
- .need_spawn = true);
-
-DEFINE_TEST(test_load_resources,
- .description = "test if kmod_load_resources works with empty modules.builtin.aliases.bin (recent depmod on kernel without modules.builtin.modinfo)",
- .config = {
- [TC_ROOTFS] = TESTSUITE_ROOTFS "test-init-load-resources-empty-builtin-aliases-bin/",
- [TC_UNAME_R] = "5.6.0",
- },
- .need_spawn = true);
-
static noreturn int test_initlib(const struct test *t)
{
struct kmod_ctx *ctx;
diff --git a/testsuite/test-modprobe.c b/testsuite/test-modprobe.c
index f908d56..1cace82 100644
--- a/testsuite/test-modprobe.c
+++ b/testsuite/test-modprobe.c
@@ -328,31 +328,6 @@
);
-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,
- .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-kcmdline6",
- },
- .output = {
- .out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline6/correct.txt",
- },
- .modules_loaded = "",
- );
-
-
static noreturn int modprobe_force(const struct test *t)
{
const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe";
diff --git a/testsuite/test-util.c b/testsuite/test-util.c
index 621446b..5e25e58 100644
--- a/testsuite/test-util.c
+++ b/testsuite/test-util.c
@@ -157,9 +157,6 @@
#ifdef ENABLE_XZ
{ "/bla.ko.xz", true },
#endif
-#ifdef ENABLE_ZSTD
- { "/bla.ko.zst", true },
-#endif
{ "/bla.ko.x", false },
{ "/bla.ko.", false },
{ "/bla.koz", false },
diff --git a/testsuite/testsuite.h b/testsuite/testsuite.h
index f190249..7ed96bf 100644
--- a/testsuite/testsuite.h
+++ b/testsuite/testsuite.h
@@ -139,7 +139,7 @@
/* Test definitions */
#define DEFINE_TEST(_name, ...) \
- static const struct test UNIQ(s##_name) \
+ static const struct test s##_name##UNIQ \
__attribute__((used, section("kmod_tests"), aligned(8))) = { \
.name = #_name, \
.func = _name, \
diff --git a/tools/depmod.c b/tools/depmod.c
index 3f31cdf..391afe9 100644
--- a/tools/depmod.c
+++ b/tools/depmod.c
@@ -2402,71 +2402,6 @@
return 0;
}
-static int output_builtin_alias_bin(struct depmod *depmod, FILE *out)
-{
- int ret = 0, count = 0;
- struct index_node *idx;
- struct kmod_list *l, *builtin = NULL;
-
- if (out == stdout)
- return 0;
-
- idx = index_create();
- if (idx == NULL)
- return -ENOMEM;
-
- ret = kmod_module_get_builtin(depmod->ctx, &builtin);
- if (ret < 0) {
- if (ret == -ENOENT)
- ret = 0;
- goto out;
- }
-
- kmod_list_foreach(l, builtin) {
- struct kmod_list *ll, *info_list = NULL;
- struct kmod_module *mod = l->data;
- const char *modname = kmod_module_get_name(mod);
-
- ret = kmod_module_get_info(mod, &info_list);
- if (ret < 0)
- goto out;
-
- kmod_list_foreach(ll, info_list) {
- char alias[PATH_MAX];
- const char *key = kmod_module_info_get_key(ll);
- const char *value = kmod_module_info_get_value(ll);
-
- if (!streq(key, "alias"))
- continue;
-
- alias[0] = '\0';
- if (alias_normalize(value, alias, NULL) < 0) {
- WRN("Unmatched bracket in %s\n", value);
- continue;
- }
-
- index_insert(idx, alias, modname, 0);
- }
-
- kmod_module_info_free_list(info_list);
-
- index_insert(idx, modname, modname, 0);
- count++;
- }
-
-out:
- /* do not bother writing the index if we are going to discard it */
- if (!ret)
- index_write(idx, out);
-
- if (builtin)
- kmod_module_unref_list(builtin);
-
- index_destroy(idx);
-
- return ret;
-}
-
static int depmod_output(struct depmod *depmod, FILE *out)
{
static const struct depfile {
@@ -2481,7 +2416,6 @@
{ "modules.symbols", output_symbols },
{ "modules.symbols.bin", output_symbols_bin },
{ "modules.builtin.bin", output_builtin_bin },
- { "modules.builtin.alias.bin", output_builtin_alias_bin },
{ "modules.devname", output_devname },
{ }
};
diff --git a/tools/modinfo.c b/tools/modinfo.c
index 0231bb0..86ac04b 100644
--- a/tools/modinfo.c
+++ b/tools/modinfo.c
@@ -172,33 +172,18 @@
{
struct kmod_list *l, *list = NULL;
struct param *params = NULL;
- int err, is_builtin;
- const char *filename = kmod_module_get_path(mod);
-
- is_builtin = (filename == NULL);
-
- if (is_builtin) {
- printf("%-16s%s%c", "name:", kmod_module_get_name(mod), separator);
- filename = "(builtin)";
- }
+ int err;
if (field != NULL && streq(field, "filename")) {
- printf("%s%c", filename, separator);
+ printf("%s%c", kmod_module_get_path(mod), separator);
return 0;
} else if (field == NULL) {
printf("%-16s%s%c", "filename:",
- filename, separator);
+ kmod_module_get_path(mod), separator);
}
err = kmod_module_get_info(mod, &list);
if (err < 0) {
- if (is_builtin && err == -ENOENT) {
- /*
- * This is an old kernel that does not have a file
- * with information about built-in modules.
- */
- return 0;
- }
ERR("could not get modinfo from '%s': %s\n",
kmod_module_get_name(mod), strerror(-err));
return err;
@@ -291,7 +276,7 @@
static int modinfo_alias_do(struct kmod_ctx *ctx, const char *alias)
{
- struct kmod_list *l, *list = NULL;
+ struct kmod_list *l, *filtered, *list = NULL;
int err = kmod_module_new_from_lookup(ctx, alias, &list);
if (err < 0) {
ERR("Module alias %s not found.\n", alias);
@@ -303,14 +288,26 @@
return -ENOENT;
}
- kmod_list_foreach(l, list) {
+ err = kmod_module_apply_filter(ctx, KMOD_FILTER_BUILTIN, list, &filtered);
+ kmod_module_unref_list(list);
+ if (err < 0) {
+ ERR("Failed to filter list: %m\n");
+ return err;
+ }
+
+ if (filtered == NULL) {
+ ERR("Module %s not found.\n", alias);
+ return -ENOENT;
+ }
+
+ kmod_list_foreach(l, filtered) {
struct kmod_module *mod = kmod_module_get_module(l);
int r = modinfo_do(mod);
kmod_module_unref(mod);
if (r < 0)
err = r;
}
- kmod_module_unref_list(list);
+ kmod_module_unref_list(filtered);
return err;
}
diff --git a/tools/modprobe.c b/tools/modprobe.c
index 9387537..a9e2331 100644
--- a/tools/modprobe.c
+++ b/tools/modprobe.c
@@ -353,9 +353,7 @@
return err;
}
-#define RMMOD_FLAG_DO_DEPENDENCIES 0x1
-#define RMMOD_FLAG_IGNORE_BUILTIN 0x2
-static int rmmod_do_module(struct kmod_module *mod, int flags);
+static int rmmod_do_module(struct kmod_module *mod, bool do_dependencies);
static int rmmod_do_deps_list(struct kmod_list *list, bool stop_on_errors)
{
@@ -363,7 +361,7 @@
kmod_list_foreach_reverse(l, list) {
struct kmod_module *m = kmod_module_get_module(l);
- int r = rmmod_do_module(m, RMMOD_FLAG_IGNORE_BUILTIN);
+ int r = rmmod_do_module(m, false);
kmod_module_unref(m);
if (r < 0 && stop_on_errors)
@@ -373,7 +371,7 @@
return 0;
}
-static int rmmod_do_module(struct kmod_module *mod, int flags)
+static int rmmod_do_module(struct kmod_module *mod, bool do_dependencies)
{
const char *modname = kmod_module_get_name(mod);
struct kmod_list *pre = NULL, *post = NULL;
@@ -403,19 +401,15 @@
}
goto error;
} else if (state == KMOD_MODULE_BUILTIN) {
- if (flags & RMMOD_FLAG_IGNORE_BUILTIN) {
- err = 0;
- } else {
- LOG("Module %s is builtin.\n", modname);
- err = -ENOENT;
- }
+ LOG("Module %s is builtin.\n", modname);
+ err = -ENOENT;
goto error;
}
}
rmmod_do_deps_list(post, false);
- if ((flags & RMMOD_FLAG_DO_DEPENDENCIES) && remove_dependencies) {
+ if (do_dependencies && remove_dependencies) {
struct kmod_list *deps = kmod_module_get_dependencies(mod);
err = rmmod_do_deps_list(deps, true);
@@ -468,7 +462,7 @@
kmod_list_foreach(l, list) {
struct kmod_module *mod = kmod_module_get_module(l);
- err = rmmod_do_module(mod, RMMOD_FLAG_DO_DEPENDENCIES);
+ err = rmmod_do_module(mod, true);
kmod_module_unref(mod);
if (err < 0)
break;
diff --git a/tools/remove.c b/tools/remove.c
index 387ef0e..07e2cc0 100644
--- a/tools/remove.c
+++ b/tools/remove.c
@@ -44,7 +44,7 @@
static int check_module_inuse(struct kmod_module *mod) {
struct kmod_list *holders;
- int state, ret;
+ int state;
state = kmod_module_get_initstate(mod);
@@ -74,15 +74,12 @@
return -EBUSY;
}
- ret = kmod_module_get_refcnt(mod);
- if (ret > 0) {
+ if (kmod_module_get_refcnt(mod) != 0) {
ERR("Module %s is in use\n", kmod_module_get_name(mod));
return -EBUSY;
- } else if (ret == -ENOENT) {
- ERR("Module unloading is not supported\n");
}
- return ret;
+ return 0;
}
static int do_remove(int argc, char *argv[])
diff --git a/tools/rmmod.c b/tools/rmmod.c
index 3942e7b..bcdea4c 100644
--- a/tools/rmmod.c
+++ b/tools/rmmod.c
@@ -63,7 +63,7 @@
static int check_module_inuse(struct kmod_module *mod) {
struct kmod_list *holders;
- int state, ret;
+ int state;
state = kmod_module_get_initstate(mod);
@@ -93,15 +93,12 @@
return -EBUSY;
}
- ret = kmod_module_get_refcnt(mod);
- if (ret > 0) {
+ if (kmod_module_get_refcnt(mod) != 0) {
ERR("Module %s is in use\n", kmod_module_get_name(mod));
return -EBUSY;
- } else if (ret == -ENOENT) {
- ERR("Module unloading is not supported\n");
}
- return ret;
+ return 0;
}
static int do_rmmod(int argc, char *argv[])