Update a bunch of docs. Run a script to update my email addr.
[oweals/busybox.git] / libbb / syscalls.c
1 /* vi: set sw=4 ts=4: */
2 /*
3  * some system calls possibly missing from libc
4  *
5  * Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
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  *
21  */
22
23 #include <stdio.h>
24 #include <errno.h>
25 #include <unistd.h>
26 /* Kernel headers before 2.1.mumble need this on the Alpha to get
27    _syscall* defined.  */
28 #define __LIBRARY__
29 #include <sys/syscall.h>
30 #if __GNU_LIBRARY__ < 5
31 /* This is needed for libc5 */
32 #include <asm/unistd.h>
33 #endif
34 #include "libbb.h"
35
36 int sysfs( int option, unsigned int fs_index, char * buf)
37 {
38         return(syscall(__NR_sysfs, option, fs_index, buf));
39 }
40
41 int pivot_root(const char * new_root,const char * put_old)
42 {
43 #ifndef __NR_pivot_root
44 #warning This kernel does not support the pivot_root syscall
45 #warning -> The pivot_root system call is being stubbed out...
46     /* BusyBox was compiled against a kernel that did not support
47      *  the pivot_root system call.  To make this application work,
48      *  you will need to recompile with a kernel supporting the
49      *  pivot_root system call.
50      */
51     bb_error_msg("\n\nTo make this application work, you will need to recompile\n"
52             "BusyBox with a kernel supporting the pivot_root system call.\n");
53     errno=ENOSYS;
54     return -1;
55 #else
56     return(syscall(__NR_pivot_root, new_root, put_old));
57 #endif
58 }
59
60
61
62 #if __GNU_LIBRARY__ < 5 || ((__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1))
63
64 /* These syscalls are not included as part of libc5 */
65 int bdflush(int func, int data)
66 {
67     return(syscall(__NR_bdflush, func, data));
68 }
69
70 #ifndef __alpha__
71 # define __NR_klogctl __NR_syslog
72 int klogctl(int type, char *b, int len)
73 {
74     return(syscall(__NR_klogctl, type, b, len));
75 }
76 #endif
77
78
79 int umount2(const char * special_file, int flags)
80 {
81 #ifndef __NR_pivot_root
82 #warning This kernel does not support the umount2 syscall
83 #warning -> The umount2 system call is being stubbed out...
84     /* BusyBox was compiled against a kernel that did not support
85      *  the umount2 system call.  To make this application work,
86      *  you will need to recompile with a kernel supporting the
87      *  umount2 system call.
88      */
89     bb_error_msg("\n\nTo make this application work, you will need to recompile\n"
90             "BusyBox with a kernel supporting the umount2 system call.\n");
91     errno=ENOSYS;
92     return -1;
93 #else
94     return(syscall(__NR_umount2, special_file, flags));
95 #endif
96 }
97
98
99 #endif /* __GNU_LIBRARY__ < 5 */
100
101
102 /* END CODE */
103 /*
104 Local Variables:
105 c-file-style: "linux"
106 c-basic-offset: 4
107 tab-width: 4
108 End:
109 */