Fix the typo in the option description.
Reported-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/225
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
With last commit we've default-enabled a few options. So the optional
dependencies become required now.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/225
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The default for the compressions and openssl is based on the autotools
build ones. With the initial goal to make migration as easy as possible
- identical option names, help messages, defaults...
Although a bunch of these have changed already, plus we want builders to
get support for compressed/signed modules out of the box.
So let's flip the defaults - everyone is welcome to adjust those when
calling `meson setup -D foo=bar`.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/225
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The kmod.pc file, contains module_signatures and module_compressions
space-separated lists, indicating how kmod is built. For the meson
generated file, any spaces are escaped where the autotools one does not
do that.
Update the meson build to be consistent with the original autotools one
and omit the escaping that we don't want.
Aside: seems like autotools does not escape the directory variables
either, so if the path(s) have any spaces in them pkg-config (pkgconf at
least) produces rubbish, quite rightfully IMHO.
Eg.
$ cat .../autotools-file.pc
prefix=/usr
includedir=${prefix}/include bar
Cflags: -I${includedir}
...
$ pkg-config --cflags autotools-file.pc
bar
$ cat .../meson-file.pc
prefix=/usr
includedir=${prefix}/include\ bar
Cflags: -I${includedir}
...
$ pkg-config --cflags meson-file.pc
-I/usr/include\ bar
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/217
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Autotools uses $prefix/lib as the default for distconfdir, while meson
$libdir - which is not guaranteed to be the same.
In particular: Debian and derivatives use /usr/lib/$target-triplet as a
$libdir, while still keep the configuration directory as /usr/lib.
Fixes: 370141c1 ("meson: introduce meson, covering libkmod.so")
Reported-by: Marco d'Itri <md@linux.it>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/216
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
This fixes a regression introduced while converting pointer to
offset arithmetics.
The for-loop itself starts at 1 already, so reflect this with the
manually performed offset + length calculation right at the start.
Closes: https://github.com/kmod-project/kmod/issues/214
Fixes: 25ab561b ("libkmod: Use ELF offsets more often")
Reported-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/215
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Return result of kmod_module_new directly in kmod_module_new_from_alias
so this function handles return values like the others.
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/211
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
If kmod_module_parse_depline runs out of memory, it is possible
that not all dependency modules are unlinked.
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/211
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The module_get_dependencies_noref function may modify content of
given kmod_module struct, so clarify this fact.
Actually we would have to adjust kmod API for total clarification,
but let's start with internally used functions first.
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/211
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The return value of kmod_module_parse_depline and
module_get_dependencies_noref are never used, and the same is true for
n_dep in struct kmod_module.
Remove them and turn variable n in kmod_module_parse_depline into a
size_t to make sure that it never overflows.
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/211
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
If functions exist which cover the exact explicitly written code, use
them 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/211
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
This is in sync with read_char, which uses getc_unlocked. This and
previous FILE based index adjustments improved FILE based index dump
performance by 8 %.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/190
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
We can use getdelim and reuse buffers by referencing the index_file
instead of just the FILE handle.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/190
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reduce the FILE overhead by reading as many bytes as possible at once.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/190
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Remove some of the repetition, by moving the common roots as needed.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/209
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Bump the meson requirement to 0.61 which allows us to remove our clunky
shell script in favour of the native install_symlink().
In terms of OS support - according to repology, all distributions which
have 0.60 (Fedora 36 + winget) also have 0.61 in their repositories.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/209
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Currently one can choose a prefix completely different from the one
bash-completion and fish use, as per their pkg-config file.
In such cases, flag a warning and disable it. People can always manually
provide the completion directory/ies to re-enable.
$ meson setup --prefix=/tmp/example build/
...
WARNING: User provided prefix '/tmp/example' differs from bash-completion one '/usr'. Disabling completion.
...
WARNING: User provided prefix '/tmp/example' differs from fish one '/usr'. Disabling completion.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/209
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
... not sure what I was smoking to add this, since we don't use it
anywhere.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/209
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Namely, ensure they are absolute paths and any trailing / is stripped.
$ meson setup -D moduledir=relative/ build/
...
ERROR: Problem encountered: User provided moduledir, 'relative' is not an absolute path.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/209
[ Fix relative customdir ]
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
We're about to add a few more checks, so instead of duplicating them
fold the handling of custom variables in single place.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/209
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The original listing (both contents and ordering) was copied from
autotools. Update it to be more comprehensive and logical.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/209
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Consolidate fetching of the directory options in a single place. This
allows us to see what's missing, wrong and prevents error-prone
duplication.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/209
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The former was introduced with meson v0.49.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/209
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Many values are never needed, so only parse them on demand. Also keep
pointers into memory-mapped area without copying data into dynamically
sized structs, which allows nodes to be kept on stack.
Improves performance of `modprobe -c` by around 3 %.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/201
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Remove arguments with fixed values. Also increment char pointers instead
of working with addresses of indices for easier readability.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/201
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Clarify that we never intend to modify the memory-mapped content.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/201
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
We don't have an easy way to test if API is missing a Since annotation,
so mention that in the contributing guide.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/200
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The kmod_module_get_filtered_blacklist() was deprecated since kmod v6 in
favour of kmod_module_apply_filter().
Add the decoration so gtk-doc includes it in the generated html and also
add a designated index.
It seem that gtk-doc insists on having deprecation guards, so not it
prints an extra warning like:
warning: XXX is deprecated in the inline comments, but no deprecation
guards were found around the declaration. (See the --deprecated-guards
option for gtkdoc-scan.)
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/200
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
With the introduction of the "Since: XX" tags, gtk-doc has been
helpfully reminding us that the per-version index isn't referenced
anywhere.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/200
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Script fails because of `set -u`. Make sure DESTDIR is set to something
Reported-by: Sedat Dilek <sedat.dilek@gmail.com>
Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # meson v1.6.0
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/206
Adjust arguments of options_from_array to avoid skipping the first
array entry because that's not intuitive based on its function name.
Fixes insmod's handling of module options given as quoted command line
arguments.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/204
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The function should be used in insmod as well to allow identical
handling of module options between insmod and modprobe.
Prepare using the function in insmod by extracting it into opt.c.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/204
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The end-user can provide either relative (to prefix) or an absolute
directory for bindir. Just fold the prefix and bindir with join_path()
which handles this correctly and pass that to kmod-symlink.sh instead of
relying on the MESON_INSTALL_DESTDIR_PREFIX environment variable.
This was previously failing due to trying to create the symlink in the
wrong location:
$ meson setup --prefix /usr --bindir /bin build-gentoo
$ DESTDIR=/tmp/install-gentoo meson install -C build-gentoo/
...
ln: failed to create symbolic link '/tmp/install-gentoo/usr//bin/depmod': No such file or directory
FAILED: install script '/home/ldmartin/p/kmod/scripts/kmod-symlink.sh /bin/depmod' failed with exit code 1.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/205
[ fix typo, add repro ]
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
On 32 bit systems it's possible to overflow the final calculation of
required memory for symbols retrieved from __ksymtab_strings.
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/198
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Currently, we walk the info list multiples times each time filtering all
but one key. Just create a few arrays to avoid that, saving 2-3% cycles
at the cost of extra ~500bytes per module.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/197
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Add a blank between variable declaration and function 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/196
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Use correct format specifiers for size_t variables.
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/196
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The contents of s and strings are identical at this point, but iterate
over the correct variable nonetheless.
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/196
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
An empty section is very unlikely, so reorder code to account for it.
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/196
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The function's purpose can be merged into elf_get_section. Reduces
amount of duplicated code.
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/196
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Its only caller can do the processing directly (kmod_elf_new).
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/196
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The name of string section is not needed, so it does not have to stored.
If section name is needed, return a char pointer instead of forcing the
caller to handle offset and memory calculations.
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/196
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Returned pointers are converted back to offsets in some functions. It is
more readable to turn offsets into pointers though.
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/196
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
This struct name is never used. Define it just like the other ones in
kmod_elf.
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/196
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
A huge module file could contain more symbols than could be represented
with an int. Use size_t 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/196
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>