]> git.ipfire.org Git - thirdparty/kmod.git/log
thirdparty/kmod.git
10 months agotestsuite: mass convert with clang-format
Emil Velikov [Wed, 11 Sep 2024 16:30:32 +0000 (17:30 +0100)] 
testsuite: mass convert with clang-format

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/118
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agoshared: mass convert with clang-format
Emil Velikov [Wed, 11 Sep 2024 16:30:21 +0000 (17:30 +0100)] 
shared: mass convert with clang-format

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/118
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agolibkmod: mass convert with clang-format
Emil Velikov [Wed, 11 Sep 2024 16:30:13 +0000 (17:30 +0100)] 
libkmod: mass convert with clang-format

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/118
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agoci: do monthly dependabot runs
Emil Velikov [Mon, 23 Sep 2024 20:40:53 +0000 (21:40 +0100)] 
ci: do monthly dependabot runs

The CodeQL action is getting 1-2 releases every week with only a handful
of changes in each.

This is getting a bit too much, so let's change to monthly checks.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/150
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agolibkmod: Avoid misaligned memory accesses
Tobias Stoeckmann [Wed, 18 Sep 2024 19:47:48 +0000 (21:47 +0200)] 
libkmod: Avoid misaligned memory accesses

ASAN incorrectly reports this as unaligned access if compiler
optimizes code. Since ASAN support is valued higher than this
kind of optimization, just copy these few bytes into a stack
variable and avoid false positives in tests.

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/147
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agolibkmod: use bufferless zstd decompression
Emil Velikov [Thu, 19 Sep 2024 12:14:58 +0000 (13:14 +0100)] 
libkmod: use bufferless zstd decompression

Unlike the other two decompressions, zstd supports streaming bufferless
mode. Meaning we don't need to read and realloc in a loop.

Some strace numbers:

        $ strace -e read ./before/depmod -o /tmp/throaway | wc -l
        35265
        $ strace -e fstat ./before/depmod -o /tmp/throaway | wc -l
        1110

        $ strace -e read ./after/depmod -o /tmp/throaway | wc -l
        5677
        $ strace -e fstat ./after/depmod -o /tmp/throaway | wc -l
        6642

.. and valgrind total heap usage statistics:
        before:
        1,039,426 allocs, 1,039,426 frees, 3,679,232,922 bytes allocated

        after:
        1,020,643 allocs, 1,020,643 frees, 1,157,922,357 bytes allocated

The actual runtime is within the error margin.

v2:
 - use ZSTD_decompress(), which allocates ZSTD_DCtx internally

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/142
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agotools: Check snprintf return value
Tobias Stoeckmann [Wed, 14 Aug 2024 15:50:34 +0000 (17:50 +0200)] 
tools: Check snprintf return value

If an excessively large root directory is supplied, subsequent
operations might process unexpected parts in file system.

Inform user that supplied directory paths are too long and stop
program execution.

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/72
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agolibkmod: refactor builtin module handling
Tobias Stoeckmann [Tue, 17 Sep 2024 17:59:39 +0000 (19:59 +0200)] 
libkmod: refactor builtin module handling

Remove arbitrary limits due to file sizes (INTPR_MAX check). Reduce
amount of system calls by up to 90 % utilizing stream functions.

Also make sure that no TOCTOU could ever happen by not iterating
through the file twice: First to figure out amount of strings, then
parsing them. If the file changes in between, this can lead to
memory corruption.

Even though more memory allocations might occur due to strbuf usage,
performance generally increased by heavy reduction of system calls.

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/136
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agotestsuite: add builtin test for modinfo
Tobias Stoeckmann [Tue, 17 Sep 2024 17:58:53 +0000 (19:58 +0200)] 
testsuite: add builtin test for modinfo

The modinfo command can show information about builtin modules. Make
sure that it functions correctly.

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/136
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agotestsuite: sort modnames only, if available
Emil Velikov [Thu, 19 Sep 2024 14:50:21 +0000 (15:50 +0100)] 
testsuite: sort modnames only, if available

In some tests we expect zero modules to be loaded. In those cases, skip
the sorting - qsort is annotated as non-null(1,2) so we shouldn't
provide null as expected/loaded modules.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/144
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agoci: add SPDX copyright/license identifiers
Emil Velikov [Sun, 22 Sep 2024 11:52:42 +0000 (12:52 +0100)] 
ci: add SPDX copyright/license identifiers

To make it clear and explicit on the topic. Inspired by me reusing some
of those for usbutils and reuse-tool [1] flagging the lack of proper
attribution.

[1] https://github.com/fsfe/reuse-tool

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/145
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agoshell-completion/*/insmod: add bash/fish/zsh completion
Emil Velikov [Wed, 18 Sep 2024 15:49:08 +0000 (16:49 +0100)] 
shell-completion/*/insmod: add bash/fish/zsh completion

A few inline todos and some odd fish behaviour as mentioned inline.
Otherwise things just work :-)

v2:
 - use e(x)clusive answers for fish, tweak force string

