efca3990289bce796ef812dacee6cffede23fdae
[oweals/busybox.git] / libbb / syscalls.c
1 /* vi: set sw=4 ts=4: */
2 /*
3  * Utility routines.
4  *
5  * Copyright (C) tons of folks.  Tracking down who wrote what
6  * isn't something I'm going to worry about...  If you wrote something
7  * here, please feel free to acknowledge your work.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22  *
23  * Based in part on code from sash, Copyright (c) 1999 by David I. Bell 
24  * Permission has been granted to redistribute this code under the GPL.
25  *
26  */
27
28 #include <stdio.h>
29 #include <errno.h>
30 #include <sys/syscall.h>
31 #include <linux/unistd.h>
32
33 #include "libbb.h"
34
35 _syscall3(int, sysfs, int, option, unsigned int, fs_index, char *, buf);
36
37 #ifndef __NR_pivot_root
38 #warning This kernel does not support the pivot_root syscall
39 #warning -> The pivot_root system call is being stubbed out...
40 int pivot_root(const char * new_root,const char * put_old)
41 {
42         /* BusyBox was compiled against a kernel that did not support
43          *  the pivot_root system call.  To make this application work,
44          *  you will need to recompile with a kernel supporting the
45          *  pivot_root system call.
46          */
47         fprintf(stderr, "\n\nTo make this application work, you will need to recompile\n");
48         fprintf(stderr, "with a kernel supporting the pivot_root system call. -Erik\n\n");
49         errno=ENOSYS;
50         return -1;
51 }
52 #else
53 _syscall2(int,pivot_root,const char *,new_root,const char *,put_old)
54 #endif
55
56
57
58
59 #if __GNU_LIBRARY__ < 5
60 /* These syscalls are not included as part of libc5 */
61 _syscall2(int, bdflush, int, func, int, data);
62 _syscall1(int, delete_module, const char *, name)
63
64 #ifndef __NR_query_module
65 #warning This kernel does not support the query_module syscall
66 #warning -> The query_module system call is being stubbed out...
67 int query_module(const char *name, int which, void *buf, size_t bufsize, size_t *ret)
68 {
69         /* BusyBox was compiled against a kernel that did not support
70          *  the query_module system call.  To make this application work,
71          *  you will need to recompile with a kernel supporting the
72          *  query_module system call.
73          */
74         fprintf(stderr, "\n\nTo make this application work, you will need to recompile\n");
75         fprintf(stderr, "with a kernel supporting the query_module system call. -Erik\n\n");
76         errno=ENOSYS;
77         return -1;
78 }
79 #else
80 _syscall5(int, query_module, const char *, name, int, which,
81                 void *, buf, size_t, bufsize, size_t*, ret);
82 #endif
83
84 #ifndef __alpha__
85 # define __NR_klogctl __NR_syslog
86   _syscall3(int, klogctl, int, type, char *, b, int, len);
87 #endif
88
89 #ifndef __NR_umount2
90 # warning This kernel does not support the umount2 syscall
91 # warning -> The umount2 system call is being stubbed out...
92 int umount2(const char * special_file, int flags)
93 {
94         /* BusyBox was compiled against a kernel that did not support
95          *  the umount2 system call.  To make this application work,
96          *  you will need to recompile with a kernel supporting the
97          *  umount2 system call.
98          */
99         fprintf(stderr, "\n\nTo make this application work, you will need to recompile\n");
100         fprintf(stderr, "with a kernel supporting the umount2 system call. -Erik\n\n");
101         errno=ENOSYS;
102         return -1;
103 }
104 # else
105 _syscall2(int, umount2, const char *, special_file, int, flags);
106 #endif
107
108
109 #endif /* __GNU_LIBRARY__ < 5 */
110
111
112 #if 0
113 _syscall1(int, sysinfo, struct sysinfo *, info);
114 #endif
115
116
117 /* END CODE */
118 /*
119 Local Variables:
120 c-file-style: "linux"
121 c-basic-offset: 4
122 tab-width: 4
123 End:
124 */