]> git.ipfire.org Git - thirdparty/kmod.git/log
thirdparty/kmod.git
11 months agolibkmod: smoke test all the API
Emil Velikov [Fri, 6 Sep 2024 21:40:03 +0000 (22:40 +0100)] 
libkmod: smoke test all the API

Aka make sure the library does not crash if we give it a NULL as input
argument.

All entry-points but kmod_config_iter_free_iter look to be safe. Update
the final instance.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/111
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agoRemove -Wno-unused-result
Emil Velikov [Sat, 7 Sep 2024 00:15:04 +0000 (01:15 +0100)] 
Remove -Wno-unused-result

With the code base now fixed, this warning doesn't need to be suppressed
anymore.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agotestsuite: Check return value of underscores()
Lucas De Marchi [Sat, 7 Sep 2024 06:19:24 +0000 (01:19 -0500)] 
testsuite: Check return value of underscores()

Error returned from underscores() shouldn't be ignored.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agoshared: use _nonnull_() decoration
Emil Velikov [Sat, 7 Sep 2024 00:15:04 +0000 (01:15 +0100)] 
shared: use _nonnull_() decoration

Use the recently introduced attribute macro.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/114
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod: introduce and use _nonnull_() decoration
Emil Velikov [Sat, 7 Sep 2024 00:15:04 +0000 (01:15 +0100)] 
libkmod: introduce and use _nonnull_() decoration

Introduce a new attribute macro and use it, placing it on the left hand
side of the function return value. This aligns with the attributes style
used in C23.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/114
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agoshared: use _nonnull_all_ decoration
Emil Velikov [Sat, 7 Sep 2024 00:15:04 +0000 (01:15 +0100)] 
shared: use _nonnull_all_ decoration

Use the recently introduced attribute macro.

Note that functions such as memdup() and path_ends_with_kmod_ext() take
the (non-zero) length of their non-null string, thus can be annotated
with this _all_ variant.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/114
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod: introduce and use _nonnull_all_ decoration
Emil Velikov [Sat, 7 Sep 2024 00:15:04 +0000 (01:15 +0100)] 
libkmod: introduce and use _nonnull_all_ decoration

Introduce a new attribute macro and use it, placing it on the left hand
side of the function return value. This aligns with the attributes style
used in C23.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/114
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod: remove open-coded _printf_format_
Emil Velikov [Sat, 7 Sep 2024 00:15:04 +0000 (01:15 +0100)] 
libkmod: remove open-coded _printf_format_

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/114
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agoMove _must_check to the left side
Lucas De Marchi [Sat, 7 Sep 2024 06:02:49 +0000 (01:02 -0500)] 
Move _must_check to the left side

Move the attribute to the left hand side since it's clearer and will
help with better formatting when running clang-format.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agotestsuite: remove unused __noreturn decorations
Emil Velikov [Sat, 7 Sep 2024 00:15:04 +0000 (01:15 +0100)] 
testsuite: remove unused __noreturn decorations

