Eric Andersen | aad1a88 | 2001-03-16 22:47:14 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* |
Eric Andersen | a2a978a | 2001-04-05 06:08:14 +0000 | [diff] [blame] | 3 | * some system calls possibly missing from libc |
Eric Andersen | aad1a88 | 2001-03-16 22:47:14 +0000 | [diff] [blame] | 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 | aad1a88 | 2001-03-16 22:47: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 | * |
Eric Andersen | aad1a88 | 2001-03-16 22:47:14 +0000 | [diff] [blame] | 22 | */ |
| 23 | |
| 24 | #include <stdio.h> |
| 25 | #include <errno.h> |
Eric Andersen | a2a978a | 2001-04-05 06:08:14 +0000 | [diff] [blame] | 26 | #include <unistd.h> |
| 27 | /* Kernel headers before 2.1.mumble need this on the Alpha to get |
| 28 | _syscall* defined. */ |
| 29 | #define __LIBRARY__ |
Eric Andersen | a2a978a | 2001-04-05 06:08:14 +0000 | [diff] [blame] | 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 | aad1a88 | 2001-03-16 22:47:14 +0000 | [diff] [blame] | 35 | #include "libbb.h" |
| 36 | |
Eric Andersen | a2a978a | 2001-04-05 06:08:14 +0000 | [diff] [blame] | 37 | #if defined(__ia64__) |
| 38 | int sysfs( int option, unsigned int fs_index, char * buf) |
| 39 | { |
| 40 | return(syscall(__NR_sysfs, option, fs_index, buf)); |
| 41 | } |
| 42 | #else |
Eric Andersen | e76c3b0 | 2001-04-05 03:14:39 +0000 | [diff] [blame] | 43 | _syscall3(int, sysfs, int, option, unsigned int, fs_index, char *, buf); |
Eric Andersen | a2a978a | 2001-04-05 06:08:14 +0000 | [diff] [blame] | 44 | #endif |
Eric Andersen | aad1a88 | 2001-03-16 22:47:14 +0000 | [diff] [blame] | 45 | |
Eric Andersen | e76c3b0 | 2001-04-05 03:14:39 +0000 | [diff] [blame] | 46 | #ifndef __NR_pivot_root |
| 47 | #warning This kernel does not support the pivot_root syscall |
| 48 | #warning -> The pivot_root system call is being stubbed out... |
| 49 | int pivot_root(const char * new_root,const char * put_old) |
| 50 | { |
| 51 | /* BusyBox was compiled against a kernel that did not support |
| 52 | * the pivot_root system call. To make this application work, |
| 53 | * you will need to recompile with a kernel supporting the |
| 54 | * pivot_root system call. |
| 55 | */ |
| 56 | fprintf(stderr, "\n\nTo make this application work, you will need to recompile\n"); |
| 57 | fprintf(stderr, "with a kernel supporting the pivot_root system call. -Erik\n\n"); |
| 58 | errno=ENOSYS; |
| 59 | return -1; |
| 60 | } |
| 61 | #else |
Eric Andersen | a2a978a | 2001-04-05 06:08:14 +0000 | [diff] [blame] | 62 | # if defined(__ia64__) |
| 63 | int pivot_root(const char * new_root,const char * put_old) |
| 64 | { |
| 65 | return(syscall(__NR_pivot_root, new_root, put_old)); |
| 66 | } |
| 67 | # else |
| 68 | _syscall2(int,pivot_root,const char *,new_root,const char *,put_old); |
| 69 | # endif |
Eric Andersen | e76c3b0 | 2001-04-05 03:14:39 +0000 | [diff] [blame] | 70 | #endif |
Eric Andersen | aad1a88 | 2001-03-16 22:47:14 +0000 | [diff] [blame] | 71 | |
Eric Andersen | e76c3b0 | 2001-04-05 03:14:39 +0000 | [diff] [blame] | 72 | |
| 73 | |
| 74 | |
Eric Andersen | 831ed16 | 2001-04-05 22:38:32 +0000 | [diff] [blame] | 75 | #if __GNU_LIBRARY__ < 5 || ((__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1)) |
Eric Andersen | e76c3b0 | 2001-04-05 03:14:39 +0000 | [diff] [blame] | 76 | /* These syscalls are not included as part of libc5 */ |
| 77 | _syscall2(int, bdflush, int, func, int, data); |
Eric Andersen | e76c3b0 | 2001-04-05 03:14:39 +0000 | [diff] [blame] | 78 | |
| 79 | #ifndef __alpha__ |
| 80 | # define __NR_klogctl __NR_syslog |
| 81 | _syscall3(int, klogctl, int, type, char *, b, int, len); |
| 82 | #endif |
Eric Andersen | aad1a88 | 2001-03-16 22:47:14 +0000 | [diff] [blame] | 83 | |
| 84 | #ifndef __NR_umount2 |
| 85 | # warning This kernel does not support the umount2 syscall |
Eric Andersen | e76c3b0 | 2001-04-05 03:14:39 +0000 | [diff] [blame] | 86 | # warning -> The umount2 system call is being stubbed out... |
Eric Andersen | aad1a88 | 2001-03-16 22:47:14 +0000 | [diff] [blame] | 87 | int umount2(const char * special_file, int flags) |
| 88 | { |
| 89 | /* BusyBox was compiled against a kernel that did not support |
| 90 | * the umount2 system call. To make this application work, |
| 91 | * you will need to recompile with a kernel supporting the |
| 92 | * umount2 system call. |
| 93 | */ |
| 94 | fprintf(stderr, "\n\nTo make this application work, you will need to recompile\n"); |
| 95 | fprintf(stderr, "with a kernel supporting the umount2 system call. -Erik\n\n"); |
| 96 | errno=ENOSYS; |
| 97 | return -1; |
| 98 | } |
| 99 | # else |
Eric Andersen | e76c3b0 | 2001-04-05 03:14:39 +0000 | [diff] [blame] | 100 | _syscall2(int, umount2, const char *, special_file, int, flags); |
Eric Andersen | aad1a88 | 2001-03-16 22:47:14 +0000 | [diff] [blame] | 101 | #endif |
| 102 | |
Eric Andersen | e76c3b0 | 2001-04-05 03:14:39 +0000 | [diff] [blame] | 103 | |
| 104 | #endif /* __GNU_LIBRARY__ < 5 */ |
| 105 | |
| 106 | |
Eric Andersen | aad1a88 | 2001-03-16 22:47:14 +0000 | [diff] [blame] | 107 | /* END CODE */ |
| 108 | /* |
| 109 | Local Variables: |
| 110 | c-file-style: "linux" |
| 111 | c-basic-offset: 4 |
| 112 | tab-width: 4 |
| 113 | End: |
| 114 | */ |