- Do not use gerund for commit message
- s/document/docs/
- Add commit sha to the doc commit message
- Update token name
- Add ci-test-docs branch to easily test changes
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
1. When master or a new tag is pushed, build API documentation
2. Push the newly built document to kmod-project.github.io
3. Dispatch kmod-project.github.io to publish documents
Co-developed-by: Chen, Yuchi <yuchi.chen@intel.com>
Signed-off-by: Chen, Yuchi <yuchi.chen@intel.com>
Signed-off-by: Gongjun Song <gongjun.song@intel.com>
Signed-off-by: Dan He <dan.h.he@intel.com>
Signed-off-by: Wenjie Wang <wenjie2.wang@intel.com>
Signed-off-by: Qingqing Li <qingqing.li@intel.com>
Link: https://github.com/kmod-project/kmod/pull/308
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
If strbuf is used (depmod, modprobe -c) then strbuf_reserve_extra is
performance critical. This reduces amount of instructions for
modprobe -c by around 10 %, the total instruction count for depmod
by 1 % (majority is within reading module files).
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/296
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
We can make it public if it's needed again.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/296
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The strbuf_reserve_extra call is only left for a possible '/' addition,
which only occurs before depmod_modules_search_dir recursively calls
itself.
By adding the slash at the start, it also simplifies
depmod_modules_search_path which does not have to do this before calling
depmod_modules_search_dir on its own.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/296
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The function depmod_modules_search_dir is supposed to ignore all errors
encountered during directory entry iteration. This was not true for
out of memory conditions, which could also lead to wrong output.
Clarify this fact by turning it void and adjust callers accordingly.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/296
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The strbuf functionality is always used to create C strings, so already
reserve an extra byte for NUL whenever size allocations occur.
Together with the fact that strbuf_str already returns a const char *,
an empty strbuf may return an unmodifiable empty string.
This renders all strbuf_str return value checks obsolete.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/296
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The only use case of strbuf_steal is gone. If the requirement for this
function returns, we can add it again.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/296
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The hex output uses a heap-based strbuf. It can be turned into a
stack-based strbuf by refactoring kmod_module_hex_to_str. Instead of
returning a C string, a supplied strbuf can be filled with hex values
in ASCII representation. Renamed to kmod_module_strbuf_pushhex.
A size of 512 is sufficient for signatures on Arch Linux and removes
heap allocations. Additional benefit is implicit strbuf_init and
strbuf_release due to DECLARE_STRBUF_WITH_STACK.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/296
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The deps bin output uses a strbuf. A size of 2048 covers all cases
on current Arch Linux (max used size is 1548) and removes heap
allocations.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/296
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The strbuf content is never returned, so it's easy to switch to a
stack-based solution. It removes heap allocations and the need to
manually call strbuf_init and strbuf_release since these are covered
through DECLARE_STRBUF_WITH_STACK as well.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/296
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
If the modules.builtin.modinfo file contains valid and invalid
lines, it is possible that libkmod leaks memory on error path.
Let strbuf API take care to always release strbuf and reset it
if allocated heap memory is taken away from it.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/291
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Clarify that the code does not perform error checks, for which we
regularly use checks and continue at the start, but merely checks
how to print/filter the data.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/290
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
- When fake delete_module() succeeds, remove its entry from /sys/module.
- Add tests to ensure module is properly removed.
Co-developed-by: Qingqing Li <qingqing.li@intel.com>
Signed-off-by: Qingqing Li <qingqing.li@intel.com>
Signed-off-by: Dan He <dan.h.he@intel.com>
Signed-off-by: Gongjun Song <gongjun.song@intel.com>
Signed-off-by: Yuchi Chen <yuchi.chen@intel.com>
Signed-off-by: Wenjie Wang <wenjie2.wang@intel.com>
Link: https://github.com/kmod-project/kmod/pull/309
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Add a test for a common setup (/usr/lib/modules) and a weird one
(/kernel-modules) to cover uses of moduledir.
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Due to a mistake on using "multilib" fixed in commit
271d8ab ("ci: Fix 32b build ignoring options") and commit
6897912 ("ci: s/multilib/x32/"), most of our builds were actually
testing 32b, which is not the most common thing.
Leave just 2 32b builds, one with Archlinux and the other with Ubuntu
and remove the FIXME about configuration.
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
In some configurations we pass meson_setup and x32 options, but the
options were being ignored in 32b builds. Unify the configure/build/test
steps since just the 32b configuration step that needs to be handled
differently, then make sure --native-file and the configure options
are also handled for 32b builds.
Add a 64b configuration for Archlinux and disable test on Archlinux x32
since it's failing due to packages installed and/or distro
configuration.
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
It's confusing using "multilib" because it's not about adding the
"capability of building 32b", it's rather "this is really building and
testing 32b, which takes different steps.
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Just use all the properties in a single level rather than embeding it in
the container object.
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The permutation available in github and extending it "include" or
reducing it with "exclude" are much harder than needed. It doesn't seem
we can have a mix of "properties" with the configurations. Just give up
and completly specify the matrix. Now that there's only 1 build system,
at least doing all the permutations doesn't make it too big.
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The path join operator / does not add a leading path seperator.
Signed-off-by: Hendrik Donner <hd@os-cillation.de>
Link: https://github.com/kmod-project/kmod/pull/303
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Some implementations of ln (toybox, busybox) typically only support the
short option format, so use it consistently.
The short options are already used in other places and it's usually
supported on more implementations: -s and -f are POSIX and the few
ln that support --relative understand -r. Which are GNU coreutils,
the Rust uutils coreutils, toybox (-r only) and there is an old
patch for busybox (-r only). The BSDs and MacOS don't seem to
support --relative at all.
Signed-off-by: Hendrik Donner <hd@os-cillation.de>
Link: https://github.com/kmod-project/kmod/pull/303
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
When running the testsuite with UBSAN and a non-existent info key is
used, the following happens:
TESTSUITE: running test_modinfo_sig_hashalgo, in forked context
TESTSUITE: ERR: 'test_modinfo_sig_hashalgo' [4212] terminated by signal 6 (Aborted)
TESTSUITE: ------
TESTSUITE: running test_modinfo_sig_key, in forked context
TESTSUITE: ERR: 'test_modinfo_sig_key' [4292] terminated by signal 6 (Aborted)
TESTSUITE: ------
TESTSUITE: running test_modinfo_signer, in forked context
TESTSUITE: ERR: 'test_modinfo_signer' [4348] terminated by signal 6 (Aborted)
In CI this happens when disabling module signature handling with
-D openssl=disabled. The UBSAN report is as below:
../dist-unpack/kmod-34/libkmod/libkmod-module.c:1773:2: runtime error: null pointer passed as argument 2, which is declared to never be null
#0 0x55bb657aa13b (/__w/kmod/kmod/build/meson-private/dist-build/kmod+0x9f13b) (BuildId: 2c8f9c0ffdbcdf249a3cca29a9d2bc47f706a324)
#1 0x55bb6580a4be (/__w/kmod/kmod/build/meson-private/dist-build/kmod+0xff4be) (BuildId: 2c8f9c0ffdbcdf249a3cca29a9d2bc47f706a324)
#2 0x55bb657cc360 (/__w/kmod/kmod/build/meson-private/dist-build/kmod+0xc1360) (BuildId: 2c8f9c0ffdbcdf249a3cca29a9d2bc47f706a324)
#3 0x55bb657cdf43 (/__w/kmod/kmod/build/meson-private/dist-build/kmod+0xc2f43) (BuildId: 2c8f9c0ffdbcdf249a3cca29a9d2bc47f706a324)
#4 0x7f0651bb3487 (/usr/lib/libc.so.6+0x27487) (BuildId: 0b707b217b15b106c25fe51df3724b25848310c0)
#5 0x7f0651bb354b (/usr/lib/libc.so.6+0x2754b) (BuildId: 0b707b217b15b106c25fe51df3724b25848310c0)
#6 0x55bb657aeb14 (/__w/kmod/kmod/build/meson-private/dist-build/kmod+0xa3b14) (BuildId: 2c8f9c0ffdbcdf249a3cca29a9d2bc47f706a324)
Keep the current behavior of appending a 0-length value, just skipping
the pointless memcpy.
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/300
The release tarballs may already contain symbolic links into the
file system for gtk-doc specific files.
If gtk-doc is not installed, and thus not desired for building,
remove the symbolic links and create empty files instead.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/295
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The pahole package is required in our test suite for module creation:
BTF [M] /__w/kmod/kmod/build/testsuite/module-playground/mod-simple.ko
/bin/sh: 1: pahole: not found
make[3]: *** [/usr/src/linux-headers-6.12.16-common/scripts/Makefile.modfinal:64: /__w/kmod/kmod/build/testsuite/module-playground/mod-simple.ko] Error 127
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/294
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
There is no libxz.so; xz produces liblzma.so.N.
Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Link: https://github.com/kmod-project/kmod/pull/288
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
When generating the dist archive, run autogen.sh so the tarball can also
be used by distros using autotools.
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Remove the explicit basename(argv[0]) calls because we already
rely on program_invocation_short_name even before reaching
these lines. Unifies code and slightly reduces binary size.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/284
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The write_* functions have different return statement handling. Unify
them by removing "else" if the if-block itself returns and also unify
the error handling by checking for the error case, leaving the success
return statement at the end of the function.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/285
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Add = to modprobe help output for --wait to comply with all other long
option descriptions.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/287
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Unifiy modinfo.8 with other manual pages by also explaining what
-h option does.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/287
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Stay in sync with other manual pages like the ones from coreutils
and the -h output of kmod tools.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/287
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
If no -o option is given, use stdout directly without opening
/dev/stdout manually. In a chroot environment, this could lead
to /dev/stdout creation as a regular file.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/283
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Check if enough bytes are available for Elf32_Ehdr, not Elf32_Shdr.
The size of Elf32_Shdr is needed later on.
Since both are 64 bytes, no functional change.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/279
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Add a missing newline between two functions.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/282
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The use_syslog variable is only used within main function, so reduce
its visibility.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/282
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Since log_open takes a booln as argument, turn use_syslog into a
bool instead of using an int. Shrinks binary size with GCC and from
C point of view, this makes the code cleaner.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/282
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
This generates a bunch of warnings in CI
ubuntu-latest pipelines will use ubuntu-24.04 soon. For more details,
see https://github.com/actions/runner-images/issues/10636
Update to ubuntu 24.04 to catch any possible issues and stop using
ubuntu-latest.
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Avoid issues like https://github.com/kmod-project/kmod/issues/269
by asserting the test binary is non-empty:
Suggested-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>