From ec359e9ebbd1e55e4e3074512f8a5b191c3465a3 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Fri, 13 Feb 2004 08:09:43 +0000 Subject: Accomodate the fact that newer libc versions may in fact not contain query_module and friends and more --- libbb/module_syscalls.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/libbb/module_syscalls.c b/libbb/module_syscalls.c index cb9258af2..9dca6f04f 100644 --- a/libbb/module_syscalls.c +++ b/libbb/module_syscalls.c @@ -23,22 +23,33 @@ #include #include #include -/* Kernel headers before 2.1.mumble need this on the Alpha to get - _syscall* defined. */ -#define __LIBRARY__ #include #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 */ -- cgit v1.2.3