mirror of
https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git
synced 2024-11-23 10:53:40 +08:00
1d0117f86a
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>
45 lines
961 B
C
45 lines
961 B
C
#pragma once
|
|
|
|
#include <unistd.h>
|
|
#include <sys/syscall.h>
|
|
|
|
/*
|
|
* Macros pulled from linux/module.h, to avoid pulling the header.
|
|
*
|
|
* In practise very few people have it installed and distros do not install the
|
|
* relevant package during their build.
|
|
*
|
|
* Values are UAPI, so they cannot change.
|
|
*/
|
|
#define MODULE_INIT_IGNORE_MODVERSIONS 1
|
|
#define MODULE_INIT_IGNORE_VERMAGIC 2
|
|
#define MODULE_INIT_COMPRESSED_FILE 4
|
|
|
|
#ifndef __NR_finit_module
|
|
#warning __NR_finit_module missing - kmod might not work correctly
|
|
#define __NR_finit_module -1
|
|
#endif
|
|
|
|
#ifndef HAVE_FINIT_MODULE
|
|
#include <errno.h>
|
|
|
|
static inline int finit_module(int fd, const char *uargs, int flags)
|
|
{
|
|
if (__NR_finit_module == -1) {
|
|
errno = ENOSYS;
|
|
return -1;
|
|
}
|
|
|
|
return syscall(__NR_finit_module, fd, uargs, flags);
|
|
}
|
|
#endif
|
|
|
|
#if !HAVE_DECL_BASENAME
|
|
#include <string.h>
|
|
static inline const char *basename(const char *s)
|
|
{
|
|
const char *p = strrchr(s, '/');
|
|
return p ? p + 1 : s;
|
|
}
|
|
#endif
|