Commit Graph

1847 Commits

Author SHA1 Message Date
Emil Velikov
2410f11e60 meson: s/modulesi/modules/ typo
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>
2024-11-07 10:10:34 -06:00
Emil Velikov
5c3ea2f45d README.md: adjust the optional dependency note
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>
2024-11-07 10:10:34 -06:00
Emil Velikov
5b2f86cd08 meson: default enable compression and openssl
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>
2024-11-07 10:10:34 -06:00
Tobias Stoeckmann
093285cb6a libkmod: Fix typo in comment
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/223
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-04 07:26:44 -06:00
Emil Velikov
e0a9df3b7a meson: don't escape module_foo in kmod.pc
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>
2024-11-01 10:35:21 -05:00
Emil Velikov
d5c7452c29 meson: align default distconfdir with autotools
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>
2024-11-01 10:33:37 -05:00
Tobias Stoeckmann
6e10fd50dc libkmod: Properly skip first symbol entry
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>
2024-10-30 07:59:18 -05:00
Tobias Stoeckmann
4891b4b095 libkmod: Unify kmod_module_new_from_* functions
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>
2024-10-28 21:55:10 -05:00
Tobias Stoeckmann
d090fb3ae5 libkmod: Clean up all dependencies on error path
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>
2024-10-28 21:55:10 -05:00
Tobias Stoeckmann
6ac1bccfe1 libkmod: Clarify function signature
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>
2024-10-28 21:55:10 -05:00
Tobias Stoeckmann
be728dd347 libkmod: Simplify module dependency parsing
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>
2024-10-28 21:55:10 -05:00
Tobias Stoeckmann
a4de36806a libkmod: Fix typo in libkmod.h
It's "within" instead of "with in".

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>
2024-10-28 21:55:10 -05:00
Tobias Stoeckmann
ed28efa53b libkmod: Reduce code duplication
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>
2024-10-28 21:55:10 -05:00
Tobias Stoeckmann
daccf4613f libkmod: Use fread_unlocked
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>
2024-10-28 21:50:14 -05:00
Tobias Stoeckmann
0f6d92ad78 libkmod: Add better caching to FILE index
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>
2024-10-28 21:50:14 -05:00
Tobias Stoeckmann
899824576d libkmod: Read multiple numbers at once
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>
2024-10-28 21:50:14 -05:00
Emil Velikov
91aa10affe meson: factor common strings when handling shell completions
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>
2024-10-24 18:10:12 -05:00
Emil Velikov
f35ef15374 meson: bump to 0.61, use install_symlink()
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>
2024-10-24 18:10:12 -05:00
Emil Velikov
cea524a659 meson: disable automatic shell completion on prefix missmatch
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>
2024-10-24 18:10:12 -05:00
Emil Velikov
a685a68beb meson: remove unused localstatedir=/var
... 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>
2024-10-24 18:10:12 -05:00
Emil Velikov
aa4c4cdd2a meson: port moduledir/distconfdir checks from autoconf
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>
2024-10-24 18:09:31 -05:00
Emil Velikov
9023f4f1bb meson: fold distconfdir/moduledir handling
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>
2024-10-24 17:46:26 -05:00
Emil Velikov
7401bb075b meson: group and print all directories in the summary
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>
2024-10-24 17:46:26 -05:00
Emil Velikov
49a17d3e7e meson: consolidate all get_option('somedir') handling
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>
2024-10-24 17:46:26 -05:00
Emil Velikov
8d409560e5 meson: switch to / operator instead of join_paths()
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>
2024-10-24 17:46:25 -05:00
Lucas De Marchi
cb9a656f83 Revert "libkmod: call fnmatch() only as needed"
This reverts commit e79bba6b4a.

This broke alias resolution to more than one module. Example:

	kmod v33:
	$ modprobe -R char-major-116-1
	snd
	snd_seq

	e79bba6b4a:
	$ ./modprobe -R char-major-116-1
	snd

Closes: https://github.com/kmod-project/kmod/issues/207
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/208
2024-10-24 10:08:01 -05:00
Tobias Stoeckmann
1fa0b27acb libkmod: Read mm index node content on demand
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>
2024-10-23 23:27:01 -05:00
Tobias Stoeckmann
cab7ddd5dd libkmod: Simplify index search functions
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>
2024-10-23 23:27:01 -05:00
Tobias Stoeckmann
b3a7664fea libkmod: Fix typos
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>
2024-10-23 23:27:01 -05:00
Tobias Stoeckmann
33248df9ea libkmod: Const annotate read_*_mm API
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>
2024-10-23 23:27:01 -05:00
Emil Velikov
1e48f8a37a CONTRIBUTING.md: mention about gtk-doc Since:
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>
2024-10-23 23:19:11 -05:00
Emil Velikov
1e4cd85c0b docs: annotate the deprecated API
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>
2024-10-23 23:19:11 -05:00
Emil Velikov
af27216996 docs: add per-version index sections
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>
2024-10-23 23:19:11 -05:00
Lucas De Marchi
e3c326a909 meson: Fix installing without DESTDIR
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
2024-10-23 23:17:02 -05:00
Tobias Stoeckmann
7155cf1db5 tools: Use options_from_array in insmod
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>
2024-10-23 22:10:39 -05:00
Tobias Stoeckmann
a3787fb134 tools: Extract options_from_array into opt.c
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>
2024-10-23 22:10:39 -05:00
Sedat Dilek
c1deab2be3 meson: Collect all prefix get_option at one place
Signed-off-by: Sedat Dilek <sedat.dilek@gmail.com>
Link: https://lore.kernel.org/r/20241023205352.45271-1-sedat.dilek@gmail.com
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-10-23 16:25:41 -05:00
Emil Velikov
844835cd9a meson: always pass complete path to kmod-symlink.sh
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>
2024-10-23 10:54:41 -05:00
Tobias Stoeckmann
33e3d24cdb libkmod: Prevent OOB with huge amount of symbols
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>
2024-10-22 12:23:42 -05:00
Emil Velikov
823849a05a tools/depmod: use separate arrays for alias,xxxdep values
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>
2024-10-22 12:18:18 -05:00
Tobias Stoeckmann
5ebbde9380 libkmod: Adjust style
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>
2024-10-22 12:02:56 -05:00
Tobias Stoeckmann
ff17adf210 libkmod: Use correct format specifiers
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>
2024-10-22 12:02:56 -05:00
Tobias Stoeckmann
1319ac5348 libkmod: Access correct array
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>
2024-10-22 12:02:56 -05:00
Tobias Stoeckmann
bb0c280181 libkmod: Simplify size checks
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>
2024-10-22 12:02:56 -05:00
Tobias Stoeckmann
6d3aa4ed08 libkmod: Remove elf_find_section
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>
2024-10-22 12:02:56 -05:00
Tobias Stoeckmann
e4d7593818 libkmod: Inline elf_get_strings_section
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>
2024-10-22 12:02:56 -05:00
Tobias Stoeckmann
e0e068143a libkmod: Simplify section name handling
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>
2024-10-22 12:02:56 -05:00
Tobias Stoeckmann
25ab561bd5 libkmod: Use ELF offsets more often
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>
2024-10-22 12:02:56 -05:00
Tobias Stoeckmann
2669abb18b libkmod: Remove struct name
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>
2024-10-22 12:02:56 -05:00
Tobias Stoeckmann
b000028d35 libkmod: Use correct data types
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>
2024-10-22 12:02:56 -05:00