Make 'grep -l' work
[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,2000,2001 by Lineo, inc.
6  * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
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
31
32 #include <sys/syscall.h>
33 #include <asm/unistd.h>
34 #include "libbb.h"
35
36 #if defined(__ia64__)
37 int sysfs( int option, unsigned int fs_index, char * buf)
38 {
39         return(syscall(__NR_sysfs, option, fs_index, buf));
40 }
41 #else
42 _syscall3(int, sysfs, int, option, unsigned int, fs_index, char *, buf);
43 #endif
44
45 #ifndef __NR_pivot_root
46 #warning This kernel does not support the pivot_root syscall
47 #warning -> The pivot_root system call is being stubbed out...
48 int pivot_root(const char * new_root,const char * put_old)
49 {
50         /* BusyBox was compiled against a kernel that did not support
51          *  the pivot_root system call.  To make this application work,
52          *  you will need to recompile with a kernel supporting the
53          *  pivot_root system call.
54          */
55         fprintf(stderr, "\n\nTo make this application work, you will need to recompile\n");
56         fprintf(stderr, "with a kernel supporting the pivot_root system call. -Erik\n\n");
57         errno=ENOSYS;
58         return -1;
59 }
60 #else
61 #  if defined(__ia64__)
62         int pivot_root(const char * new_root,const char * put_old)
63         {
64                 return(syscall(__NR_pivot_root, new_root, put_old));
65         }
66 #  else
67     _syscall2(int,pivot_root,const char *,new_root,const char *,put_old);
68 #  endif
69 #endif
70
71
72
73
74 #if __GNU_LIBRARY__ < 5 || ((__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1))
75 /* These syscalls are not included as part of libc5 */
76 _syscall2(int, bdflush, int, func, int, data);
77
78 #ifndef __alpha__
79 # define __NR_klogctl __NR_syslog
80   _syscall3(int, klogctl, int, type, char *, b, int, len);
81 #endif
82
83 #ifndef __NR_umount2
84 # warning This kernel does not support the umount2 syscall
85 # warning -> The umount2 system call is being stubbed out...
86 int umount2(const char * special_file, int flags)
87 {
88         /* BusyBox was compiled against a kernel that did not support
89          *  the umount2 system call.  To make this application work,
90          *  you will need to recompile with a kernel supporting the
91          *  umount2 system call.
92          */
93         fprintf(stderr, "\n\nTo make this application work, you will need to recompile\n");
94         fprintf(stderr, "with a kernel supporting the umount2 system call. -Erik\n\n");
95         errno=ENOSYS;
96         return -1;
97 }
98 # else
99 _syscall2(int, umount2, const char *, special_file, int, flags);
100 #endif
101
102
103 #endif /* __GNU_LIBRARY__ < 5 */
104
105
106 /* END CODE */
107 /*
108 Local Variables:
109 c-file-style: "linux"
110 c-basic-offset: 4
111 tab-width: 4
112 End:
113 */