v3:
 - wire the completions to the autotools build

v4:
 - use SPDX style copyright statements

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/138
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agoshell-completion/*/rmmod: add bash/fish/zsh completion
Emil Velikov [Wed, 18 Sep 2024 15:49:08 +0000 (16:49 +0100)] 
shell-completion/*/rmmod: add bash/fish/zsh completion

v2:
 - use e(x)clusive answers for fish, tweak force string

v3:
 - wire the completions to the autotools build

v4:
 - use SPDX style copyright statements

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/138
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agoshell-completion/*/lsmod: add bash/fish/zsh completion
Emil Velikov [Wed, 18 Sep 2024 15:49:08 +0000 (16:49 +0100)] 
shell-completion/*/lsmod: add bash/fish/zsh completion

Note that completions are explicitly aimed to be simple, depending on as
little as possible shell specific helpers.

The goal is that people unfamiliar with these can extend them with zero
ramp-up. Doing things efficiently or "properly" is somewhat secondary.

v2:
 - wire the completions to the autotools build

v3:
 - use SPDX style copyright statements

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/138
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agolibkmod: remove __secure_getenv handling
Emil Velikov [Wed, 18 Sep 2024 16:32:31 +0000 (17:32 +0100)] 
libkmod: remove __secure_getenv handling

The build-time checking for __secure_getenv was dropped earlier, yet I
forgot to remove the actual users :facepalm:

Fixes: 9dc54a3 ("build: stop checking for __secure_getenv")
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/139
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agotestsuite/list: resolve memory leaks
Emil Velikov [Thu, 19 Sep 2024 14:30:26 +0000 (15:30 +0100)] 
testsuite/list: resolve memory leaks

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/143
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agotools/insmod: add --force longopt and document it
Emil Velikov [Wed, 18 Sep 2024 15:49:08 +0000 (16:49 +0100)] 
tools/insmod: add --force longopt and document it

As of the initial import to git, the option was silently ignored.
Shortly afterwards, functionality was reinstated lacking a longopt and
any documentation.

As per insmod(8) for most use-cases you'd want to use modprobe(8).
Although since the option is available and we have an equivalent in
rmmod(8) having it documented and consistent triumphs.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/138
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agotools/insmod: add syslog and verbose options
Emil Velikov [Wed, 18 Sep 2024 15:49:08 +0000 (16:49 +0100)] 
tools/insmod: add syslog and verbose options

Add the extra options for consistency with the rest of kmod.

Document all options in the man page.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/138
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agotools/insmod: remove unused -p -s shortopts
Emil Velikov [Wed, 18 Sep 2024 15:49:08 +0000 (16:49 +0100)] 
tools/insmod: remove unused -p -s shortopts

These have been around since the import to git, doing nothing. There are
no users that I can see, the manual page does not list them and the
shell completions (fish and bash lack any for insmod, zsh has one) don't
suggest it either.

Remove them.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/138
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agotools/rmmod: return EXIT_FAILURE if kmod_module_new_* fails
Emil Velikov [Wed, 18 Sep 2024 15:49:08 +0000 (16:49 +0100)] 
tools/rmmod: return EXIT_FAILURE if kmod_module_new_* fails

In the unlikely case where kmod_module_new_from_{path,name} fails,
rmmod will return success. Change that to EXIT_FAILURE.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/138
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agotools/rmmod: consistently use ERR logging facility
Emil Velikov [Wed, 18 Sep 2024 15:49:08 +0000 (16:49 +0100)] 
tools/rmmod: consistently use ERR logging facility

Currently we'll print "Module foo is in use by:" to syslog, while the
modules themselves will end up in strerr.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/138
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agotools/rmmod: make opt variables non-global
Emil Velikov [Wed, 18 Sep 2024 15:49:08 +0000 (16:49 +0100)] 
tools/rmmod: make opt variables non-global

They're used locally within one function so declare them there.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/138
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agoman/rmmod: reorder, add --help
Emil Velikov [Wed, 18 Sep 2024 15:49:08 +0000 (16:49 +0100)] 
man/rmmod: reorder, add --help

Stay consistent with the output of rmmod --help and update the
respective options.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/138
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agotools/rmmod: tweak --force help message
Emil Velikov [Wed, 18 Sep 2024 15:49:08 +0000 (16:49 +0100)] 
tools/rmmod: tweak --force help message

Drop the kernel configuration details - the CONFIG toggle name is more
useful (since you can see it in /proc/config.*) and generally the part
is better suited for the manual page.

Move DANGEROUS at the front, so it's obvious from the start

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/138
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agotools/rmmod: remove unused -w shortopt
Emil Velikov [Wed, 18 Sep 2024 15:49:08 +0000 (16:49 +0100)] 
tools/rmmod: remove unused -w shortopt

The (long)option and handling was removed some 10 years ago, yet the
shortopt remained... oops

Fixes: a4bd144 ("Remove "rmmod -w" documentation and getopt entry")
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/138
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agotools/lsmod: add basic opts like rmmod
Emil Velikov [Wed, 18 Sep 2024 15:49:08 +0000 (16:49 +0100)] 
tools/lsmod: add basic opts like rmmod

