first public release of samba4 code
[samba.git] / source4 / smbwrapper / realcalls.h
1 /* 
2    Unix SMB/CIFS implementation.
3    defintions of syscall entries
4    Copyright (C) Andrew Tridgell 1998
5    
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10    
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15    
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 #if HAVE_SYS_SYSCALL_H
22 #include <sys/syscall.h>
23 #elif HAVE_SYSCALL_H
24 #include <syscall.h>
25 #endif
26
27 #ifdef IRIX
28 /* amazingly, IRIX gets its own syscall numbers wrong! */
29 #ifdef SYSVoffset
30 #if (SYSVoffset == 1)
31 #undef SYSVoffset
32 #define SYSVoffset 1000
33 #endif
34 #endif
35 #endif
36
37 /* this file is partly derived from zlibc by Alain Knaff */
38
39 #define real_access(fn, mode)           (syscall(SYS_access, (fn), (mode)))
40 #define real_chdir(fn)                  (syscall(SYS_chdir, (fn)))
41 #define real_chmod(fn, mode)            (syscall(SYS_chmod,(fn), (mode)))
42 #define real_chown(fn, owner, group)    (syscall(SYS_chown,(fn),(owner),(group)))
43
44 #ifdef SYS_getdents
45 #define real_getdents(fd, dirp, count)  (syscall(SYS_getdents, (fd), (dirp), (count)))
46 #endif
47
48 #define real_link(fn1, fn2)             (syscall(SYS_link, (fn1), (fn2)))
49
50 #define real_open(fn,flags,mode)        (syscall(SYS_open, (fn), (flags), (mode)))
51
52 #ifdef SYS_open64
53 #define real_open64(fn,flags,mode)      (syscall(SYS_open64, (fn), (flags), (mode)))
54 #elif HAVE__OPEN64
55 #define real_open64(fn,flags,mode)      (_open64(fn,flags,mode))
56 #define NO_OPEN64_ALIAS
57 #elif HAVE___OPEN64
58 #define real_open64(fn,flags,mode)      (__open64(fn,flags,mode))
59 #define NO_OPEN64_ALIAS
60 #endif
61
62 #ifdef HAVE__FORK
63 #define real_fork()             (_fork())
64 #elif HAVE___FORK
65 #define real_fork()             (__fork())
66 #elif SYS_fork
67 #define real_fork()             (syscall(SYS_fork))
68 #endif
69
70 #ifdef HAVE__OPENDIR
71 #define real_opendir(fn)                (_opendir(fn))
72 #elif SYS_opendir
73 #define real_opendir(fn)                (syscall(SYS_opendir,(fn)))
74 #elif HAVE___OPENDIR
75 #define real_opendir(fn)                (__opendir(fn))
76 #endif
77
78 #ifdef HAVE__READDIR
79 #define real_readdir(d)                 (_readdir(d))
80 #elif HAVE___READDIR
81 #define real_readdir(d)                 (__readdir(d))
82 #elif SYS_readdir
83 #define real_readdir(d)         (syscall(SYS_readdir,(d)))
84 #endif
85
86 #ifdef HAVE__CLOSEDIR
87 #define real_closedir(d)                (_closedir(d))
88 #elif SYS_closedir
89 #define real_closedir(d)                (syscall(SYS_closedir,(d)))
90 #elif HAVE___CLOSEDIR
91 #define real_closedir(d)                (__closedir(d))
92 #endif
93
94 #ifdef HAVE__SEEKDIR
95 #define real_seekdir(d,l)               (_seekdir(d,l))
96 #elif SYS_seekdir
97 #define real_seekdir(d,l)               (syscall(SYS_seekdir,(d),(l)))
98 #elif HAVE___SEEKDIR
99 #define real_seekdir(d,l)               (__seekdir(d,l))
100 #else
101 #define NO_SEEKDIR_WRAPPER
102 #endif
103
104 #ifdef HAVE__TELLDIR
105 #define real_telldir(d)                 (_telldir(d))
106 #elif SYS_telldir
107 #define real_telldir(d)         (syscall(SYS_telldir,(d)))
108 #elif HAVE___TELLDIR
109 #define real_telldir(d)                 (__telldir(d))
110 #endif
111
112 #ifdef HAVE__DUP
113 #define real_dup(d)             (_dup(d))
114 #elif SYS_dup
115 #define real_dup(d)             (syscall(SYS_dup,(d)))
116 #elif HAVE___DUP
117 #define real_dup(d)             (__dup(d))
118 #endif
119
120 #ifdef HAVE__DUP2
121 #define real_dup2(d1,d2)                (_dup2(d1,d2))
122 #elif SYS_dup2
123 #define real_dup2(d1,d2)                (syscall(SYS_dup2,(d1),(d2)))
124 #elif HAVE___DUP2
125 #define real_dup2(d1,d2)                (__dup2(d1,d2))
126 #endif
127
128 #ifdef HAVE__GETCWD
129 #define real_getcwd(b,s)                ((char *)_getcwd(b,s))
130 #elif SYS_getcwd
131 #define real_getcwd(b,s)                ((char *)syscall(SYS_getcwd,(b),(s)))
132 #elif HAVE___GETCWD
133 #define real_getcwd(b,s)                ((char *)__getcwd(b,s))
134 #endif
135
136 #ifdef HAVE__STAT
137 #define real_stat(fn,st)                (_stat(fn,st))
138 #elif SYS_stat
139 #define real_stat(fn,st)                (syscall(SYS_stat,(fn),(st)))
140 #elif HAVE___STAT
141 #define real_stat(fn,st)                (__stat(fn,st))
142 #endif
143
144 #ifdef HAVE__LSTAT
145 #define real_lstat(fn,st)               (_lstat(fn,st))
146 #elif SYS_lstat
147 #define real_lstat(fn,st)               (syscall(SYS_lstat,(fn),(st)))
148 #elif HAVE___LSTAT
149 #define real_lstat(fn,st)               (__lstat(fn,st))
150 #endif
151
152 #ifdef HAVE__FSTAT
153 #define real_fstat(fd,st)               (_fstat(fd,st))
154 #elif SYS_fstat
155 #define real_fstat(fd,st)               (syscall(SYS_fstat,(fd),(st)))
156 #elif HAVE___FSTAT
157 #define real_fstat(fd,st)               (__fstat(fd,st))
158 #endif
159
160 #if defined(HAVE_SYS_ACL_H) && defined(HAVE__ACL)
161 #define real_acl(fn,cmd,n,buf)                  (_acl(fn,cmd,n,buf))
162 #elif SYS_acl
163 #define real_acl(fn,cmd,n,buf)          (syscall(SYS_acl,(fn),(cmd),(n),(buf)))
164 #elif HAVE___ACL
165 #define real_acl(fn,cmd,n,buf)                  (__acl(fn,cmd,n,buf))
166 #else
167 #define NO_ACL_WRAPPER
168 #endif
169
170 #ifdef HAVE__FACL
171 #define real_facl(fd,cmd,n,buf)                 (_facl(fd,cmd,n,buf))
172 #elif SYS_facl
173 #define real_facl(fd,cmd,n,buf)         (syscall(SYS_facl,(fd),(cmd),(n),(buf)))
174 #elif HAVE___FACL
175 #define real_facl(fd,cmd,n,buf)                 (__facl(fd,cmd,n,buf))
176 #else
177 #define NO_FACL_WRAPPER
178 #endif
179
180
181 #ifdef HAVE__STAT64
182 #define real_stat64(fn,st)              (_stat64(fn,st))
183 #elif HAVE___STAT64
184 #define real_stat64(fn,st)              (__stat64(fn,st))
185 #endif
186
187 #ifdef HAVE__LSTAT64
188 #define real_lstat64(fn,st)             (_lstat64(fn,st))
189 #elif HAVE___LSTAT64
190 #define real_lstat64(fn,st)             (__lstat64(fn,st))
191 #endif
192
193 #ifdef HAVE__FSTAT64
194 #define real_fstat64(fd,st)             (_fstat64(fd,st))
195 #elif HAVE___FSTAT64
196 #define real_fstat64(fd,st)             (__fstat64(fd,st))
197 #endif
198
199 #ifdef HAVE__READDIR64
200 #define real_readdir64(d)               (_readdir64(d))
201 #elif HAVE___READDIR64
202 #define real_readdir64(d)               (__readdir64(d))
203 #endif
204
205 #ifdef HAVE__LLSEEK
206 #define real_llseek(fd,ofs,whence)              (_llseek(fd,ofs,whence))
207 #elif HAVE___LLSEEK
208 #define real_llseek(fd,ofs,whence)              (__llseek(fd,ofs,whence))
209 #elif HAVE___SYS_LLSEEK
210 #define real_llseek(fd,ofs,whence)              (__sys_llseek(fd,ofs,whence))
211 #endif
212
213
214 #ifdef HAVE__PREAD
215 #define real_pread(fd,buf,size,ofs)             (_pread(fd,buf,size,ofs))
216 #elif HAVE___PREAD
217 #define real_pread(fd,buf,size,ofs)             (__pread(fd,buf,size,ofs))
218 #endif
219
220 #ifdef HAVE__PREAD64
221 #define real_pread64(fd,buf,size,ofs)                   (_pread64(fd,buf,size,ofs))
222 #elif HAVE___PREAD64
223 #define real_pread64(fd,buf,size,ofs)                   (__pread64(fd,buf,size,ofs))
224 #endif
225
226 #ifdef HAVE__PWRITE
227 #define real_pwrite(fd,buf,size,ofs)                    (_pwrite(fd,buf,size,ofs))
228 #elif HAVE___PWRITE
229 #define real_pwrite(fd,buf,size,ofs)                    (__pwrite(fd,buf,size,ofs))
230 #endif
231
232 #ifdef HAVE__PWRITE64
233 #define real_pwrite64(fd,buf,size,ofs)                  (_pwrite64(fd,buf,size,ofs))
234 #elif HAVE___PWRITE64
235 #define real_pwrite64(fd,buf,size,ofs)                  (__pwrite64(fd,buf,size,ofs))
236 #endif
237
238
239 #define real_readlink(fn,buf,len)       (syscall(SYS_readlink, (fn), (buf), (len)))
240 #define real_rename(fn1, fn2)           (syscall(SYS_rename, (fn1), (fn2)))
241 #define real_symlink(fn1, fn2)          (syscall(SYS_symlink, (fn1), (fn2)))
242 #define real_read(fd, buf, count )      (syscall(SYS_read, (fd), (buf), (count)))
243 #define real_lseek(fd, offset, whence)  (syscall(SYS_lseek, (fd), (offset), (whence)))
244 #define real_write(fd, buf, count )     (syscall(SYS_write, (fd), (buf), (count)))
245 #define real_close(fd)                  (syscall(SYS_close, (fd)))
246 #define real_fchdir(fd)                 (syscall(SYS_fchdir, (fd)))
247 #define real_fcntl(fd,cmd,arg)          (syscall(SYS_fcntl, (fd), (cmd), (arg)))
248 #define real_symlink(fn1, fn2)          (syscall(SYS_symlink, (fn1), (fn2)))
249 #define real_unlink(fn)                 (syscall(SYS_unlink, (fn)))
250 #define real_rmdir(fn)                  (syscall(SYS_rmdir, (fn)))
251 #define real_mkdir(fn, mode)            (syscall(SYS_mkdir, (fn), (mode)))
252
253 #ifdef SYS_utime
254 #define real_utime(fn, buf)             (syscall(SYS_utime, (fn), (buf)))
255 #else
256 #define REPLACE_UTIME 1
257 #endif
258
259 #ifdef SYS_utimes
260 #define real_utimes(fn, buf)            (syscall(SYS_utimes, (fn), (buf)))
261 #else
262 #define REPLACE_UTIMES 1
263 #endif