The last user was removed in 2013 with commit d96ca9c ("Use C11's
noreturn")

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/114
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agoDrop empty statements
Lucas De Marchi [Sat, 7 Sep 2024 00:15:04 +0000 (01:15 +0100)] 
Drop empty statements

The double ';;' were clearly a mistake and clang-format only makes it
worse if we try running it. Remove the mistake before mass-converting
the source code.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/114
11 months agotools: add trailing comma for multi-line enums
Emil Velikov [Sat, 7 Sep 2024 00:15:04 +0000 (01:15 +0100)] 
tools: add trailing comma for multi-line enums

... otherwise the upcoming clang-format will try to fold them on single
line, making the end result far from ideal.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/114
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod: add trailing comma for multi-line enums
Emil Velikov [Sat, 7 Sep 2024 00:15:04 +0000 (01:15 +0100)] 
libkmod: add trailing comma for multi-line enums

... otherwise the upcoming clang-format will try to fold them on single
line, making the end result far from ideal.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/114
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agotools: add trailing comma for multi-line arrays
Emil Velikov [Sat, 7 Sep 2024 00:15:04 +0000 (01:15 +0100)] 
tools: add trailing comma for multi-line arrays

... otherwise the upcoming clang-format will try to fold them on single
line, making the end result far from ideal.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/114
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agotestsuite: add trailing comma for multi-line arrays
Emil Velikov [Sat, 7 Sep 2024 00:15:04 +0000 (01:15 +0100)] 
testsuite: add trailing comma for multi-line arrays

... otherwise the upcoming clang-format will try to fold them on single
line, making the end result far from ideal.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/114
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agoshared: add trailing comma for multi-line arrays
Emil Velikov [Sat, 7 Sep 2024 00:15:04 +0000 (01:15 +0100)] 
shared: add trailing comma for multi-line arrays

... otherwise the upcoming clang-format will try to fold them on single
line, making the end result far from ideal.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/114
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod: add trailing comma for multi-line arrays
Emil Velikov [Sat, 7 Sep 2024 00:15:04 +0000 (01:15 +0100)] 
libkmod: add trailing comma for multi-line arrays

... otherwise the upcoming clang-format will try to fold them on single
line, making the end result far from ideal.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/114
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agomeson: make all warnings fatal on ci/developer builds
Emil Velikov [Fri, 6 Sep 2024 21:21:44 +0000 (22:21 +0100)] 
meson: make all warnings fatal on ci/developer builds

Aka "-D werror=true", so we catch as many issues as possible in
automated manner.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/110
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agoci: add multilib (32bit) CI for Arch, Debian, Ubuntu
Emil Velikov [Fri, 6 Sep 2024 19:45:51 +0000 (20:45 +0100)] 
ci: add multilib (32bit) CI for Arch, Debian, Ubuntu

Enable it only for meson, as we plan to phase out autotools soonish.
Also don't bother with the openssl/compression paths for now.

AFAICT there is no multilib package on Alpine. Fedora should have one,
but I couldn't find it from a quick search.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/110
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agoci: remove duplicate libssl-dev entries
Emil Velikov [Fri, 6 Sep 2024 20:44:51 +0000 (21:44 +0100)] 
ci: remove duplicate libssl-dev entries

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/110
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod: check fstatat return value
Tobias Stoeckmann [Wed, 4 Sep 2024 16:26:15 +0000 (18:26 +0200)] 
libkmod: check fstatat return value

If fstatat fails, st is not set, which leads to undefined results of
subsequent S_ISDIR call.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/103
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agoscripts: Make build-scdoc.sh executable
Lucas De Marchi [Fri, 6 Sep 2024 19:47:36 +0000 (14:47 -0500)] 
scripts: Make build-scdoc.sh executable

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agomeson: normalize s/check/test/
Lucas De Marchi [Fri, 6 Sep 2024 19:46:28 +0000 (14:46 -0500)] 
meson: normalize s/check/test/

The testsuite is executed by calling the 'test' target in meson, as
opposed to 'check' with autotools. Let's normalize it aligned to the new
build system.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agoci: build: add docs in ci/developer builds
Emil Velikov [Fri, 6 Sep 2024 16:45:21 +0000 (11:45 -0500)] 
ci: build: add docs in ci/developer builds

To make it a little bit more obvious that those should be updated as
well...

On Alpine it fails (as below), so we've disabled it for now.

When gtkdoc-mkhtml calls xsltproc, the latter throws dozens of errors and
fails to produce the libkmod.devhelp2 file. Which meson tries to move
and fails.

  Error: no ID for constraint linkend: "int"

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agomeson: add test for gtkdoc coverage
Emil Velikov [Wed, 4 Sep 2024 18:25:44 +0000 (19:25 +0100)] 
meson: add test for gtkdoc coverage

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agomeson: add support for building the gtk-doc pages
Emil Velikov [Mon, 2 Sep 2024 22:20:18 +0000 (23:20 +0100)] 
meson: add support for building the gtk-doc pages

v2:
 - track the version.xml dependency

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agomeson: Align summary to option names
Lucas De Marchi [Fri, 6 Sep 2024 16:47:10 +0000 (11:47 -0500)] 
meson: Align summary to option names

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
11 months agomeson: Add build-tests to build-dev.ini
Lucas De Marchi [Thu, 5 Sep 2024 05:30:49 +0000 (00:30 -0500)] 
meson: Add build-tests to build-dev.ini

Developers are supposed to run tests to test their code.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/104
11 months agolibkmod/docs: drop pre gtk-doc comments
Emil Velikov [Mon, 2 Sep 2024 22:20:19 +0000 (23:20 +0100)] 
libkmod/docs: drop pre gtk-doc comments

Drop the misc comments, which are effectively superseded by the gtk-doc
decorations.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod/docs: tweak kmod_module_get_sections
Emil Velikov [Mon, 2 Sep 2024 22:20:19 +0000 (23:20 +0100)] 
libkmod/docs: tweak kmod_module_get_sections

Adjust the grammar and split the getter information in new paragraph.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod/docs: move in-argument kmod_module*get* reffs
Emil Velikov [Mon, 2 Sep 2024 22:20:19 +0000 (23:20 +0100)] 
libkmod/docs: move in-argument kmod_module*get* reffs

Move the references out of the argument's description, to the main
description. With that the "how-to-free" is now duplicate, so remove it.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod/docs: remove misleading "After use, free"
Emil Velikov [Mon, 2 Sep 2024 22:20:19 +0000 (23:20 +0100)] 
libkmod/docs: remove misleading "After use, free"

In a couple of instances, the doc suggests freeing the (whole) list
after operating on a (single) list entry.

This is somewhat misleading - drop the instances, since the getters doc
(the ones allocating the lists) are pretty clear about freeing.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod/docs: document kmod_list iterators
Emil Velikov [Mon, 2 Sep 2024 22:20:19 +0000 (23:20 +0100)] 
libkmod/docs: document kmod_list iterators

... and change the argument names to match the other kmod_list APIs.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod/docs: add outstanding struct description(s)
Emil Velikov [Mon, 2 Sep 2024 22:20:19 +0000 (23:20 +0100)] 
libkmod/docs: add outstanding struct description(s)

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod/docs: document logging priority definitions
Emil Velikov [Mon, 2 Sep 2024 22:20:19 +0000 (23:20 +0100)] 
libkmod/docs: document logging priority definitions

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod/docs: add outstanding long_description(s)
Emil Velikov [Mon, 2 Sep 2024 22:20:19 +0000 (23:20 +0100)] 
libkmod/docs: add outstanding long_description(s)

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod/docs: document and reference kmod_symbol_bind
Emil Velikov [Mon, 2 Sep 2024 22:20:19 +0000 (23:20 +0100)] 
libkmod/docs: document and reference kmod_symbol_bind

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod/docs: s/in kernel/in the kernel/
Emil Velikov [Mon, 2 Sep 2024 22:20:19 +0000 (23:20 +0100)] 
libkmod/docs: s/in kernel/in the kernel/

Add the definite article to the remaining instances.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod/docs: s/Linux [Kk]ernel/the kernel/
Emil Velikov [Mon, 2 Sep 2024 22:20:19 +0000 (23:20 +0100)] 
libkmod/docs: s/Linux [Kk]ernel/the kernel/

The project is Linux specific, let's little point in repeating it.
More so, when we predominantly use "kernel" already. Adjust, while also
adding the definite article to adjust the grammar.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod/docs: document and reference kmod_module_initstate
Emil Velikov [Mon, 2 Sep 2024 22:20:19 +0000 (23:20 +0100)] 
libkmod/docs: document and reference kmod_module_initstate

Mostly move the existing documentation from kmod_module_get_initstate()

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod/docs: document and reference kmod_filter
Emil Velikov [Mon, 2 Sep 2024 22:20:19 +0000 (23:20 +0100)] 
libkmod/docs: document and reference kmod_filter

Mostly move the existing documentation from kmod_module_apply_filter().

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod/docs: document and reference kmod_remove
Emil Velikov [Mon, 2 Sep 2024 22:20:19 +0000 (23:20 +0100)] 
libkmod/docs: document and reference kmod_remove

Mostly move the existing documentation from kmod_module_remove_module().

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod/docs: document and reference kmod_probe
Emil Velikov [Mon, 2 Sep 2024 22:20:19 +0000 (23:20 +0100)] 
libkmod/docs: document and reference kmod_probe

Mostly move the existing documentation from
kmod_module_probe_insert_module().

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod/docs: document and reference kmod_insert
Emil Velikov [Mon, 2 Sep 2024 22:20:19 +0000 (23:20 +0100)] 
libkmod/docs: document and reference kmod_insert

Mostly move the existing documentation from kmod_module_insert_module().

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod/docs: document and reference kmod_index
Emil Velikov [Mon, 2 Sep 2024 22:20:19 +0000 (23:20 +0100)] 
libkmod/docs: document and reference kmod_index

Mostly move the existing documentation from kmod_dump_index().

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod/docs: document and reference kmod_resources
Emil Velikov [Mon, 2 Sep 2024 22:20:19 +0000 (23:20 +0100)] 
libkmod/docs: document and reference kmod_resources

Mostly move the existing documentation from kmod_validate_resources().

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod/docs: correct a function doc name
Emil Velikov [Mon, 2 Sep 2024 22:20:19 +0000 (23:20 +0100)] 
libkmod/docs: correct a function doc name

A trivial typo, which has been around since the doc was added in 2011.

s/kmod_module_section_get_module_name/kmod_module_section_get_name/

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod/docs: add missing second asterisk
Emil Velikov [Mon, 2 Sep 2024 22:20:19 +0000 (23:20 +0100)] 
libkmod/docs: add missing second asterisk

... for kmod_module_get_weakdeps. Otherwise gtk-doc doesn't pick up the
documentation.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod/docs: add a trailing colon
Emil Velikov [Mon, 2 Sep 2024 22:20:19 +0000 (23:20 +0100)] 
libkmod/docs: add a trailing colon

Namely the doc for kmod_module_apply_filter is missing the trailing
colon. It seems that gtk-doc is smart enough to not needed, but we might
as well stay consistent.

This tripped me as I was grepping for "\* kmod_foo.*:$", while checking
the header against the gtk-doc sections file.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod/docs: move libkmod-loaded section to the header
Emil Velikov [Mon, 2 Sep 2024 22:20:18 +0000 (23:20 +0100)] 
libkmod/docs: move libkmod-loaded section to the header

In part to ease my life as I'm going through (shortly) and updating the
log. In part so that developers how don't install the gtk-doc html
pages, still have the information at hand.

While here, sort the API akin to the HTML documentation.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod/docs: move libkmod(-core) section to the header
Emil Velikov [Mon, 2 Sep 2024 22:20:18 +0000 (23:20 +0100)] 
libkmod/docs: move libkmod(-core) section to the header

In part to ease my life as I'm going through (shortly) and updating the
log. In part so that developers how don't install the gtk-doc html
pages, still have the information at hand.

While here, sort the API akin to the HTML documentation.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod/docs: move libkmod-module section to the header
Emil Velikov [Mon, 2 Sep 2024 22:20:18 +0000 (23:20 +0100)] 
libkmod/docs: move libkmod-module section to the header

In part to ease my life as I'm going through (shortly) and updating the
log. In part so that developers how don't install the gtk-doc html
pages, still have the information at hand.

While here, sort the API akin to the HTML documentation.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod/docs: move libkmod-list section to the header
Emil Velikov [Mon, 2 Sep 2024 22:20:18 +0000 (23:20 +0100)] 
libkmod/docs: move libkmod-list section to the header

In part to ease my life as I'm going through (shortly) and updating the
log. In part so that developers how don't install the gtk-doc html
pages, still have the information at hand.

While here, sort the API akin to the HTML documentation.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod/docs: move libkmod-config section to the header
Emil Velikov [Mon, 2 Sep 2024 22:20:18 +0000 (23:20 +0100)] 
libkmod/docs: move libkmod-config section to the header

In part to ease my life as I'm going through (shortly) and updating the
log. In part so that developers how don't install the gtk-doc html
pages, still have the information at hand.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod/docs: move all _free_list around
Emil Velikov [Mon, 2 Sep 2024 22:20:18 +0000 (23:20 +0100)] 
libkmod/docs: move all _free_list around

There are a few _free_list functions, not at the end of the respective
sub-sections. Move them to stay consistent with the rest.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod/docs: ignore libkmod-internal-file.h
Emil Velikov [Mon, 2 Sep 2024 22:20:18 +0000 (23:20 +0100)] 
libkmod/docs: ignore libkmod-internal-file.h

Recently we introduced another internal header, yet forgot to add it to
the ignore headers list.

Fixes: 929ca4c ("libkmod: Move xz-related functions to separate file")
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod/docs: remove non-applicable __must_check
Emil Velikov [Mon, 2 Sep 2024 22:20:18 +0000 (23:20 +0100)] 
libkmod/docs: remove non-applicable __must_check

Drop the __must_check from ignore-decorations, since it's nowhere to be
found. The correct name is _must_check_, although amongst others the
decoration is only for the internal API.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod/docs: remove deprecated template options
Emil Velikov [Mon, 2 Sep 2024 22:20:18 +0000 (23:20 +0100)] 
libkmod/docs: remove deprecated template options

The --tmpl-dir and MKTMPL_OPTIONS have been deprecated a while ago,
remove them.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/94
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agoshared: use size_t for strbuf
Tobias Stoeckmann [Wed, 4 Sep 2024 16:17:50 +0000 (18:17 +0200)] 
shared: use size_t for strbuf

The unsigned datatype could overflow on 64 bit systems with sufficiently
large index files. Switch to size_t just to be safe.

Since the API of strbuf is not exported, this has no side-effect for
libkmod users.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/101
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agotestsuite/path: wrap 64 variants for _GLIBC_
Emil Velikov [Tue, 3 Sep 2024 21:31:04 +0000 (22:31 +0100)] 
testsuite/path: wrap 64 variants for _GLIBC_

Since musl v1.2.4 and Alpine 3.18, circa May 2023, the LFS64 variants
are no longer exported by libc.so.

In addition musl headers provide relevant "#define foo64 foo" macros,
when _LARGEFILE64_SOURCE is defined and symbol resolution is deferred to
the runtime linker. See musl commit 246f1c811448 ("remove LFS64 symbol
aliases; replace with dynamic linker remapping") more details.

Earlier versions of musl had the symbols exposed by libc, although the
^^ macros were also available when _GNU_SOURCE is set, as our build
does.

Most importantly, we do not explicitly use the 64 variants and musl
doesn't implicitly pull them either. So in practise building with musl,
the binaries do not have any 64 references, thus there is no need to
wrap them.

AFAICT there is no obvious way of detecting musl, apart from the lack of
of __GLIBC__, so pull features.h (which defines it) and check on that.

There is a small chance the __GLIBC__ check will miss-fire on other
implementations like bionic, dietlibc or ulibc(-ng). We don't run the
tests on those platforms (although we could) so it should be fine.

With that we can install tar (for make distcheck) and enable the tests
in CI \o/

Closes: https://github.com/kmod-project/kmod/issues/65
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/97
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod: check for NULL in kmod_get_dirname
Tobias Stoeckmann [Wed, 4 Sep 2024 16:21:17 +0000 (18:21 +0200)] 
libkmod: check for NULL in kmod_get_dirname

The other KMOD_EXPORT'ed functions protect against ctx being NULL.
Add this to kmod_get_dirname purely for consistency reasons.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/102
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod: Improve signature parser on 32 bit archs
Tobias Stoeckmann [Tue, 3 Sep 2024 17:49:04 +0000 (19:49 +0200)] 
libkmod: Improve signature parser on 32 bit archs

During signature parser validation it is not enough to cast the end
result to 64 bit, because on 32 bit systems size_t is an unsigned 32 bit
integer, which implies that this will be the data type used to evaluate
the expression BEFORE casting it due to C standard.

Since the unsigned 32 bit calculation can overflow, cast the size_t
to int64_t, which makes the whole calculation safe.

This has no negative impact on 64 bit systems because the size_t
value is read as an unsigned 32 bit value from module.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/95
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agoci: add meson build permutation
Emil Velikov [Mon, 2 Sep 2024 17:58:35 +0000 (18:58 +0100)] 
ci: add meson build permutation

Note that we cannot use conditionals within the run actions, because
coreutils (for [ and test) are not installed on Debian/Ubuntu. Even
after doing so, the script consistently fails.

For meson dist to work, we need a full git repo, git and safe
directories setup, otherwise it fails as below. Meson issue was
reported ~2 years ago and we're about to get a fix soon (tm).

  Dist currently only works with Git or Mercurial repos

v2:
 - split git/checkout to separate patch
 - use build-dev.ini instead of meson.sh
v3:
 - use matrix for setting 'test' variable

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agomeson: build-dev.ini file
Emil Velikov [Mon, 2 Sep 2024 17:58:35 +0000 (18:58 +0100)] 
meson: build-dev.ini file

Functionally identical to the autogen.sh c options. This allows devs
(and upcoming CI) to make use of a pre-defined set.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agoci: add KDIR to the environment
Emil Velikov [Mon, 2 Sep 2024 17:58:35 +0000 (18:58 +0100)] 
ci: add KDIR to the environment

The environment variable is used in multiple places, so just set it
once.

While in there, check that only a single kernel is installed. It's
better to error out with a clear message.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agoci: install git and checkout using it
Emil Velikov [Mon, 2 Sep 2024 17:58:35 +0000 (18:58 +0100)] 
ci: install git and checkout using it

Atm the checkout action pulls the whole repo as tarball, since git is
missing. Since we install packages via local actions, we need to first
do an initial sparse checkout, install the packages (git including) and
do a proper second checkout.

At which point, the second checkout action claims to set safe.directory
(it's the default) although in practise we need to do it again. Perhaps
it's getting tripped by our initial sparse checkout?

Either way, explicitly set the option so that git just works.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agoci: remove no longer set matrix.configure
Emil Velikov [Mon, 2 Sep 2024 17:58:35 +0000 (18:58 +0100)] 
ci: remove no longer set matrix.configure

... and it doesn't seem like we'll need it in the future.

Fixes: fdcb656 ("testsuite: remove cached modules and --disable-test-modules")
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agomeson: allow building the manpages
Emil Velikov [Mon, 2 Sep 2024 17:58:35 +0000 (18:58 +0100)] 
meson: allow building the manpages

Not as brief as the pipeline and pattern matching that (auto)make can
do, although it's fully functional ;-)

v2:
 - move man/meson.build
 - move script under scripts/

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agomeson: add support for the testsuite
Emil Velikov [Mon, 2 Sep 2024 17:58:35 +0000 (18:58 +0100)] 
meson: add support for the testsuite

Currently the stale tracking of modules/rootfs is non-existent and I
cannot quite find a way to fix that.

In addition, there is a long standing meson bug where the tests and by
extension their dependencies are always build even when annotated as
`build_by_default : false`. To workaround that, a new option is
introduced `build-tests`, defaulting to false.

Apart from that, all tests run and pass \o/

v2:
 - split from top-level meson.build to subdir one
 - add to EXTRA_DIST
 - scripts are in scripts/
 - add option to enable building tests
 - error out if building without tools

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agomeson: allow disabling the bash completion
Emil Velikov [Mon, 2 Sep 2024 17:58:35 +0000 (18:58 +0100)] 
meson: allow disabling the bash completion

For the cases where you don't want (or cannot) install it. For example,
I've seen similar requests from the Nix people.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agomeson: enable PIE by default
Emil Velikov [Mon, 2 Sep 2024 17:58:35 +0000 (18:58 +0100)] 
meson: enable PIE by default

The autotools build has PIC enabled by default, as do we. Take this a
step further by also enabling PIE.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agomeson: add support for the tools
Emil Velikov [Mon, 2 Sep 2024 17:58:35 +0000 (18:58 +0100)] 
meson: add support for the tools

Nothing too spectacular, apart from a few meson quirks:
 - one can use both_libraries() alas, "install: true" will also install
   the static library, which we do not want
 - need to workaround kmod.pc empty variables, introduced in 1.4.0
 - wrapper script is needed for the symlink creation - see wrapper
   script for details
 - resulting binary exports optarg/optind/stderr/stdout and more

v2:
 - add kmod bash-completion hunk

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agomeson: introduce meson, covering libkmod.so
Emil Velikov [Mon, 2 Sep 2024 17:58:35 +0000 (18:58 +0100)] 
meson: introduce meson, covering libkmod.so

The meson build system has been getting popularity, but for us that
means coverage and sanitisers OOTB et al.

The current patch, handles only libkmod.so and libkmod.pc. The rest will
follow-up.

Notable changes comparing against the autoconf:
 - more consistent dirnames
 - omit printing bash completion dir and compiler flags from summary
 - debug toggle is renamed to debug-messages
 - a few [C,LD]FLAGS were omitted - they're provided by meson itself
 - libkmod.pc has the more complete Requires.private over Libs.private
 - use the symver for libkmod.so, omit the version-info magic

Note: The minimal meson version is 0.60.0 akin to systemd and mesa.

v2:
 - use gnu11, list both LGPL and GPL licenses
 - add meson files to EXTRA_DIST
 - add temporary stdndupa workaround
 - move kmod bash-completion to later patch

v3:
 - switch to meson 0.60.0
 - remove stdndupa workaround

Loosely based on the work by: Dave Reisner <dreisner@archlinux.org>

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agotestsuite: split out setup-modules.sh
Emil Velikov [Mon, 2 Sep 2024 17:58:35 +0000 (18:58 +0100)] 
testsuite: split out setup-modules.sh

So that we can reuse it from the upcoming meson build.

v2:
 - shellcheck fixes, add TODO, move to scripts/

v3:
 - set MAKEFLAGS="-j$(nproc)" if empty

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months ago.editorconfig: add sh(ell) section
Emil Velikov [Mon, 2 Sep 2024 17:58:35 +0000 (18:58 +0100)] 
.editorconfig: add sh(ell) section

The existing in-tree (two) shell scripts are of fairly mixed style.
With indent_size being 0, 4, 8 and indent_style both space and tab.

The more common instance seems to be 4 spaces, so add that to the
config. Updating existing scripts is deferred for another time.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agotestsuite: move setup-rootfs.sh to scripts/
Emil Velikov [Mon, 2 Sep 2024 17:58:35 +0000 (18:58 +0100)] 
testsuite: move setup-rootfs.sh to scripts/

There will be a few more scripts incoming, so let's give them a
dedicated location.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agotestsuite: tweak sed/find dance in setup-rootfs.sh
Emil Velikov [Mon, 2 Sep 2024 17:58:35 +0000 (18:58 +0100)] 
testsuite: tweak sed/find dance in setup-rootfs.sh

Instead of doing the exact same search twice and using sub-shells, find
once and -exec the patterns.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agotestsuite: sprinkle more quotation marks in setup-rootfs.sh
Emil Velikov [Mon, 2 Sep 2024 17:58:35 +0000 (18:58 +0100)] 
testsuite: sprinkle more quotation marks in setup-rootfs.sh

... as highlighted by shellcheck.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agotestsuite: correct the default KDIR
Emil Velikov [Mon, 2 Sep 2024 17:58:35 +0000 (18:58 +0100)] 
testsuite: correct the default KDIR

Honor the user-provided module directory. At the moment things work,
because distros have compatibility /lib -> /usr/lib symlink.

While in there, avoid the use of deprecated backtick (shell) notation.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agotestsuite: split-out Kbuild from Makefile
Emil Velikov [Mon, 2 Sep 2024 17:58:35 +0000 (18:58 +0100)] 
testsuite: split-out Kbuild from Makefile

The former is used by the kernel build system, while the latter is our
convenience wrapper. Split the two to indicate the distinction and make
things easier to parse.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agotestsuite: use standard make (modules|clean) targets
Emil Velikov [Mon, 2 Sep 2024 17:58:35 +0000 (18:58 +0100)] 
testsuite: use standard make (modules|clean) targets

Drop the manual (and partial) module cleanup in favour of the clean
target. Similarly - explicitly use the modules target for the build.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agotestsuite: temporary drop cross compilation test, remove binaries
Emil Velikov [Mon, 2 Sep 2024 17:58:35 +0000 (18:58 +0100)] 
testsuite: temporary drop cross compilation test, remove binaries

The idea behind the test is that modinfo should work with foreign
modules - be that CPU architecture, endianess, bit width or otherwise.

On the other hand, having binary modules baked into the repo isn't great
since they can may be outdated wrt their in-tree source code, may
trigger warnings by various tools (the Debian linter flags them as
"source-not-available") and in general it's better if they're actually
generated via the in-tree Makefile.arch file.

Remove the binaries and temporarily drop the tests. We'll add proper
cross-compilation and re-enable them at a later stage.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agoshared: use memdup over stdndupa
Emil Velikov [Thu, 22 Aug 2024 16:04:21 +0000 (17:04 +0100)] 
shared: use memdup over stdndupa

The stdndupa has a couple of gotchas:
 - allocates memory on stack via alloca(3)... where we pass it a
   user-provided string in at least one instance
 - it's a GNU extension missing on musl and bionic

The mkdir_p() function is not a hot path, so using heap allocation is
perfectly fine. Swap the stdndupa for our local helper memdup.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/92
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agotestsuite: use bash strict mode for setup-rootfs.sh
Emil Velikov [Thu, 22 Aug 2024 16:04:21 +0000 (17:04 +0100)] 
testsuite: use bash strict mode for setup-rootfs.sh

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agobuild: swap ABS_TOP_BUILDDIR for TOOLS_DIR
Emil Velikov [Thu, 22 Aug 2024 16:04:21 +0000 (17:04 +0100)] 
build: swap ABS_TOP_BUILDDIR for TOOLS_DIR

All the remaining instances are used to track the tools directory (aka
the local symlinks to kmod). Rename accordingly and include the tools
sub-directory.

Similar to the OVERRIDE_LIBDIR change earlier, this is build system
specific layout, which shouldn't be in the tests.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agotestsuite/path: match the full rootpath
Emil Velikov [Thu, 22 Aug 2024 16:04:21 +0000 (17:04 +0100)] 
testsuite/path: match the full rootpath

Our expectation is that the (full) rootpath is present, otherwise we
prepend it ourselves. Drop the ABS_TOP_BUILDDIR instance.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agobuild: set OVERRIDE_LIBDIR in the build system
Emil Velikov [Thu, 22 Aug 2024 16:04:21 +0000 (17:04 +0100)] 
build: set OVERRIDE_LIBDIR in the build system

The path is build-system specific, so set it there. Shortly we'll be
adding a meson build, where the value will be different.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agobuild: pass MODULE_DIRECTORY as arg to setup-rootfs.sh
Emil Velikov [Thu, 22 Aug 2024 16:04:21 +0000 (17:04 +0100)] 
build: pass MODULE_DIRECTORY as arg to setup-rootfs.sh

... just like the other 5 args passed to the script.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agobuild: fixup testsuite LDFLAGS
Emil Velikov [Thu, 22 Aug 2024 16:04:21 +0000 (17:04 +0100)] 
build: fixup testsuite LDFLAGS

Add the leading '-' for avoid-version, otherwise the module gets
versioned.

Drop the -export-dynamic, since the modules are built with
-fvisibility=hidden everything but the explicitly exported symbol is not
exported.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agobuild: alphabetically sort tests
Emil Velikov [Thu, 22 Aug 2024 16:04:21 +0000 (17:04 +0100)] 
build: alphabetically sort tests

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agobuild: alphabetically sort sources
Emil Velikov [Thu, 22 Aug 2024 16:04:21 +0000 (17:04 +0100)] 
build: alphabetically sort sources

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agobuild: remove linux/module.h check
Emil Velikov [Thu, 22 Aug 2024 16:04:21 +0000 (17:04 +0100)] 
build: remove linux/module.h check

We include the header for the UAPI MODULE_INIT_* constants, while we
also provide them locally.

At a glance, at least Arch and Alpine build kmod without the uapi
header, so just drop the check and ifndef guards all together.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agobuild: remove finit_module() check
Emil Velikov [Thu, 22 Aug 2024 16:04:21 +0000 (17:04 +0100)] 
build: remove finit_module() check

For over 10 years, init_module(2) has been pretty clear - glibc does not
provide a wrapper for the function. AFAICT musl never provided one
either.

Remove the always failing check.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agomissing.h: remove be32toh wrapper
Emil Velikov [Thu, 22 Aug 2024 16:04:21 +0000 (17:04 +0100)] 
missing.h: remove be32toh wrapper

As the inline comment says, it is applicable for older distributions
like RHEL 5. The extended support for RHEL 5 ended in 2020 (4 years ago)
so we're safe to drop this.

According to the Alpine build logs - the symbol has been present in musl
for years.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agomissing.h: warn on missing __NR_finit_module
Emil Velikov [Thu, 22 Aug 2024 16:04:21 +0000 (17:04 +0100)] 
missing.h: warn on missing __NR_finit_module

Complain (somewhat) loudly if we don't have the syscall number, as the
default cannot work.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agotestsuite: set-but-unused variable KVER
Emil Velikov [Thu, 22 Aug 2024 16:04:20 +0000 (17:04 +0100)] 
testsuite: set-but-unused variable KVER

As far as I can see, nothing ever used the variable - be that within
kmod itself, or the Kbuild itself.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agotestsuite: remove cached modules and --disable-test-modules
Emil Velikov [Thu, 22 Aug 2024 16:04:20 +0000 (17:04 +0100)] 
testsuite: remove cached modules and --disable-test-modules

The option was added for distributions/maintainers lacking the linux
headers, while running the test-suite. It also aimed to resolve
licensing and "source-not-included" issues around the cached modules.

At a glance, it seems like only Debian is using the option these days,
Arch is using "any" linux headers available, while Fedora and Gentoo do
not run `make check` all together.

Debian's linter is complaining about "source-is-missing" and
"source-contains-prebuilt-binary", where the maintainer had to disable
those.

Removing the cache will make ^^ obsolete, while also simplifying the
check target. A nice side effect is making the (compressed) release
tarball 20% smaller.

Distributions are welcome to do something like Arch or not run the
target all together.

We are already running it in CI for Arch, Debian, Fedora and Ubuntu,
where more can be added as needed.

Effectively this reverts commit 23603f1f837caeff45c6960722c2cad690db801d

Lintian overrides:
https://salsa.debian.org/md/kmod/-/commit/8d6fc9e90b12fe88476c6c8f53ae25f9a0d5d634

Arch reference:
https://gitlab.archlinux.org/archlinux/packaging/packages/kmod/-/commit/b2d37d2bcc0ca2ef6187ce115ef8da105019d49f

The autopkgtest's copy of lsmod, ideally should use SPDX license
identifiers like we did in kmod v33.

Autopkgtest lsmod:
https://salsa.debian.org/md/kmod/-/commit/11793a49f6b65af8c442397a845e8b65008d0630

Cc: Marco d'Itri <md@linux.it>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
[ Fixup flag being passed in CI ]
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agobuild: remove --with-rootlibdir toggle
Emil Velikov [Thu, 22 Aug 2024 16:04:20 +0000 (17:04 +0100)] 
build: remove --with-rootlibdir toggle

At a glance this option was introduced with distributions migrating from
/lib to /usr/lib.

Checking with Debian, Arch, Alpine, Fedora and Gentoo - only Debian and
Alpine set it. In the former - it's explicitly set to the default
(libdir), while the latter uses /lib and /usr/lib respectively.

Looking at the implementation itself, we don't adjust the libkmod.pc
which lists libdir, while libkmod.so is installed in rootlibdir.

Considering the negligible user base and somewhat broken state, drop the
option.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod: Treat illegal modinfo file as error
Tobias Stoeckmann [Wed, 21 Aug 2024 20:14:37 +0000 (22:14 +0200)] 
libkmod: Treat illegal modinfo file as error

The file modules.builtin.modinfo is supposed to consist of NUL
terminated strings. If the file contains a string which is not
properly NUL terminated, treat it as error.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/83
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
11 months agolibkmod: Propagate correct errno values
Tobias Stoeckmann [Wed, 21 Aug 2024 20:42:32 +0000 (22:42 +0200)] 
libkmod: Propagate correct errno values

Make sure that errors never end up with errno being 0. These code paths
negate the errno value to get a negative value to propagate the fact
that an error occurred. -0 would be 0 again so errors are not detected.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/83
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>