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 | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 5 | * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> |
Eric Andersen | aad1a88 | 2001-03-16 22:47:14 +0000 | [diff] [blame] | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 | * |
Eric Andersen | aad1a88 | 2001-03-16 22:47:14 +0000 | [diff] [blame] | 21 | */ |
| 22 | |
| 23 | #include <stdio.h> |
| 24 | #include <errno.h> |
Eric Andersen | a2a978a | 2001-04-05 06:08:14 +0000 | [diff] [blame] | 25 | #include <unistd.h> |
| 26 | /* Kernel headers before 2.1.mumble need this on the Alpha to get |
| 27 | _syscall* defined. */ |
| 28 | #define __LIBRARY__ |
Eric Andersen | a2a978a | 2001-04-05 06:08:14 +0000 | [diff] [blame] | 29 | #include <sys/syscall.h> |
Eric Andersen | aad1a88 | 2001-03-16 22:47:14 +0000 | [diff] [blame] | 30 | #include "libbb.h" |
| 31 | |
Mike Frysinger | 9b9e547 | 2005-03-04 01:27:18 +0000 | [diff] [blame] | 32 | int sysfs(int option, unsigned int fs_index, char * buf) |
Eric Andersen | a2a978a | 2001-04-05 06:08:14 +0000 | [diff] [blame] | 33 | { |
Mike Frysinger | ddddb94 | 2005-08-27 18:19:01 +0000 | [diff] [blame] | 34 | #ifndef __NR_pivot_root |
| 35 | #warning This kernel does not support the sysfs syscall |
| 36 | #warning -> The sysfs system call is being stubbed out... |
| 37 | bb_error_msg("\n\nTo make this application work, you will need to recompile\n" |
| 38 | "BusyBox with a kernel supporting the pivot_root system call.\n"); |
| 39 | errno = ENOSYS; |
| 40 | return -1; |
| 41 | #else |
Eric Andersen | a2a978a | 2001-04-05 06:08:14 +0000 | [diff] [blame] | 42 | return(syscall(__NR_sysfs, option, fs_index, buf)); |
Mike Frysinger | ddddb94 | 2005-08-27 18:19:01 +0000 | [diff] [blame] | 43 | #endif |
Eric Andersen | a2a978a | 2001-04-05 06:08:14 +0000 | [diff] [blame] | 44 | } |
Eric Andersen | aad1a88 | 2001-03-16 22:47:14 +0000 | [diff] [blame] | 45 | |
Eric Andersen | 82ab3d7 | 2003-05-26 18:48:56 +0000 | [diff] [blame] | 46 | int pivot_root(const char * new_root,const char * put_old) |
| 47 | { |
Eric Andersen | e76c3b0 | 2001-04-05 03:14:39 +0000 | [diff] [blame] | 48 | #ifndef __NR_pivot_root |
| 49 | #warning This kernel does not support the pivot_root syscall |
| 50 | #warning -> The pivot_root system call is being stubbed out... |
Mike Frysinger | 9b9e547 | 2005-03-04 01:27:18 +0000 | [diff] [blame] | 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 | bb_error_msg("\n\nTo make this application work, you will need to recompile\n" |
| 57 | "BusyBox with a kernel supporting the pivot_root system call.\n"); |
| 58 | errno = ENOSYS; |
| 59 | return -1; |
Eric Andersen | e76c3b0 | 2001-04-05 03:14:39 +0000 | [diff] [blame] | 60 | #else |
Mike Frysinger | 9b9e547 | 2005-03-04 01:27:18 +0000 | [diff] [blame] | 61 | return(syscall(__NR_pivot_root, new_root, put_old)); |
| 62 | #endif /* __NR_pivot_root */ |
Eric Andersen | 82ab3d7 | 2003-05-26 18:48:56 +0000 | [diff] [blame] | 63 | } |
Eric Andersen | e76c3b0 | 2001-04-05 03:14:39 +0000 | [diff] [blame] | 64 | |
| 65 | |
Mike Frysinger | 9b9e547 | 2005-03-04 01:27:18 +0000 | [diff] [blame] | 66 | /* These syscalls are not included in ancient glibc versions, |
| 67 | so we have to define them ourselves, whee ! */ |
Eric Andersen | 85e5e72 | 2003-07-22 08:56:55 +0000 | [diff] [blame] | 68 | #if ((__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1)) |
Eric Andersen | 82ab3d7 | 2003-05-26 18:48:56 +0000 | [diff] [blame] | 69 | |
Eric Andersen | 82ab3d7 | 2003-05-26 18:48:56 +0000 | [diff] [blame] | 70 | int bdflush(int func, int data) |
| 71 | { |
Mike Frysinger | 9b9e547 | 2005-03-04 01:27:18 +0000 | [diff] [blame] | 72 | return(syscall(__NR_bdflush, func, data)); |
Eric Andersen | 82ab3d7 | 2003-05-26 18:48:56 +0000 | [diff] [blame] | 73 | } |
Eric Andersen | e76c3b0 | 2001-04-05 03:14:39 +0000 | [diff] [blame] | 74 | |
| 75 | #ifndef __alpha__ |
| 76 | # define __NR_klogctl __NR_syslog |
Eric Andersen | 82ab3d7 | 2003-05-26 18:48:56 +0000 | [diff] [blame] | 77 | int klogctl(int type, char *b, int len) |
| 78 | { |
Mike Frysinger | 9b9e547 | 2005-03-04 01:27:18 +0000 | [diff] [blame] | 79 | return(syscall(__NR_klogctl, type, b, len)); |
Eric Andersen | 82ab3d7 | 2003-05-26 18:48:56 +0000 | [diff] [blame] | 80 | } |
Mike Frysinger | 9b9e547 | 2005-03-04 01:27:18 +0000 | [diff] [blame] | 81 | #endif /* __alpha__ */ |
Eric Andersen | aad1a88 | 2001-03-16 22:47:14 +0000 | [diff] [blame] | 82 | |
Eric Andersen | 82ab3d7 | 2003-05-26 18:48:56 +0000 | [diff] [blame] | 83 | |
Eric Andersen | aad1a88 | 2001-03-16 22:47:14 +0000 | [diff] [blame] | 84 | int umount2(const char * special_file, int flags) |
| 85 | { |
Mike Frysinger | a36ac0d | 2005-03-04 01:34:23 +0000 | [diff] [blame] | 86 | #ifndef __NR_umount2 |
Eric Andersen | 82ab3d7 | 2003-05-26 18:48:56 +0000 | [diff] [blame] | 87 | #warning This kernel does not support the umount2 syscall |
| 88 | #warning -> The umount2 system call is being stubbed out... |
Mike Frysinger | 9b9e547 | 2005-03-04 01:27:18 +0000 | [diff] [blame] | 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 | bb_error_msg("\n\nTo make this application work, you will need to recompile\n" |
| 95 | "BusyBox with a kernel supporting the umount2 system call.\n"); |
| 96 | errno = ENOSYS; |
| 97 | return -1; |
Eric Andersen | 82ab3d7 | 2003-05-26 18:48:56 +0000 | [diff] [blame] | 98 | #else |
Mike Frysinger | 9b9e547 | 2005-03-04 01:27:18 +0000 | [diff] [blame] | 99 | return(syscall(__NR_umount2, special_file, flags)); |
| 100 | #endif /* __NR_pivot_root */ |
Eric Andersen | 82ab3d7 | 2003-05-26 18:48:56 +0000 | [diff] [blame] | 101 | } |
Eric Andersen | aad1a88 | 2001-03-16 22:47:14 +0000 | [diff] [blame] | 102 | |
Mike Frysinger | 9b9e547 | 2005-03-04 01:27:18 +0000 | [diff] [blame] | 103 | #endif /* old glibc check */ |
Eric Andersen | e76c3b0 | 2001-04-05 03:14:39 +0000 | [diff] [blame] | 104 | |
| 105 | |
Eric Andersen | aad1a88 | 2001-03-16 22:47:14 +0000 | [diff] [blame] | 106 | /* END CODE */ |
| 107 | /* |
| 108 | Local Variables: |
| 109 | c-file-style: "linux" |
| 110 | c-basic-offset: 4 |
| 111 | tab-width: 4 |
| 112 | End: |
| 113 | */ |