Commit Graph

1469 Commits

Author SHA1 Message Date
Lucas De Marchi
af21689dd0 depmod: Remove license/copyright from the middle
The top license is enough as it's the same. Just move the copyright to
the top and remove notice about code that was copied and modified: that
comment doesn't age well as source is updated.

Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://lore.kernel.org/r/20240723185921.1005569-4-lucas.de.marchi@gmail.com
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-26 13:41:56 -05:00
Lucas De Marchi
d4f659e12a Drop the one line short description on sources
Some are outdated, misleading or just repeat the same thing over and
over. Remove them as they are not needed.

Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://lore.kernel.org/r/20240723185921.1005569-3-lucas.de.marchi@gmail.com
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-26 13:41:56 -05:00
Lucas De Marchi
b5a2cd070d Use SPDX header for license
Drop the lengthy license from each file and just use SPDX like most
projects nowadays. This doesn't have any change to license, just how
they are recorded in each file.

This follows the kernel approach: header files use '/*' for comments
while .c files use '//'. For .m4, use "#".

Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://lore.kernel.org/r/20240723185921.1005569-2-lucas.de.marchi@gmail.com
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-26 13:41:56 -05:00
Lucas De Marchi
d84631afc2 libkmod: Move zstd-related functions to separate file
Move zstd-related function to a separate file so it's easier to isolate
the dependency on each decompression library.

Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/58
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-26 13:41:47 -05:00
Lucas De Marchi
24d78fed15 libkmod: Move zlib-related functions to separate file
Move zlib-related function to a separate file so it's easier to isolate
the dependency on each decompression library.

Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/58
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-26 13:41:24 -05:00
Lucas De Marchi
929ca4c92a libkmod: Move xz-related functions to separate file
Move xz-related function to a separate file so it's easier to isolate
the dependency on each decompression library.

Declare struct kmod_file in a shared libkmod-internal-file.h that will
be included only by sources implementing kmod_file decompression
routines.

Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/58
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-26 13:41:13 -05:00
Lucas De Marchi
d4d3df1089 build: Always run distcheck with all compression libraries
Make sure to pass enable all compression libraries so all sources are
included.

Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/58
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-26 13:40:46 -05:00
Emil Velikov
7d72b22385 libkmod: move new weak API to separate section
Add the new weak API, to a separate section in the version script. These
will be exposed with the upcoming v33 release and not with v5 as the
symbol tag implies.

Cc: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
Fixes: 05828b4 ("libkmod: add weak dependecies")
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Link: https://lore.kernel.org/r/20240719-abi-fixes-v1-3-1e6d99a2846b@gmail.com
2024-07-20 09:11:01 -05:00
Emil Velikov
a5b7ac3ee1 libkmod: correctly tag kmod_module_new_from_name_lookup
The symbol was introduced with v30, yet was erroneously added in the v5
section. Move it to the correct place.

In theory this might cause an issue - severity depends on how the
runtime linker is setup. From a harmless warning (on stderr/stdout) to
failure to load the library.

In practise this shouldn't be a problem, since there are seemingly no
external users of the API.

Fixes: 9becaae ("libkmod: Add lookup from module name")
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Link: https://lore.kernel.org/r/20240719-abi-fixes-v1-2-1e6d99a2846b@gmail.com
2024-07-20 09:11:01 -05:00
Emil Velikov
89596b7518 libkmod: document KMOD_INDEX_MODULES_BUILTIN_ALIAS in kmod_dump_index()
The extra enum was introduced a few years ago, although the (only)
function using it did not have it's documentation updated.

The commit itself has caused an ABI break with kmod v27, since the
KMOD_INDEX_MODULES_BUILTIN value has changed.

A search through Google, Github and Arch packages have shown one user of
kmod_dump_index() - the only API that uses the enum.

In that case and all others, no projects referencing the changed enum
were found. Although since recent and/or supported distros use kmod v27
or later we've decided to only update the documentation.

