Eric Andersen | a2a978a | 2001-04-05 06:08:14 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* |
| 3 | * some system calls possibly missing from libc |
| 4 | * |
Eric Andersen | bdfd0d7 | 2001-10-24 05:00:29 +0000 | [diff] [blame] | 5 | * Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen |
| 6 | * Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org> |
Eric Andersen | a2a978a | 2001-04-05 06:08:14 +0000 | [diff] [blame] | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | * General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 21 | * |
| 22 | */ |
| 23 | |
| 24 | #include <stdio.h> |
| 25 | #include <errno.h> |
| 26 | #include <unistd.h> |
| 27 | /* Kernel headers before 2.1.mumble need this on the Alpha to get |
| 28 | _syscall* defined. */ |
| 29 | #define __LIBRARY__ |
| 30 | #include <sys/syscall.h> |
Eric Andersen | 806c74f | 2002-03-12 00:35:40 +0000 | [diff] [blame] | 31 | #if __GNU_LIBRARY__ < 5 |
| 32 | /* This is needed for libc5 */ |
Eric Andersen | a2a978a | 2001-04-05 06:08:14 +0000 | [diff] [blame] | 33 | #include <asm/unistd.h> |
Manuel Novoa III | a2949aa | 2001-06-29 18:59:32 +0000 | [diff] [blame] | 34 | #endif |
Eric Andersen | a2a978a | 2001-04-05 06:08:14 +0000 | [diff] [blame] | 35 | #include "libbb.h" |
| 36 | |
Eric Andersen | acc7757 | 2001-04-05 06:24:28 +0000 | [diff] [blame] | 37 | |
Eric Andersen | 9260fc5 | 2001-10-24 00:44:11 +0000 | [diff] [blame] | 38 | #if __GNU_LIBRARY__ < 5 || ((__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1)) |
Eric Andersen | a2a978a | 2001-04-05 06:08:14 +0000 | [diff] [blame] | 39 | /* These syscalls are not included as part of libc5 */ |
| 40 | _syscall1(int, delete_module, const char *, name); |
Eric Andersen | 911af57 | 2001-04-05 07:41:51 +0000 | [diff] [blame] | 41 | _syscall1(int, get_kernel_syms, __ptr_t, ks); |
Eric Andersen | a2a978a | 2001-04-05 06:08:14 +0000 | [diff] [blame] | 42 | |
Eric Andersen | 64c8b17 | 2001-04-05 07:33:10 +0000 | [diff] [blame] | 43 | /* This may have 5 arguments (for old 2.0 kernels) or 2 arguments |
| 44 | * (for 2.2 and 2.4 kernels). Use the greatest common denominator, |
| 45 | * and let the kernel cope with whatever it gets. Its good at that. */ |
| 46 | _syscall5(int, init_module, void *, first, void *, second, void *, third, |
| 47 | void *, fourth, void *, fifth); |
| 48 | |
Eric Andersen | a2a978a | 2001-04-05 06:08:14 +0000 | [diff] [blame] | 49 | #ifndef __NR_query_module |
| 50 | #warning This kernel does not support the query_module syscall |
| 51 | #warning -> The query_module system call is being stubbed out... |
| 52 | int query_module(const char *name, int which, void *buf, size_t bufsize, size_t *ret) |
| 53 | { |
| 54 | fprintf(stderr, "\n\nTo make this application work, you will need to recompile\n"); |
| 55 | fprintf(stderr, "with a kernel supporting the query_module system call. -Erik\n\n"); |
| 56 | errno=ENOSYS; |
| 57 | return -1; |
| 58 | } |
| 59 | #else |
| 60 | _syscall5(int, query_module, const char *, name, int, which, |
| 61 | void *, buf, size_t, bufsize, size_t*, ret); |
| 62 | #endif |
| 63 | |
| 64 | /* Jump through hoops to fixup error return codes */ |
Eric Andersen | 64c8b17 | 2001-04-05 07:33:10 +0000 | [diff] [blame] | 65 | #define __NR___create_module __NR_create_module |
| 66 | static inline _syscall2(long, __create_module, const char *, name, size_t, size) |
Eric Andersen | a2a978a | 2001-04-05 06:08:14 +0000 | [diff] [blame] | 67 | unsigned long create_module(const char *name, size_t size) |
| 68 | { |
Eric Andersen | 64c8b17 | 2001-04-05 07:33:10 +0000 | [diff] [blame] | 69 | long ret = __create_module(name, size); |
Eric Andersen | a2a978a | 2001-04-05 06:08:14 +0000 | [diff] [blame] | 70 | |
| 71 | if (ret == -1 && errno > 125) { |
| 72 | ret = -errno; |
| 73 | errno = 0; |
| 74 | } |
| 75 | return ret; |
| 76 | } |
| 77 | |
| 78 | #endif /* __GNU_LIBRARY__ < 5 */ |
| 79 | |
| 80 | |
| 81 | /* END CODE */ |
| 82 | /* |
| 83 | Local Variables: |
| 84 | c-file-style: "linux" |
| 85 | c-basic-offset: 4 |
| 86 | tab-width: 4 |
| 87 | End: |
| 88 | */ |
| 89 | |