a38703ee7eabd67e8763c1e869fcd8ddf5d6a4d5
[kamenim/samba.git] / source3 / smbwrapper / realcalls.h
1 /* 
2    Unix SMB/Netbios implementation.
3    Version 2.0
4    defintions of syscall entries
5    Copyright (C) Andrew Tridgell 1998
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
15    GNU 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., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22 #if HAVE_SYS_SYSCALL_H
23 #include <sys/syscall.h>
24 #elif HAVE_SYSCALL_H
25 #include <syscall.h>
26 #endif
27
28 #ifdef IRIX
29 /* amazingly, IRIX gets its own syscall numbers wrong! */
30 #ifdef SYSVoffset
31 #if (SYSVoffset == 1)
32 #undef SYSVoffset
33 #define SYSVoffset 1000
34 #endif
35 #endif
36 #endif
37
38 /* this file is partly derived from zlibc by Alain Knaff */
39
40 #define real_access(fn, mode)           (syscall(SYS_access, (fn), (mode)))
41 #define real_chdir(fn)                  (syscall(SYS_chdir, (fn)))
42 #define real_chmod(fn, mode)            (syscall(SYS_chmod,(fn), (mode)))
43 #define real_chown(fn, owner, group)    (syscall(SYS_chown,(fn),(owner),(group)))
44
45 #ifdef SYS_getdents
46 #define real_getdents(fd, dirp, count)  (syscall(SYS_getdents, (fd), (dirp), (count)))
47 #endif
48
49 #define real_link(fn1, fn2)             (syscall(SYS_link, (fn1), (fn2)))
50
51 #define real_open(fn,flags,mode)        (syscall(SYS_open, (fn), (flags), (mode)))
52
53 #ifdef SYS_open64
54 #define real_open64(fn,flags,mode)      (syscall(SYS_open64, (fn), (flags), (mode)))
55 #elif HAVE__OPEN64
56 #define real_open64(fn,flags,mode)      (_open64(fn,flags,mode))
57 #define NO_OPEN64_ALIAS
58 #elif HAVE___OPEN64
59 #define real_open64(fn,flags,mode)      (__open64(fn,flags,mode))
60 #define NO_OPEN64_ALIAS
61 #else
62 #error No open64() wrapper
63 #endif
64
65 #ifdef HAVE__FORK
66 #define real_fork()             (_fork())
67 #elif HAVE___FORK
68 #define real_fork()             (__fork())
69 #elif SYS_fork
70 #define real_fork()             (syscall(SYS_fork))
71 #else
72 #error No fork() wrapper
73 #endif
74
75 #ifdef HAVE__OPENDIR
76 #define real_opendir(fn)                (_opendir(fn))
77 #elif SYS_opendir
78 #define real_opendir(fn)                (syscall(SYS_opendir,(fn)))
79 #elif HAVE___OPENDIR
80 #define real_opendir(fn)                (__opendir(fn))
81 #else
82 #error No opendir() wrapper
83 #endif
84
85 #ifdef HAVE__READDIR
86 #define real_readdir(d)                 (_readdir(d))
87 #elif HAVE___READDIR
88 #define real_readdir(d)                 (__readdir(d))
89 #elif SYS_readdir
90 #define real_readdir(d)         (syscall(SYS_readdir,(d)))
91 #else
92 #error No readdir() wrapper
93 #endif
94
95 #ifdef HAVE__CLOSEDIR
96 #define real_closedir(d)                (_closedir(d))
97 #elif SYS_closedir
98 #define real_closedir(d)                (syscall(SYS_closedir,(d)))
99 #elif HAVE___CLOSEDIR
100 #define real_closedir(d)                (__closedir(d))
101 #else
102 #error No closedir() wrapper
103 #endif
104
105 #ifdef HAVE__SEEKDIR
106 #define real_seekdir(d,l)               (_seekdir(d,l))
107 #elif SYS_seekdir
108 #define real_seekdir(d,l)               (syscall(SYS_seekdir,(d),(l)))
109 #elif HAVE___SEEKDIR
110 #define real_seekdir(d,l)               (__seekdir(d,l))
111 #else
112 #define NO_SEEKDIR_WRAPPER
113 #error No seekdir() wrapper
114 #endif
115
116 #ifdef HAVE__TELLDIR
117 #define real_telldir(d)                 (_telldir(d))
118 #elif SYS_telldir
119 #define real_telldir(d)         (syscall(SYS_telldir,(d)))
120 #elif HAVE___TELLDIR
121 #define real_telldir(d)                 (__telldir(d))
122 #else
123 #error No telldir() wrapper
124 #endif
125
126 #ifdef HAVE__DUP
127 #define real_dup(d)             (_dup(d))
128 #elif SYS_dup
129 #define real_dup(d)             (syscall(SYS_dup,(d)))
130 #elif HAVE___DUP
131 #define real_dup(d)             (__dup(d))
132 #else
133 #error No dup() wrapper
134 #endif
135
136 #ifdef HAVE__DUP2
137 #define real_dup2(d1,d2)                (_dup2(d1,d2))
138 #elif SYS_dup2
139 #define real_dup2(d1,d2)                (syscall(SYS_dup2,(d1),(d2)))
140 #elif HAVE___DUP2
141 #define real_dup2(d1,d2)                (__dup2(d1,d2))
142 #else
143 #error No dup2() wrapper
144 #endif
145
146 #ifdef HAVE__GETCWD
147 #define real_getcwd(b,s)                ((char *)_getcwd(b,s))
148 #elif SYS_getcwd
149 #define real_getcwd(b,s)                ((char *)syscall(SYS_getcwd,(b),(s)))
150 #elif HAVE___GETCWD
151 #define real_getcwd(b,s)                ((char *)__getcwd(b,s))
152 #else
153 #error No getcwd() wrapper
154 #endif
155
156 #ifdef HAVE__STAT
157 #define real_stat(fn,st)                (_stat(fn,st))
158 #elif SYS_stat
159 #define real_stat(fn,st)                (syscall(SYS_stat,(fn),(st)))
160 #elif HAVE___STAT
161 #define real_stat(fn,st)                (__stat(fn,st))
162 #else
163 #error No stat() wrapper
164 #endif
165
166 #ifdef HAVE__LSTAT
167 #define real_lstat(fn,st)               (_lstat(fn,st))
168 #elif SYS_lstat
169 #define real_lstat(fn,st)               (syscall(SYS_lstat,(fn),(st)))
170 #elif HAVE___LSTAT
171 #define real_lstat(fn,st)               (__lstat(fn,st))
172 #else
173 #error No lstat() wrapper
174 #endif
175
176 #ifdef HAVE__FSTAT
177 #define real_fstat(fd,st)               (_fstat(fd,st))
178 #elif SYS_fstat
179 #define real_fstat(fd,st)               (syscall(SYS_fstat,(fd),(st)))
180 #elif HAVE___FSTAT
181 #define real_fstat(fd,st)               (__fstat(fd,st))
182 #else
183 #error No fstat() wrapper
184 #endif
185
186 #if defined(HAVE_SYS_ACL_H) && defined(HAVE__ACL)
187 #define real_acl(fn,cmd,n,buf)                  (_acl(fn,cmd,n,buf))
188 #elif SYS_acl
189 #define real_acl(fn,cmd,n,buf)          (syscall(SYS_acl,(fn),(cmd),(n),(buf)))
190 #elif HAVE___ACL
191 #define real_acl(fn,cmd,n,buf)                  (__acl(fn,cmd,n,buf))
192 #else
193 #define NO_ACL_WRAPPER
194 #endif
195
196 #ifdef HAVE__FACL
197 #define real_facl(fd,cmd,n,buf)                 (_facl(fd,cmd,n,buf))
198 #elif SYS_facl
199 #define real_facl(fd,cmd,n,buf)         (syscall(SYS_facl,(fd),(cmd),(n),(buf)))
200 #elif HAVE___FACL
201 #define real_facl(fd,cmd,n,buf)                 (__facl(fd,cmd,n,buf))
202 #else
203 #define NO_FACL_WRAPPER
204 #endif
205
206
207 #ifdef HAVE__STAT64
208 #define real_stat64(fn,st)              (_stat64(fn,st))
209 #elif HAVE___STAT64
210 #define real_stat64(fn,st)              (__stat64(fn,st))
211 #else
212 #error No stat64() wrapper
213 #endif
214
215 #ifdef HAVE__LSTAT64
216 #define real_lstat64(fn,st)             (_lstat64(fn,st))
217 #elif HAVE___LSTAT64
218 #define real_lstat64(fn,st)             (__lstat64(fn,st))
219 #else
220 #error No lstat64() wrapper
221 #endif
222
223 #ifdef HAVE__FSTAT64
224 #define real_fstat64(fd,st)             (_fstat64(fd,st))
225 #elif HAVE___FSTAT64
226 #define real_fstat64(fd,st)             (__fstat64(fd,st))
227 #else
228 #error No fstat64() wrapper
229 #endif
230
231 #ifdef HAVE__READDIR64
232 #define real_readdir64(d)               (_readdir64(d))
233 #elif HAVE___READDIR64
234 #define real_readdir64(d)               (__readdir64(d))
235 #else
236 #error No readdir64() wrapper
237 #endif
238
239 #ifdef HAVE__LLSEEK
240 #define real_llseek(fd,ofs,whence)              (_llseek(fd,ofs,whence))
241 #elif HAVE___LLSEEK
242 #define real_llseek(fd,ofs,whence)              (__llseek(fd,ofs,whence))
243 #elif HAVE___SYS_LLSEEK
244 #define real_llseek(fd,ofs,whence)              (__sys_llseek(fd,ofs,whence))
245 #else
246 #error No llseek() wrapper
247 #endif
248
249
250 #ifdef HAVE__PREAD
251 #define real_pread(fd,buf,size,ofs)             (_pread(fd,buf,size,ofs))
252 #elif HAVE___PREAD
253 #define real_pread(fd,buf,size,ofs)             (__pread(fd,buf,size,ofs))
254 #else
255 #error No pread() wrapper
256 #endif
257
258 #ifdef HAVE__PREAD64
259 #define real_pread64(fd,buf,size,ofs)                   (_pread64(fd,buf,size,ofs))
260 #elif HAVE___PREAD64
261 #define real_pread64(fd,buf,size,ofs)                   (__pread64(fd,buf,size,ofs))
262 #else
263 #error No pread64() wrapper
264 #endif
265
266 #ifdef HAVE__PWRITE
267 #define real_pwrite(fd,buf,size,ofs)                    (_pwrite(fd,buf,size,ofs))
268 #elif HAVE___PWRITE
269 #define real_pwrite(fd,buf,size,ofs)                    (__pwrite(fd,buf,size,ofs))
270 #else
271 #error No pwrite() wrapper
272 #endif
273
274 #ifdef HAVE__PWRITE64
275 #define real_pwrite64(fd,buf,size,ofs)                  (_pwrite64(fd,buf,size,ofs))
276 #elif HAVE___PWRITE64
277 #define real_pwrite64(fd,buf,size,ofs)                  (__pwrite64(fd,buf,size,ofs))
278 #else
279 #error No pwrite64() wrapper
280 #endif
281
282
283 #define real_readlink(fn,buf,len)       (syscall(SYS_readlink, (fn), (buf), (len)))
284 #define real_rename(fn1, fn2)           (syscall(SYS_rename, (fn1), (fn2)))
285 #define real_symlink(fn1, fn2)          (syscall(SYS_symlink, (fn1), (fn2)))
286 #define real_read(fd, buf, count )      (syscall(SYS_read, (fd), (buf), (count)))
287 #define real_lseek(fd, offset, whence)  (syscall(SYS_lseek, (fd), (offset), (whence)))
288 #define real_write(fd, buf, count )     (syscall(SYS_write, (fd), (buf), (count)))
289 #define real_close(fd)                  (syscall(SYS_close, (fd)))
290 #define real_fchdir(fd)                 (syscall(SYS_fchdir, (fd)))
291 #define real_fcntl(fd,cmd,arg)          (syscall(SYS_fcntl, (fd), (cmd), (arg)))
292 #define real_symlink(fn1, fn2)          (syscall(SYS_symlink, (fn1), (fn2)))
293 #define real_unlink(fn)                 (syscall(SYS_unlink, (fn)))
294 #define real_rmdir(fn)                  (syscall(SYS_rmdir, (fn)))
295 #define real_mkdir(fn, mode)            (syscall(SYS_mkdir, (fn), (mode)))
296
297 #ifdef SYS_utime
298 #define real_utime(fn, buf)             (syscall(SYS_utime, (fn), (buf)))
299 #else
300 #define REPLACE_UTIME 1
301 #endif
302
303 #ifdef SYS_utimes
304 #define real_utimes(fn, buf)            (syscall(SYS_utimes, (fn), (buf)))
305 #else
306 #define REPLACE_UTIMES 1
307 #endif