Cc: Alexey Gladkov <gladkov.alexey@gmail.com>
Fixes: b866b21 ("Lookup aliases in the modules.builtin.modinfo")
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Link: https://lore.kernel.org/r/20240719-abi-fixes-v1-1-1e6d99a2846b@gmail.com
2024-07-20 09:11:01 -05:00
Emil Velikov
29cc8c2e70 kmod: remove .alias config files for modprobe.d
The use of .alias (alongside .conf) was added for compatibility with the
original module-init-tools project and has been living in kmod ever
since.

In practise, all the linux distributions that I can see are using .conf
files alone, as instructed by modprobe.d(5) and the only instance of an
.alias file is the modules.alias as shipped in the kernel.

The latter is already handled by other parts of the kmod project, so
let's enforce what our documentation says.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Link: https://lore.kernel.org/r/20240717-rm-alias-v1-1-58874caf343a@gmail.com
2024-07-20 09:10:28 -05:00
Lucas De Marchi
91e4ea5a50 ci: Add Alpine
Add setup action for Alpine and start building it. Unfortunately the
testsuite is not ready yet and fails to build like this:

	../testsuite/path.c:219:14: error: conflicting types for '__xstat64';
	have 'int(int,  const char *, struct stat64 *)'
	  219 | WRAP_VERSTAT(__x,64);
	      |              ^~~

Add everything needed on the setup action, so when the underlying issue
is fixed, the testsuite can be enabled in CI.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/44
2024-07-17 12:37:51 -05:00
Lucas De Marchi
8c8860021a ci: Add Fedora
Add an action to setup latest Fedora and use it for the initial setup.
Add hack on /usr/lib/modules so /usr/lib/modules/*/build can still be
used in the rest of the workflow as the KDIR.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/44
2024-07-17 12:37:51 -05:00
Lucas De Marchi
0efaaa5355 ci: Add Archlinux
Add an action to setup Archlinux and use it for the initial setup.
The rest of the workflow can stay the same.

Currently the Arch container in docker hub is not very up-to-date with
some expired keys and other keys not yet in the package. Workaround
that by wiping the current db and reinstalling the keyring. As requested
by Emil, add a comment in this part of the github-action about why
that is done.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/44
2024-07-17 12:37:51 -05:00
Lucas De Marchi
e9f4600bd0 ci: Use a container and expand versions
Use containers to build/test so it's not restricted to the OS versions
supported by Github runners. A few changes are needed to the workflow to
support using containers:

	1) No need for sudo, so remove it
	2) Explicitly install missing zlib
	3) Explicitly pass KDIR= while building kernel modules, since it
	   won't match `uname -r`. This assumes the container has just
	   one kernel installed and so /usr/lib/modules/*/build can be
	   used as the single symlink to the kernel headers. This should
	   be common to other distros to be added, too.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/44
2024-07-17 12:37:51 -05:00
Lucas De Marchi
da6345d17a ci: Replace package installation with local action
Separate the package installation step with a local action so
it's easier to support more versions and distros.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/44
2024-07-17 12:37:51 -05:00
Lucas De Marchi
5cdd221d88 README: update to a decade+ later
- State support for clang and other libc's
- Fix typos
- Reword the compatibility with module-init-tools section,
  removing most of the specific examples as we didn't keep
  track of all of them, and they are not important anymore
  in year 2024

Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://lore.kernel.org/r/20240712132449.780421-1-lucas.de.marchi@gmail.com
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-17 12:28:36 -05:00
q66
8da7c1e088 libkmod: improve realloc behavior for zstd outbuffer
The allocator in glibc has a particular quirk that successive
reallocs on the same pointer are cheap, at the cost of excess
memory fragmentation. Other allocators generally do not do this,
so excessive reallocs become relatively expensive.

