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>
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>
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>
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>
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>
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>