Commit Graph

8 Commits

Author SHA1 Message Date
Emil Velikov
1d0117f86a 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>
2024-09-24 09:59:20 -05:00
Emil Velikov
b27aa3fb5a shared: use memdup over stdndupa
The stdndupa has a couple of gotchas:
 - allocates memory on stack via alloca(3)... where we pass it a
   user-provided string in at least one instance
 - it's a GNU extension missing on musl and bionic

The mkdir_p() function is not a hot path, so using heap allocation is
perfectly fine. Swap the stdndupa for our local helper memdup.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/92
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-09-02 08:55:40 -05:00
Emil Velikov
d469acd4d5 build: remove linux/module.h check
We include the header for the UAPI MODULE_INIT_* constants, while we
also provide them locally.

At a glance, at least Arch and Alpine build kmod without the uapi
header, so just drop the check and ifndef guards all together.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-08-23 13:51:19 -05:00
Emil Velikov
e48e07fd4c missing.h: remove be32toh wrapper
As the inline comment says, it is applicable for older distributions
like RHEL 5. The extended support for RHEL 5 ended in 2020 (4 years ago)
so we're safe to drop this.

According to the Alpine build logs - the symbol has been present in musl
for years.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-08-23 13:51:19 -05:00
Emil Velikov
cee455ee78 missing.h: warn on missing __NR_finit_module
Complain (somewhat) loudly if we don't have the syscall number, as the
default cannot work.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/86
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-08-23 13:51:19 -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
Emil Velikov
0140db94c0 libkmod: add fallback MODULE_INIT_COMPRESSED_FILE define
The symbol was somewhat recently introduced by the kernel and not all
distributions may be have available.

The number is part of the ABI, so we can add a local fallback define.

Closes: https://github.com/kmod-project/kmod/issues/29
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-09-27 22:37:45 -05:00
Lucas De Marchi
8b7189bc25 Move missing.h to shared directory 2014-10-03 00:31:10 -03:00