Reducing the number of reallocations by using a more agressive
strategy for buffer size increase makes performance better on
those setups, e.g. musl libc, or generally any other allocator;
on my Chimera Linux setup with Scudo allocator (LLVM) it doubles
to triples the performance of running e.g. depmod.

Signed-off-by: q66 <q66@chimera-linux.org>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-12 07:58:13 -05:00
Lucas De Marchi
a6f070b3e1 ci: Add github workflow
Add a minimal github workflow to test kmod. This can be incremented in
future to test more distros, compilers and libc.

Link: https://lore.kernel.org/r/20240709135007.104325-2-lucas.de.marchi@gmail.com
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-12 07:28:50 -05:00
Lucas De Marchi
8434a0bd93 build: Add mod-weakdep.c to EXTRA_DIST
Fix distcheck failure:
	make[5]: *** No rule to make target
	'/home/runner/work/kmod/kmod/build/kmod-32/_build/sub/testsuite/module-playground/mod-weakdep.o',
	needed by
	'/home/runner/work/kmod/kmod/build/kmod-32/_build/sub/testsuite/module-playground/'.
	Stop.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-09 08:38:00 -05:00
Emil Velikov
e7626810fd man: list options one per line
Somewhat inspired by my selfish use of VIM as man pager. Namely, when
there are multiple options on the same line, only the first one gets
properly rendered.

A good bonus point is that very long instances, like modinfo's legacy
"--author, --description ..." look a bit neater now.

With this is also more consistently handle short/long options which take
an argument.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-09 00:18:21 -05:00
Emil Velikov
082617913f man: rework AUTHORS section
Replace the partial listing with suggestion to check through git
shortlog and git blame.

Explicitly spell out the current maintainer, alongside giving Jon
attribution for the original project.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-09 00:18:21 -05:00
Emil Velikov
ff38d82ede man: remove the "Maintained by" references
At a glance through my system, around 2% of the man pages include such
statement.

Looking through git log, Jon has been active in a while and presumably
have moved on.

Most importantly the Copyright section isn't the best place to reference
the maintainer/contact person.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-09 00:18:21 -05:00
Emil Velikov
4ec655d249 man: modprobe: remove hard-coded /etc/modprobe.d references
Point the users to modprobe.d(5) instead.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-09 00:18:21 -05:00
Emil Velikov
42d60a3267 man: add few mentions about MODPROBE_OPTIONS
The environment variable may alter config file ordering, so mention it
in the man page.

In addition, highlight that the format is intentionally undocumented
since the use by third parties is discouraged.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-09 00:18:21 -05:00
Emil Velikov
e46b473a92 man: modprobe.d: factor out a CONFIGURATION FORMAT section
Keep the description neat and tidy.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-09 00:18:21 -05:00
Emil Velikov
11d09ac414 man: modprobe.d: document the config file order handling
The modprobe.d configuration order/handling aligns with existing tools
such as sysctl.d, even though there is no mention in the manual.

Reorder the list in SYNOPSIS and add a bit of verbiage describing things.

Section is inspired by sysctl.d(5) and sysctl(8).

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-09 00:18:21 -05:00
Emil Velikov
e83e142ce7 man: depmod: remove hard-coded /etc/depmod.d references
Point the users to depmod.d(5) instead.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-09 00:18:21 -05:00
Emil Velikov
7b19a71289 man: depmod.d: rework the opening description sentence
Use a slightly longer, more gradual introduction.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-09 00:18:21 -05:00
Emil Velikov
0682f1ed56 man: depmod.d: factor out a CONFIGURATION FORMAT section
Keep the description neat and tidy.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-09 00:18:21 -05:00
Emil Velikov
12ca199bd7 man: depmod.d: document the config file order handling
The depmod.d configuration order/handling aligns with existing tools
such as sysctl.d, even though there is no mention in the manual.

Reorder the list in SYNOPSIS and add a bit of verbiage describing things.