This allows for more consistent experience across tools, allows to see
the version, observe/debug if "Used by" reports -1, etc.

Also don't forget to update the man page :-)

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/138
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agotools: add kmod_version() helper
Emil Velikov [Wed, 18 Sep 2024 15:49:08 +0000 (16:49 +0100)] 
tools: add kmod_version() helper

Add a trivial helper that prints the version + features combo. I will be
adding another instance of those, so I'm aiming to keep the boilerplate
code to a minimum.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/138
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agotestsuite: Fix init_module
Tobias Stoeckmann [Wed, 18 Sep 2024 19:53:23 +0000 (21:53 +0200)] 
testsuite: Fix init_module

Apply same logic as in delete_module.c, i.e. pass a reference to a
pointer instead of the pointer value, otherwise we cannot update
the linked list and added entries are lost.

Spotted with ASAN while running testsuite.

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/141
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agolibkmod: Fix OOB write with illegal index files
Tobias Stoeckmann [Wed, 11 Sep 2024 15:51:53 +0000 (17:51 +0200)] 
libkmod: Fix OOB write with illegal index files

If an index file with INDEX_NODE_CHILDS flag contains illegal first
and last markers for children, it is possible to trigger an out of
boundary write.

Make sure that first value is not larger than last value while reading
index files.

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/126
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agodepmod: annotate fatal_oom() as noreturn
Emil Velikov [Tue, 17 Sep 2024 09:50:45 +0000 (10:50 +0100)] 
depmod: annotate fatal_oom() as noreturn

... in case the compiler cannot deduce it from the exit(3) within.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/135
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agoshared: remove no longer used NOFAIL() macro
Emil Velikov [Tue, 17 Sep 2024 09:49:38 +0000 (10:49 +0100)] 
shared: remove no longer used NOFAIL() macro

Closes: https://github.com/kmod-project/kmod/issues/60
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/135
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agodepmod: Replace NOFAIL macro
Tobias Stoeckmann [Fri, 13 Sep 2024 17:29:56 +0000 (19:29 +0200)] 
depmod: Replace NOFAIL macro

The NOFAIL macro was not implemented. Add a function which
gracefully exits depmod instead of letting it crash.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/130
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agodepmod: Check strdup return value
Tobias Stoeckmann [Tue, 10 Sep 2024 18:06:11 +0000 (20:06 +0200)] 
depmod: Check strdup return value

If strdup fails, return error.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/130
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agodepmod: Handle malloc failure in index_create
Tobias Stoeckmann [Tue, 10 Sep 2024 16:18:48 +0000 (18:18 +0200)] 
depmod: Handle malloc failure in index_create

Callers already check error return value, so actually return one in case
of failure.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/130
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agolibkmod: Improve st_size checks on 32 bit systems
Tobias Stoeckmann [Tue, 3 Sep 2024 18:28:26 +0000 (20:28 +0200)] 
libkmod: Improve st_size checks on 32 bit systems

Since off_t can (and most likely will) be 64 bit on 32 bit systems,
check its actual value before casting it to 32 bit size_t.

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/96
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agolibkmod: rename read_long to read_u32
Tobias Stoeckmann [Wed, 11 Sep 2024 15:07:05 +0000 (17:07 +0200)] 
libkmod: rename read_long to read_u32

Same goes for mm version of the function.

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/123
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agolibkmod: Remove NOFAIL usage
Tobias Stoeckmann [Tue, 10 Sep 2024 16:53:40 +0000 (18:53 +0200)] 
libkmod: Remove NOFAIL usage

Forward errors to callers instead of relying on unimplemented macro.

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/123
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agolibkmod: handle read_char errors
Tobias Stoeckmann [Tue, 10 Sep 2024 16:13:41 +0000 (18:13 +0200)] 
libkmod: handle read_char errors

If read_char fails, stop operations and return an error instead.

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/123
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agoshared: Remove fatal macro
Tobias Stoeckmann [Tue, 10 Sep 2024 16:11:41 +0000 (18:11 +0200)] 
shared: Remove fatal macro

The fatal macro was never implemented. Its only user, libkmod-index,
should propagate error condition through errno as good as possible.

Other logging mechanisms are not available without adjusting API
because context is missing.

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/123
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agolibkmod: treat read_long failures
Tobias Stoeckmann [Tue, 10 Sep 2024 16:04:14 +0000 (18:04 +0200)] 
libkmod: treat read_long failures

If read_long fails, forward error up to caller. Also perform proper
fread return value check.

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/123
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agolibkmod: allow buf_freadchars to report errors
Tobias Stoeckmann [Tue, 10 Sep 2024 16:01:35 +0000 (18:01 +0200)] 
libkmod: allow buf_freadchars to report errors

