Accomodate the fact that newer libc versions may in fact not

contain query_module and friends and more
This commit is contained in:
Eric Andersen 2004-02-13 08:09:43 +00:00
parent 95b26250a7
commit ec359e9ebb

View File

@ -23,22 +23,33 @@
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
/* Kernel headers before 2.1.mumble need this on the Alpha to get
_syscall* defined. */
#define __LIBRARY__
#include <sys/syscall.h>
#include "libbb.h"
/* These syscalls are not included in very old glibc versions */
#if ((__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1))
int delete_module(const char *name)
{
#ifndef __NR_delete_module
#warning This kernel does not support the delete_module syscall
#warning -> The delete_module system call is being stubbed out...
errno=ENOSYS;
return -1;
#else
return(syscall(__NR_delete_module, name));
#endif
}
int get_kernel_syms(__ptr_t ks)
{
#ifndef __NR_get_kernel_syms
#warning This kernel does not support the get_kernel_syms syscall
#warning -> The get_kernel_syms system call is being stubbed out...
errno=ENOSYS;
return -1;
#else
return(syscall(__NR_get_kernel_syms, ks));
#endif
}
/* This may have 5 arguments (for old 2.0 kernels) or 2 arguments
@ -46,7 +57,14 @@ int get_kernel_syms(__ptr_t ks)
* and let the kernel cope with whatever it gets. Its good at that. */
int init_module(void *first, void *second, void *third, void *fourth, void *fifth)
{
#ifndef __NR_init_module
#warning This kernel does not support the init_module syscall
#warning -> The init_module system call is being stubbed out...
errno=ENOSYS;
return -1;
#else
return(syscall(__NR_init_module, first, second, third, fourth, fifth));
#endif
}
int query_module(const char *name, int which, void *buf, size_t bufsize, size_t *ret)
@ -66,6 +84,12 @@ int query_module(const char *name, int which, void *buf, size_t bufsize, size_t
/* Jump through hoops to fixup error return codes */
unsigned long create_module(const char *name, size_t size)
{
#ifndef __NR_create_module
#warning This kernel does not support the create_module syscall
#warning -> The create_module system call is being stubbed out...
errno=ENOSYS;
return -1;
#else
long ret = syscall(__NR_create_module, name, size);
if (ret == -1 && errno > 125) {
@ -73,9 +97,8 @@ unsigned long create_module(const char *name, size_t size)
errno = 0;
}
return ret;
}
#endif
}
/* END CODE */