Section is inspired by sysctl.d(5) and sysctl(8).

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-09 00:18:21 -05:00
Emil Velikov
52a9d42464 man: stop removing DISTCONFDIR lines
Presently when DISTCONFDIR is identical to /lib we remove the whole
line, since the man pages already have an /lib instance.

At the same time, there are in-text DISTCONFDIR entries, and removing
the whole line outright breaks the documentation.

Drop the removal line - worst case scenario we get a duplicate entry in
the synopsis.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-09 00:18:21 -05:00
Emil Velikov
6f80a0874b man: couple of grammar/language fixes
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-09 00:18:21 -05:00
Emil Velikov
2b5c56c430 man: some options take an argument, mention that
For example modinfo -F requires the field name, although the
documentation was missing the "field".

Similarly modprobe has omissions, so let's fix those as well.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-09 00:18:21 -05:00
Emil Velikov
e971579bba man: misc punctuation fixes
Some commas and a full stop was missing ;-)

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-09 00:18:21 -05:00
Emil Velikov
f1e233c31e man: white space fixes
These were present in the original xml files and I opted to keep them
separate fix to make the transition/comparison easier.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-09 00:18:21 -05:00
Emil Velikov
134bf30e74 man: add some extra bold/italic annotations
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-09 00:18:21 -05:00
Emil Velikov
fa715f8c8b man: remove no longer used XML files
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-03 10:14:47 -05:00
Lucas De Marchi
aa125fbc4a build: Require scdoc if building man pages
Instead of creating invalid man pages, make sure the configure step
fails if scdoc is not available.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-03 10:14:47 -05:00
Lucas De Marchi
7829607fff gitignore: ignore gtk-doc.m4
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-03 10:14:47 -05:00
Emil Velikov
83e22ab5e9 man: build the scdoc based man pages
Note that scdoc does not handle natively handle the dummy
modules.dep.bin.5 entry, so we need to create one manually.

Not a big deal, since it's single static line anyway.

Also: pkg-config --variable=scdoc scdoc, produces the full executable
and path, although for now we stick with the AC_PATH_PROG approach.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
[ Do not add the stub man page (modules.dep.bin.5) to CLEANFILES
  to avoid removing a file that is tracked by git. Also fix a typo
  s/AM_V_SCDOR_/AM_V_SCDOC_/ to make silent rules to work ]
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-03 10:14:35 -05:00
Emil Velikov
f3a423b6d8 man: add scdoc based man pages
Working with xml is quite fiddly. Swap that for scdoc, which has very
trivial markup-like syntax.

We have opted for scdoc since it's available on practically any linux
distribution. Implementation-wise it's a trivial C99 project, at 1k LoC.

If using scdoc proves to be a burden, we can trivially port these to
pandoc or similar - 90% of the content will stay the same.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-07-03 10:10:05 -05:00
Jose Ignacio Tornos Martinez
d06712b514 testsuite: add tests for weak dependencies
The following tests to verify weak dependencies have been implemented:
1) modprobe test to check that related weakdep modules are not loaded
   due to being a weakdep.
2) depmod test to check weakdep output.
3) user test to check that configuration files with weakdep are parsed
   correctly and related weakdep modules can be read correctly from user
   applications.

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
Link: https://lore.kernel.org/r/20240530070836.9438-1-jtornosm@redhat.com
[ Minor whitespace issues and define MODULE_WEAKDEP if it's not defined
  already ]
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-06-14 14:16:17 -05:00
Emil Velikov
a0ed4f8438 .mailmap: Forward to my personal email
My Collabora email is bouncing, so forward to my personal Gmail.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://lore.kernel.org/r/20240611-mailmap-v1-1-69ce7f7ffbe6@gmail.com
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-06-14 13:49:03 -05:00
Lucas De Marchi
8837461494 testsuite: Add missing.h include
basename() moved to missing.h when the libc doesn't provide it, but
testsuite is not including it. Add missing include.