The return value is currently not needed. In prepration for subsequent
commits, use the return value to report if errors occurred or not.

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/123
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agobuild: stop checking for __secure_getenv
Emil Velikov [Sun, 15 Sep 2024 00:40:37 +0000 (01:40 +0100)] 
build: stop checking for __secure_getenv

Currently we check for both __secure_getenv and secure_getenv. The
former was introduced with glibc 2.2.5 as internal(?) API, while the
has been part of glibc 2.17, circa 2012.

Drop the former check. It may have been required over 10 years ago, but
not any more.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/131
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agobuild: check for __xstat declarations
Emil Velikov [Sun, 15 Sep 2024 00:40:14 +0000 (01:40 +0100)] 
build: check for __xstat declarations

Currently we check the function is resolved at link time. Although what
we really care is if the headers are silently transposing any of our stat
calls to __xstat{,64}. If so, we'd want to wrap the latter functions.

As the now-removed comment says, glibc 2.33 was the first release to no
longer have static inline wrappers that do the transposition. See the
glibc commit 8ed005daf0ab ("Remove stat wrapper functions, move them to
exported symbols") for more details.

So change the checking to check_decl/has_header_symbol and keep them for
distributions with older glibc.

NOTE: to summarise/contrast this wrt the previous open64, etc
 - here: we had inline wrappers and declarations (as below)
 - others: no inline wrappers and optionally declarations

glibc 2.32
extern ... __xstat(); extern inline stat(...) { return __xstat(...); }

glibc 2.33
extern stat(...);

Note we group the 64 variant as well, since the codepath has been
identical (wrt core logic) to the normal __xstat().

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/131
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agomeson: use has_header_symbol for checking declarations
Emil Velikov [Sun, 15 Sep 2024 18:04:19 +0000 (19:04 +0100)] 
meson: use has_header_symbol for checking declarations

Currently we use has_function, which will construct local declaration
and see if the program links successfully. What we're really interested
is if the referenced header has a declaration of the respective symbol.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/131
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agobuild: check properly for __stat64_time64
Emil Velikov [Sun, 15 Sep 2024 10:03:00 +0000 (11:03 +0100)] 
build: check properly for __stat64_time64

Having learned from prior LFS64 experience the glibc developers have
implemented stat in (albeit varying but) neater way:

 - declaration with asm linkage to __stat64_time64
 - or, `#define stat __stat64_time64`
 - or, `#define stat stat64; #define stat64 __stat64_time64`

In all cases __stat64_time64 lacks an explicit declaration, unlike
open64, stat64, fopen64 mentioned earlier.

Since we lack declaration, we have no other option but to check if a
program with reference to __stat64_time64 can link, so we use the
check/has function.

For more details glibc commit aa03f722f3 ("linux: Add {f}stat{at} y2038
support") added internal.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/131
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agotestsuite/path: s/__stat64_t64/void/
Emil Velikov [Sun, 15 Sep 2024 10:03:00 +0000 (11:03 +0100)] 
testsuite/path: s/__stat64_t64/void/

The exact struct varies across the build-options, but in practise is
never __stat64_t64 - this is the internal name used within glibc.

When the fstat declaration with __fstat64_time64 asm linkage is used, we
have "struct stat". Whenever the `#define stat __stat64_time64` kicks
in, both function and struct get redefined/renamed.

Since we don't care about it (apart from the pointer part) just use void.

For more details glibc commit aa03f722f3 ("linux: Add {f}stat{at} y2038
support") added internal.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/131
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agobuild: check for open64, stat64 and fopen64
Emil Velikov [Sun, 15 Sep 2024 09:11:49 +0000 (10:11 +0100)] 
build: check for open64, stat64 and fopen64

... and use behind the respective ifdef HAVE_FOO guards instead of the
HAVE_DECL___GLIBC__ currently.

Since day one, glibc has declarations for the functions, which was
forwarding the normal functions to them, via asm linkage, et al.
Aka `extern int open(....) asm_linkage("open64").

In addition, a lot of libraries have grown to depend on the declarations
being available and functions being statically exposed via libc.so.

Whereas musl pre 1.2.4 (circa 2023) have exposed the symbols
statically, without a declaration for well over a decade. Newer musl,
no longer expose the symbol in their runtime but have retained the
define trick, stating it will be removed in the future.

Looking at the bionic front things are somewhat similar. Newer bionic
(circa 2019) have a declaration and an inline wrapper open64 function
forwarding to open. Throughout 2019, open64 did forward to misc other
internal functions thought.

Older pre 2019 bionic had a declaration alongside plug exposing the
symbol statically in their C runtime.... since 2014. Not sure what they
did prior to 2014, it's a target out of scope for us.

Considering the above, the most robust approach is to do a check/has
function checking.

With that, we no longer need the __GLIBC__ guard for the respective
functions.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/131
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agotestsuite: remove access() sub-test
Emil Velikov [Sat, 14 Sep 2024 14:08:59 +0000 (15:08 +0100)] 
testsuite: remove access() sub-test

Our test does access + stat, where stat is sufficient. In addition, the
kmod codebase never used access (afaict), so we're safe to remove the
access() part.

Alongside it we can drop the LD_PRELOAD wrapper.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/131
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agotestsuite: remove *lstat* wrappers
Emil Velikov [Sat, 14 Sep 2024 13:57:44 +0000 (14:57 +0100)] 
testsuite: remove *lstat* wrappers

The majority of these were initially introduced with commit 123e827
("testsuite preload: Factorize into macros, add more stat and open
variants").

The commit itself was meant to refactor existing wrappers and add new
_xstat (aka stat) variants. The lstat variants were never used in kmod
directly nor indirectly via header macros.

The rest were added to mimic the original, without much testing it
seems.

They are all dead code - remove them.

In theory one could have a macro/helper that calls `lstat` for `stat`
itself, although that isn't a practical solution for a few reasons.

The functionality across the two varies, where if the path provided is
a symlink `stat` follows it, while `lstat` gets the details for the link
itself. To fix this, the wrapper would need second syscall to resolve
the symlink, which will cause notable performance regression wrt using
using the `stat`/`stat64` syscall alone.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/131
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agoci: add codeql code-scanning action
Emil Velikov [Sat, 14 Sep 2024 15:12:33 +0000 (16:12 +0100)] 
ci: add codeql code-scanning action

Effectively a trimmed down copy of main.yml, running only on
ubuntu-22.04 for now.

The action flags a handful of interesting issues and allows us to
prevent more from creeping in.

The action does not need need docs/manpages so we disable those.

v2:
 - script lives in .github/

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/132
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agoscripts/print-kdir: error out on multiple kernels
Emil Velikov [Sat, 14 Sep 2024 15:48:19 +0000 (16:48 +0100)] 
scripts/print-kdir: error out on multiple kernels

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/132
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agoci: flesh out print-kdir.sh script, bash ftw
Emil Velikov [Sat, 14 Sep 2024 15:46:27 +0000 (16:46 +0100)] 
ci: flesh out print-kdir.sh script, bash ftw

We'll be adding another action, where this script is handy. Flesh it out
to scripts and convert to bash.

v2:
 - move script to .github/

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/132
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agoci: don't abort all pipeline if one is failing
Emil Velikov [Sat, 14 Sep 2024 15:55:52 +0000 (16:55 +0100)] 
ci: don't abort all pipeline if one is failing

Our jobs are pretty quick sub 2m for meson builds and sub 1m, when if
going without tests.

Wait for all jobs so we get all the (potential) issues at once.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/132
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agoCONTRIBUTING.md: mention license and SPDX
Emil Velikov [Mon, 16 Sep 2024 22:39:23 +0000 (23:39 +0100)] 
CONTRIBUTING.md: mention license and SPDX

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/134
[ Mention LGPL is preferred, even for tools/ ]
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agoCONTRIBUTING.md: add inline TOC
Emil Velikov [Mon, 16 Sep 2024 10:35:47 +0000 (11:35 +0100)] 
CONTRIBUTING.md: add inline TOC

While the file is small, it does cover a handful of topics. So include a
simple TOC and the start to make browsing a little bit easier.

v2:
 - tag -> trailer

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/134
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agoCONTRIBUTING.md: mention s-o-b tag, includ DCO copy
Emil Velikov [Mon, 16 Sep 2024 10:18:39 +0000 (11:18 +0100)] 
CONTRIBUTING.md: mention s-o-b tag, includ DCO copy

While CODING-STYLE states that using Signed-off-by is an error, a large
number of contributors have been using it. Most, if not all, of those
are people who have contributed to the kernel, and by extension know
about the DCO.

So let's add an in-tree copy of the file, explicitly document what is
meant with the tag (other projects use if for different purposes) and
drop the note from CODING-STYLE.

I have not went full bananas to require it, since based on the numbers
below, majority of commits lack it. We could reconsider that at later
point, if needed.

Numbers, as of commit 11ccabd ("libkmod: document the symbols file")
 - total number of commits - 1640
 - number of commits with at least one s-o-b - 357
   - this can be s-o-b by the author, maintainer and/or both
 - total number of contributors (bots including) - 109
 - number of individuals with at least one s-o-b - 42

v2
 - drop html bits from DCO
 - tag -> trailer

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/134
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agoCONTRIBUTING.md: mention the "Link:" tag
Emil Velikov [Mon, 16 Sep 2024 10:12:11 +0000 (11:12 +0100)] 
CONTRIBUTING.md: mention the "Link:" tag

v2:
 - tag -> trailer

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/134
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agoCONTRIBUTING.md: small grammar/typo/style fixes
Emil Velikov [Mon, 16 Sep 2024 10:05:28 +0000 (11:05 +0100)] 
CONTRIBUTING.md: small grammar/typo/style fixes

v2
 - drop erroneous "a"

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/134
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agoCONTRIBUTING.md: tweaks the section names a bit
Emil Velikov [Mon, 16 Sep 2024 10:04:36 +0000 (11:04 +0100)] 
CONTRIBUTING.md: tweaks the section names a bit

Make them a little less terse and natural.

v2:
 - tag -> trailer

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/134
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agoCONTRIBUTING.md: s/tag/trailer/
Emil Velikov [Mon, 16 Sep 2024 22:27:09 +0000 (23:27 +0100)] 
CONTRIBUTING.md: s/tag/trailer/

There are multiple things commonly referred to as "tags". Use the proper
term for what we mean here - trailer.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/134
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agolibkmod: document the symbols file
Emil Velikov [Sat, 14 Sep 2024 13:48:20 +0000 (14:48 +0100)] 
libkmod: document the symbols file

Add a note about the v5 sections and note we should not change existing
sections.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/128
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agodocs: annotate the v33 API
Emil Velikov [Sat, 14 Sep 2024 13:38:57 +0000 (14:38 +0100)] 
docs: annotate the v33 API

Namely:
 - kmod_config_get_weakdeps
 - kmod_module_get_weakdeps

Closes: https://github.com/kmod-project/kmod/issues/98
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/128
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agodocs: annotate the v30 API
Emil Velikov [Sat, 14 Sep 2024 13:38:23 +0000 (14:38 +0100)] 
docs: annotate the v30 API

Namely:
 - kmod_module_new_from_name_lookup

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/128
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agodocs: annotate the v22 API
Emil Velikov [Sat, 14 Sep 2024 13:37:25 +0000 (14:37 +0100)] 
docs: annotate the v22 API

Namely:
 - kmod_get_dirname

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/128
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agodocs: annotate the v6 API
Emil Velikov [Fri, 13 Sep 2024 11:48:55 +0000 (12:48 +0100)] 
docs: annotate the v6 API

Namely:
 - kmod_module_apply_filter

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/128
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agodocs: annotate the v4 API
Emil Velikov [Sat, 14 Sep 2024 13:18:31 +0000 (14:18 +0100)] 
docs: annotate the v4 API

Namely:
 - kmod_config_get_aliases
 - kmod_config_get_blacklists
 - kmod_config_get_install_commands
 - kmod_config_get_options
 - kmod_config_get_remove_commands
 - kmod_config_get_softdeps

 - kmod_config_iter_free_iter
 - kmod_config_iter_get_key
 - kmod_config_iter_get_value
 - kmod_config_iter_next

 - kmod_dump_index

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/128
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agodocs: annotate the v3 API
Emil Velikov [Sat, 14 Sep 2024 13:16:16 +0000 (14:16 +0100)] 
docs: annotate the v3 API

Namely:
 - kmod_module_get_dependency_symbols
 - kmod_module_dependency_symbol_get_bind
 - kmod_module_dependency_symbol_get_crc
 - kmod_module_dependency_symbol_get_symbol
 - kmod_module_dependency_symbols_free_list

 - kmod_module_get_symbols
 - kmod_module_symbol_get_crc
 - kmod_module_symbol_get_symbol
 - kmod_module_symbols_free_list

 - kmod_module_probe_insert_module
 - kmod_validate_resources

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/128
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agodocs: annotate the v2 API
Emil Velikov [Sat, 14 Sep 2024 13:09:27 +0000 (14:09 +0100)] 
docs: annotate the v2 API

Namely:
 - kmod_list_last

 - kmod_module_get_softdeps

 - kmod_module_get_info
 - kmod_module_info_get_key
 - kmod_module_info_get_value
 - kmod_module_info_free_list

 - kmod_module_get_versions
 - kmod_module_version_get_crc
 - kmod_module_version_get_symbol
 - kmod_module_versions_free_list

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/128
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agodocs: annotate the v1 API
Emil Velikov [Sat, 14 Sep 2024 13:05:32 +0000 (14:05 +0100)] 
docs: annotate the v1 API

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/128
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agolibkmod: remove internal kmod_list iterators
Emil Velikov [Sun, 8 Sep 2024 09:41:16 +0000 (10:41 +0100)] 
libkmod: remove internal kmod_list iterators

These were introduced to workaround since the compiler cannot properly
optimise things, since the symbols have external linkage.

These days this is not so much an issue. For example comparing a gcc 14
build, with -O2 shows 24 bytes growth with this reverted.

Although in practise anyone looking for extreme optimisations - be that
speed or size - should be using LTO and/or PGO.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/117
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agoman: remove slash before @MODULE_DIRECTORY@
Emil Velikov [Fri, 13 Sep 2024 12:02:54 +0000 (13:02 +0100)] 
man: remove slash before @MODULE_DIRECTORY@

... otherwise we get a double-slash in the manual.

Fixes: e2536ab ("man: Provide examples for paths")
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/129
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agolibkmod: fix clang-format ofr -> off typo
Emil Velikov [Wed, 11 Sep 2024 16:27:52 +0000 (17:27 +0100)] 
libkmod: fix clang-format ofr -> off typo

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/118
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agoCONTRIBUTING.md: add initial contributing guideline
Emil Velikov [Mon, 9 Sep 2024 15:14:54 +0000 (16:14 +0100)] 
CONTRIBUTING.md: add initial contributing guideline

Document some of the practises and expectations that we've been using
in the project.

Large chunks of the document are inspired by wlroots - thank you o/

Going further, I think we'd want to document the use of SoB/DCO and
mention about our CI pipelines, so that people try them before opening
PRs/sending patches.

Although I think that can follow-up at another day.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/122
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agoREADME.md: recommend meson, mention autotools EOL
Emil Velikov [Mon, 9 Sep 2024 14:10:38 +0000 (15:10 +0100)] 
README.md: recommend meson, mention autotools EOL

The meson build has the default options already set, so I don't think we
need the verbosity of the configure example.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/122
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agoREADME.md: make it a proper markdown
Emil Velikov [Sat, 7 Sep 2024 18:30:49 +0000 (19:30 +0100)] 
README.md: make it a proper markdown

Resolve the formatting so the file renders correctly.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/122
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agoREADME.md: rework the Information section
Emil Velikov [Sat, 7 Sep 2024 18:50:10 +0000 (19:50 +0100)] 
README.md: rework the Information section

Move the section after the Overview, so that people can first see what
the project is about, before talking about ML, issues, etc.

Fold the git/gitweb sections, since the distinction is no longer needed
adding some mirrors. Document the IRC freenode -> oftc move.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/122
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agoREADME.md: remove outdated Coverity Scan
Emil Velikov [Sat, 7 Sep 2024 18:44:32 +0000 (19:44 +0100)] 
README.md: remove outdated Coverity Scan

It hasn't been run in years, so let's drop it. We might reintroduce it
sooner or later at which point we'll add back the badge.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/122
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agobuild: Fix KDIR again
Lucas De Marchi [Wed, 11 Sep 2024 13:51:23 +0000 (08:51 -0500)] 
build: Fix KDIR again

KDIR is not related to the what we configure in kmod's build. It's only
used in kmod to locate where the distro's kernel source/headers is,
which may be different from what we are configuring the (under
development) kmod with.

Remove the setting from meson/autotools and figure it out inside the
module-playground Makefile what should be used. For advanced use cases,
KDIR= can be passed to override the location.

For our own tests, which includes testing with a different module_directory,
scripts/setup-rootfs.sh will copy the module to the desired location
according to the map defined in the script.

Fixes: 27ff72732666 ("testsuite: correct the default KDIR")
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/125
10 months agokmod: Avoid negative exit codes
Tobias Stoeckmann [Tue, 10 Sep 2024 20:02:24 +0000 (22:02 +0200)] 
kmod: Avoid negative exit codes

Exit codes shall be non-negative to comply with standards.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/124
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agoRemove depmod_module_directory_override from .pc
Lucas De Marchi [Tue, 10 Sep 2024 18:27:06 +0000 (13:27 -0500)] 
Remove depmod_module_directory_override from .pc

Hopefully this is not needed to implement the kernel side.
Let's remove it and bring it back in case it really is.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agoman: Provide examples for paths
Lucas De Marchi [Mon, 9 Sep 2024 06:36:12 +0000 (01:36 -0500)] 
man: Provide examples for paths

Add some examples to help clarifying each part of the paths.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/100
10 months agoman: Reword depmod's paths
Lucas De Marchi [Mon, 9 Sep 2024 06:13:55 +0000 (01:13 -0500)] 
man: Reword depmod's paths

Main goal is to give the reader the complete picture of each component
of the path being used, divided in <BASEDIR>, <MODULEDIR>, version.
Then reword the options accordingly to refer to what they are
overriding.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/100
10 months agotestsuite: Test depmod's -m flag
Lucas De Marchi [Mon, 9 Sep 2024 06:03:01 +0000 (01:03 -0500)] 
testsuite: Test depmod's -m flag

Link: https://github.com/kmod-project/kmod/pull/100
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agodepmod: Rewrite basedir/moduledir/outputdir/ help
Lucas De Marchi [Mon, 9 Sep 2024 06:50:29 +0000 (01:50 -0500)] 
depmod: Rewrite basedir/moduledir/outputdir/ help

Follow the same logic for all of them: short help message about
what the option is and default value inside parenthesis.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/100
10 months agodepmod: Add option to override MODULE_DIRECTORY
Michal Suchanek [Wed, 4 Sep 2024 06:54:06 +0000 (08:54 +0200)] 
depmod: Add option to override MODULE_DIRECTORY

This a compile time option. When building modules for a different system
that uses a different value of this option it is useful to be able to
override it without rebuilding kmod.

Closes: https://github.com/kmod-project/kmod/issues/85
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Link: https://github.com/kmod-project/kmod/pull/100
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agodepmod: Remove deprecated options
Michal Suchanek [Thu, 5 Sep 2024 14:47:15 +0000 (16:47 +0200)] 
depmod: Remove deprecated options

These options are deprecated and undocumented since import of depmod
into git (Dec 2011).

Link: https://github.com/kmod-project/kmod/pull/100
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agomeson: Stop rebuilding modules over and over
Lucas De Marchi [Mon, 9 Sep 2024 13:33:35 +0000 (08:33 -0500)] 
meson: Stop rebuilding modules over and over

Instead of removing the sources every time and rebuilding, just use
rsync to preserve the timestamps and allow Make to do its job of
rebuilding if it changed.

There's a bug in meson that keeps building the testsuite even outside of
`ninja test`, but if the build result is cached, we can greatly minimize
the impact for developers.

Closes: https://github.com/kmod-project/kmod/issues/119
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/121
10 months agomeson: Move symlinks up
Lucas De Marchi [Mon, 9 Sep 2024 07:08:54 +0000 (02:08 -0500)] 
meson: Move symlinks up

Currently it's only possible to test the tools by using the symlink.
However, differently from autotools, the symlink is created inside the
testsuite dir, and only if build-tests=true. Move it to the same
directory that kmod is so it's possible to test without the testsuite.

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/120
10 months agotestsuite: use size_t with strbuf
Emil Velikov [Sat, 7 Sep 2024 00:28:19 +0000 (01:28 +0100)] 
testsuite: use size_t with strbuf

We recently updated the API, but forgot to update the tests.

Fixes: 38943b2 ("shared: use size_t for strbuf")
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/115
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months ago.editorconfig: max_line_length=90 like clang-format
Emil Velikov [Sun, 8 Sep 2024 10:38:12 +0000 (11:38 +0100)] 
.editorconfig: max_line_length=90 like clang-format

Ideally the config (and editors) will have hard and soft limit for the
line length. Until then, update the config so that clang-format does not
excessively reformat.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/118
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agoclang-format: Override settings
Lucas De Marchi [Sun, 8 Sep 2024 10:38:12 +0000 (11:38 +0100)] 
clang-format: Override settings

- Define our own foreach macros
- Add defines for attributes. This also needs the minimum clang-format
  version to be raised so it has the AttributeMacros setting.
- Redefine a few settings related to max number of columns and
  penalties for breaking lines

v2
 - [Emil] update attributes list

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/118
10 months agoclang-format: Import from kernel
Lucas De Marchi [Sun, 8 Sep 2024 10:38:12 +0000 (11:38 +0100)] 
clang-format: Import from kernel

Import .clang-format from Linux kernel as of v6.11-rc6.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/118
10 months agotestsuite: reformat and clang-format off arrays
Emil Velikov [Sun, 8 Sep 2024 10:38:12 +0000 (11:38 +0100)] 
testsuite: reformat and clang-format off arrays

For some arrays, clang-format does far than ideal jobs reformatting. Do
so manually and ban clang-format from interfering.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/118
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agotestsuite: reformat and clang-format off args[]
Emil Velikov [Sun, 8 Sep 2024 10:38:12 +0000 (11:38 +0100)] 
testsuite: reformat and clang-format off args[]

Reformat a bunch of the args blocks and freeze them as-is. The remaining
instances clang-format handles correctly. The format is:

  progname,
  '--list', 'of', '--arguments',
  'modname',
  NULL

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/118
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agotestsuite: remove .needspawn = false instances
Emil Velikov [Sun, 8 Sep 2024 10:38:12 +0000 (11:38 +0100)] 
testsuite: remove .needspawn = false instances

The .needspawn = false is the default so just remove them. Tall the
other tests don't set it, so remove the test-util.c instances.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/118
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agotools: reformat and clang-format off arrays
Emil Velikov [Sun, 8 Sep 2024 10:38:12 +0000 (11:38 +0100)] 
tools: reformat and clang-format off arrays

For some arrays, clang-format does far than ideal jobs reformatting. Do
so manually and ban clang-format from interfering.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/118
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agolibkmod: reformat and clang-format off arrays
Emil Velikov [Sun, 8 Sep 2024 10:38:12 +0000 (11:38 +0100)] 
libkmod: reformat and clang-format off arrays

For some arrays, clang-format does far than ideal jobs reformatting. Do
so manually and ban clang-format from interfering.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/118
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agolibkmod: guard some functions with clang-format off
Emil Velikov [Sun, 8 Sep 2024 10:38:12 +0000 (11:38 +0100)] 
libkmod: guard some functions with clang-format off

Running this through clang-format results in a massacre. In some cases
we get function names starting at column 1, in others, every argument is
on separate line.

Just block the lot, so things are somewhat sane and consistent.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/118
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agolibkmod: remove the "Ugly assignment + check."
Emil Velikov [Fri, 6 Sep 2024 21:48:40 +0000 (22:48 +0100)] 
libkmod: remove the "Ugly assignment + check."

Check if the module is blacklisted first and then perform the individual
flag checks. As result drop the no-longer needed comment.

This might be a dozen CPU cycles slower, but overall clarity triumphs.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/112
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
10 months agolibkmod: module_is_blacklisted takes a const mod
Emil Velikov [Fri, 6 Sep 2024 21:46:30 +0000 (22:46 +0100)] 
libkmod: module_is_blacklisted takes a const mod

Update the API to reflect reality.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/112
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>