2 Unix SMB/CIFS implementation.
4 Copyright (C) Andrew Tridgell 1998
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.
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.
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.
21 /* NOTE: This file WILL produce compiler warnings. They are unavoidable
23 Do not try and get rid of them by including other include files or
24 by including includes.h or proto.h or you will break portability.
28 #include <sys/types.h>
30 #include "realcalls.h"
33 # define NULL ((void *)0)
36 int open(char *name
, int flags
, mode_t mode
)
38 if (smbw_path(name
)) {
39 return smbw_open(name
, flags
, mode
);
42 return real_open(name
, flags
, mode
);
46 int _open(char *name
, int flags
, mode_t mode
)
48 return open(name
, flags
, mode
);
51 int __open(char *name
, int flags
, mode_t mode
)
53 return open(name
, flags
, mode
);
59 int open64(char *name
, int flags
, mode_t mode
)
61 if (smbw_path(name
)) {
62 return smbw_open(name
, flags
, mode
);
65 return real_open64(name
, flags
, mode
);
69 #ifndef NO_OPEN64_ALIAS
71 int _open64(char *name
, int flags
, mode_t mode
)
73 return open64(name
, flags
, mode
);
76 int __open64(char *name
, int flags
, mode_t mode
)
78 return open64(name
, flags
, mode
);
84 ssize_t
pread(int fd
, void *buf
, size_t size
, off_t ofs
)
87 return smbw_pread(fd
, buf
, size
, ofs
);
90 return real_pread(fd
, buf
, size
, ofs
);
94 #if defined(HAVE_PREAD64) && defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT)
95 ssize_t
pread64(int fd
, void *buf
, size_t size
, off64_t ofs
)
98 return smbw_pread(fd
, buf
, size
, ofs
);
101 return real_pread64(fd
, buf
, size
, ofs
);
106 ssize_t
pwrite(int fd
, void *buf
, size_t size
, off_t ofs
)
109 return smbw_pwrite(fd
, buf
, size
, ofs
);
112 return real_pwrite(fd
, buf
, size
, ofs
);
116 #if defined(HAVE_PWRITE64) && defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT)
117 ssize_t
pwrite64(int fd
, void *buf
, size_t size
, off64_t ofs
)
120 return smbw_pwrite(fd
, buf
, size
, ofs
);
123 return real_pwrite64(fd
, buf
, size
, ofs
);
128 int chdir(char *name
)
130 return smbw_chdir(name
);
134 int __chdir(char *name
)
139 int _chdir(char *name
)
149 return smbw_close(fd
);
151 if (smbw_local_fd(fd
)) {
156 return real_close(fd
);
174 return smbw_fchdir(fd
);
190 int fcntl(int fd
, int cmd
, long arg
)
193 return smbw_fcntl(fd
, cmd
, arg
);
196 return real_fcntl(fd
, cmd
, arg
);
201 int __fcntl(int fd
, int cmd
, long arg
)
203 return fcntl(fd
, cmd
, arg
);
206 int _fcntl(int fd
, int cmd
, long arg
)
208 return fcntl(fd
, cmd
, arg
);
215 int getdents(int fd
, void *dirp
, unsigned int count
)
218 return smbw_getdents(fd
, dirp
, count
);
221 return real_getdents(fd
, dirp
, count
);
225 #ifdef HAVE___GETDENTS
226 int __getdents(int fd
, void *dirp
, unsigned int count
)
228 return getdents(fd
, dirp
, count
);
231 int _getdents(int fd
, void *dirp
, unsigned int count
)
233 return getdents(fd
, dirp
, count
);
238 off_t
lseek(int fd
, off_t offset
, int whence
)
241 return smbw_lseek(fd
, offset
, whence
);
244 return real_lseek(fd
, offset
, whence
);
248 off_t
__lseek(int fd
, off_t offset
, int whence
)
250 return lseek(fd
, offset
, whence
);
253 off_t
_lseek(int fd
, off_t offset
, int whence
)
255 return lseek(fd
, offset
, whence
);
260 ssize_t
read(int fd
, void *buf
, size_t count
)
263 return smbw_read(fd
, buf
, count
);
266 return real_read(fd
, buf
, count
);
270 ssize_t
__read(int fd
, void *buf
, size_t count
)
272 return read(fd
, buf
, count
);
275 ssize_t
_read(int fd
, void *buf
, size_t count
)
277 return read(fd
, buf
, count
);
282 ssize_t
write(int fd
, void *buf
, size_t count
)
285 return smbw_write(fd
, buf
, count
);
288 return real_write(fd
, buf
, count
);
292 ssize_t
__write(int fd
, void *buf
, size_t count
)
294 return write(fd
, buf
, count
);
297 ssize_t
_write(int fd
, void *buf
, size_t count
)
299 return write(fd
, buf
, count
);
305 int access(char *name
, int mode
)
307 if (smbw_path(name
)) {
308 return smbw_access(name
, mode
);
311 return real_access(name
, mode
);
316 int chmod(char *name
,mode_t mode
)
318 if (smbw_path(name
)) {
319 return smbw_chmod(name
, mode
);
322 return real_chmod(name
, mode
);
327 int chown(char *name
,uid_t owner
, gid_t group
)
329 if (smbw_path(name
)) {
330 return smbw_chown(name
, owner
, group
);
333 return real_chown(name
, owner
, group
);
337 char *getcwd(char *buf
, size_t size
)
339 return (char *)smbw_getcwd(buf
, size
);
345 int mkdir(char *name
, mode_t mode
)
347 if (smbw_path(name
)) {
348 return smbw_mkdir(name
, mode
);
351 return real_mkdir(name
, mode
);
356 int __fxstat(int vers
, int fd
, void *st
)
362 return smbw_fstat(fd
, st
);
365 ret
= real_fstat(fd
, xx
);
366 xstat_convert(vers
, st
, xx
);
372 int __xstat(int vers
, char *name
, void *st
)
377 if (smbw_path(name
)) {
378 return smbw_stat(name
, st
);
381 ret
= real_stat(name
, xx
);
382 xstat_convert(vers
, st
, xx
);
389 int __lxstat(int vers
, char *name
, void *st
)
394 if (smbw_path(name
)) {
395 return smbw_stat(name
, st
);
398 ret
= real_lstat(name
, xx
);
399 xstat_convert(vers
, st
, xx
);
405 int stat(char *name
, void *st
)
408 return __xstat(0, name
, st
);
410 if (smbw_path(name
)) {
411 return smbw_stat(name
, st
);
413 return real_stat(name
, st
);
417 int lstat(char *name
, void *st
)
420 return __lxstat(0, name
, st
);
422 if (smbw_path(name
)) {
423 return smbw_stat(name
, st
);
425 return real_lstat(name
, st
);
429 int fstat(int fd
, void *st
)
432 return __fxstat(0, fd
, st
);
435 return smbw_fstat(fd
, st
);
437 return real_fstat(fd
, st
);
442 int unlink(char *name
)
444 if (smbw_path(name
)) {
445 return smbw_unlink(name
);
448 return real_unlink(name
);
453 int utime(char *name
,void *tvp
)
455 if (smbw_path(name
)) {
456 return smbw_utime(name
, tvp
);
459 return real_utime(name
, tvp
);
464 int utimes(const char *name
, const struct timeval
*tvp
)
466 if (smbw_path(name
)) {
467 return smbw_utimes(name
, tvp
);
470 return real_utimes(name
, tvp
);
474 int readlink(char *path
, char *buf
, size_t bufsize
)
476 if (smbw_path(path
)) {
477 return smbw_readlink(path
, buf
, bufsize
);
480 return real_readlink(path
, buf
, bufsize
);
484 int rename(char *oldname
,char *newname
)
487 p1
= smbw_path(oldname
);
488 p2
= smbw_path(newname
);
490 /* can't cross filesystem boundaries */
495 return smbw_rename(oldname
, newname
);
498 return real_rename(oldname
, newname
);
501 int rmdir(char *name
)
503 if (smbw_path(name
)) {
504 return smbw_rmdir(name
);
507 return real_rmdir(name
);
511 int symlink(char *topath
,char *frompath
)
514 p1
= smbw_path(topath
);
515 p2
= smbw_path(frompath
);
517 /* can't handle symlinks */
522 return real_symlink(topath
, frompath
);
534 int dup2(int oldfd
, int newfd
)
536 if (smbw_fd(newfd
)) {
540 if (smbw_fd(oldfd
)) {
541 return smbw_dup2(oldfd
, newfd
);
544 return real_dup2(oldfd
, newfd
);
548 void *opendir(char *name
)
550 if (smbw_path(name
)) {
551 return (void *)smbw_opendir(name
);
554 return (void *)real_opendir(name
);
559 void *readdir(void *dir
)
561 if (smbw_dirp(dir
)) {
562 return (void *)smbw_readdir(dir
);
565 return (void *)real_readdir(dir
);
570 int closedir(void *dir
)
572 if (smbw_dirp(dir
)) {
573 return smbw_closedir(dir
);
576 return real_closedir(dir
);
581 off_t
telldir(void *dir
)
583 if (smbw_dirp(dir
)) {
584 return smbw_telldir(dir
);
587 return real_telldir(dir
);
592 int seekdir(void *dir
, off_t offset
)
594 if (smbw_dirp(dir
)) {
595 smbw_seekdir(dir
, offset
);
599 real_seekdir(dir
, offset
);
605 #ifndef NO_ACL_WRAPPER
606 int acl(char *pathp
, int cmd
, int nentries
, void *aclbufp
)
608 if (smbw_path(pathp
)) {
609 return smbw_acl(pathp
, cmd
, nentries
, aclbufp
);
612 return real_acl(pathp
, cmd
, nentries
, aclbufp
);
616 #ifndef NO_FACL_WRAPPER
617 int facl(int fd
, int cmd
, int nentries
, void *aclbufp
)
620 return smbw_facl(fd
, cmd
, nentries
, aclbufp
);
623 return real_facl(fd
, cmd
, nentries
, aclbufp
);
627 int creat(char *path
, mode_t mode
)
629 extern int creat_bits
;
630 return open(path
, creat_bits
, mode
);
634 int creat64(char *path
, mode_t mode
)
636 extern int creat_bits
;
637 return open64(path
, creat_bits
, mode
);
642 int stat64(char *name
, void *st64
)
644 if (smbw_path(name
)) {
646 int ret
= stat(name
, xx
);
647 stat64_convert(xx
, st64
);
650 return real_stat64(name
, st64
);
653 int fstat64(int fd
, void *st64
)
657 int ret
= fstat(fd
, xx
);
658 stat64_convert(xx
, st64
);
661 return real_fstat64(fd
, st64
);
664 int lstat64(char *name
, void *st64
)
666 if (smbw_path(name
)) {
668 int ret
= lstat(name
, xx
);
669 stat64_convert(xx
, st64
);
672 return real_lstat64(name
, st64
);
677 offset_t
llseek(int fd
, offset_t ofs
, int whence
)
680 return lseek(fd
, ofs
, whence
);
682 return real_llseek(fd
, ofs
, whence
);
686 #ifdef HAVE_READDIR64
687 void *readdir64(void *dir
)
689 if (smbw_dirp(dir
)) {
690 static double xx
[70];
692 d
= (void *)readdir(dir
);
694 dirent64_convert(d
, xx
);
697 return (void *)real_readdir64(dir
);