Fixes: 11eb9bc67c ("Use portable implementation for basename API")
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-06-11 08:15:36 -05:00
Lucas De Marchi
22c36b7dac depmod: Fix warning with -D_TIME_BITS=64
Printing time_t, suseconds_t, useconds_t in 32bits with -D_TIME_BITS=64
leads to the following warning:

../tools/depmod.c:2641:61: warning: format ‘%li’ expects argument of type ‘long int’, but argument 6 has type ‘__suseconds64_t’ {aka ‘long long int’} [-Wformat=]
 2641 |                         snprintf(tmp, sizeof(tmp), "%s.%i.%li.%li", itr->name, getpid(),
      |                                                           ~~^
      |                                                             |
      |                                                             long int
      |                                                           %lli
 2642 |                                         tv.tv_usec, tv.tv_sec);
      |                                         ~~~~~~~~~~

Paper it over by casting the argument to 64 bits and switching to long long.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-06-11 08:15:30 -05:00
Shengjing Zhu
68db675078 testsuite: wrap _{l,}stat64_time64 in test
Fix building with -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64 on 32bit arch.

Closes: https://github.com/kmod-project/kmod/issues/37
Bug: https://bugs.debian.org/1065973
Co-authored-by: Jochen Sprickerhof <github@jochen.sprickerhof.de>
Signed-off-by: Shengjing Zhu <shengjing.zhu@canonical.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-06-11 07:43:27 -05:00
Khem Raj
11eb9bc67c Use portable implementation for basename API
musl has removed the non-prototype declaration of basename from
string.h [1] which now results in build errors with clang-17+ compiler

Implement GNU basename behavior using strchr which is portable across libcs

Fixes
../git/tools/kmod.c:71:19: error: call to undeclared function 'basename'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
71 | "Commands:\n", basename(argv[0]));
| ^

[1] https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7

Suggested-by: Rich Felker

Signed-off-by: Khem Raj <raj.khem@gmail.com>
[ Implement a basename() function in missing.h and ensure we always use
  the right include rather than having a separate gnu_basename() ]
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-06-10 18:15:39 -05:00
Jose Ignacio Tornos Martinez
05828b4a6e libkmod: add weak dependecies
It has been seen that for some network mac drivers (i.e. lan78xx) the
related module for the phy is loaded dynamically depending on the current
hardware. In this case, the associated phy is read using mdio bus and then
the associated phy module is loaded during runtime (kernel function
phy_request_driver_module). However, no software dependency is defined, so
the user tools will no be able to get this dependency. For example, if
dracut is used and the hardware is present, lan78xx will be included but no
phy module will be added, and in the next restart the device will not work
from boot because no related phy will be found during initramfs stage.

In order to solve this, we could define a normal 'pre' software dependency
in lan78xx module with all the possible phy modules (there may be some),
but proceeding in that way, all the possible phy modules would be loaded
while only one is necessary.

The idea is to create a new type of dependency, that we are going to call
'weak' to be used only by the user tools that need to detect this situation.
In that way, for example, dracut could check the 'weak' dependency of the
modules involved in order to install these dependencies in initramfs too.
That is, for the commented lan78xx module, defining the 'weak' dependency
with the possible phy modules list, only the necessary phy would be loaded
on demand keeping the same behavior, but all the possible phy modules would
be available from initramfs.

A new function 'kmod_module_get_weakdeps' in libkmod will be added for
this to avoid breaking the API and maintain backward compatibility. This
general procedure could be useful for other similar cases (not only for
dynamic phy loading).

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
Link: https://lore.kernel.org/r/20240327141116.97587-1-jtornosm@redhat.com
2024-05-08 23:37:38 -05:00
Emil Velikov
5a8b16b718 libkmod: keep KMOD_FILE_COMPRESSION_NONE/load_reg in comp_types
It's cleaner to handle all compression types and load functions in the
same style.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-04-30 15:35:37 -05:00