2 Unix SMB/Netbios implementation.
5 Copyright (C) Andrew Tridgell 1998
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.
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.
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.
22 /* NOTE: This file WILL produce compiler warnings. They are unavoidable
24 Do not try and get rid of them by including other include files or
25 by including includes.h or proto.h or you will break portability.
29 #include <sys/types.h>
31 #include "realcalls.h"
33 int open(char *name, int flags, mode_t mode)
35 if (smbw_path(name)) {
36 return smbw_open(name, flags, mode);
39 return real_open(name, flags, mode);
43 int _open(char *name, int flags, mode_t mode)
45 return open(name, flags, mode);
48 int __open(char *name, int flags, mode_t mode)
50 return open(name, flags, mode);
56 int open64(char *name, int flags, mode_t mode)
58 if (smbw_path(name)) {
59 return smbw_open(name, flags, mode);
62 return real_open64(name, flags, mode);
66 #ifndef NO_OPEN64_ALIAS
68 int _open64(char *name, int flags, mode_t mode)
70 return open64(name, flags, mode);
73 int __open64(char *name, int flags, mode_t mode)
75 return open64(name, flags, mode);
81 ssize_t pread(int fd, void *buf, size_t size, off_t ofs)
84 return smbw_pread(fd, buf, size, ofs);
87 return real_pread(fd, buf, size, ofs);
92 ssize_t pread64(int fd, void *buf, size_t size, off64_t ofs)
95 return smbw_pread(fd, buf, size, ofs);
98 return real_pread64(fd, buf, size, ofs);
103 ssize_t pwrite(int fd, void *buf, size_t size, off_t ofs)
106 return smbw_pwrite(fd, buf, size, ofs);
109 return real_pwrite(fd, buf, size, ofs);
114 ssize_t pwrite64(int fd, void *buf, size_t size, off64_t ofs)
117 return smbw_pwrite(fd, buf, size, ofs);
120 return real_pwrite64(fd, buf, size, ofs);
125 int chdir(char *name)
127 return smbw_chdir(name);
131 int __chdir(char *name)
136 int _chdir(char *name)
146 return smbw_close(fd);
149 return real_close(fd);
167 return smbw_fchdir(fd);
183 int fcntl(int fd, int cmd, long arg)
186 return smbw_fcntl(fd, cmd, arg);
189 return real_fcntl(fd, cmd, arg);
194 int __fcntl(int fd, int cmd, long arg)
196 return fcntl(fd, cmd, arg);
199 int _fcntl(int fd, int cmd, long arg)
201 return fcntl(fd, cmd, arg);
208 int getdents(int fd, void *dirp, unsigned int count)
211 return smbw_getdents(fd, dirp, count);
214 return real_getdents(fd, dirp, count);
218 #ifdef HAVE___GETDENTS
219 int __getdents(int fd, void *dirp, unsigned int count)
221 return getdents(fd, dirp, count);
224 int _getdents(int fd, void *dirp, unsigned int count)
226 return getdents(fd, dirp, count);
231 off_t lseek(int fd, off_t offset, int whence)
234 return smbw_lseek(fd, offset, whence);
237 return real_lseek(fd, offset, whence);
241 off_t __lseek(int fd, off_t offset, int whence)
243 return lseek(fd, offset, whence);
246 off_t _lseek(int fd, off_t offset, int whence)
248 return lseek(fd, offset, whence);
253 ssize_t read(int fd, void *buf, size_t count)
256 return smbw_read(fd, buf, count);
259 return real_read(fd, buf, count);
263 ssize_t __read(int fd, void *buf, size_t count)
265 return read(fd, buf, count);
268 ssize_t _read(int fd, void *buf, size_t count)
270 return read(fd, buf, count);
275 ssize_t write(int fd, void *buf, size_t count)
278 return smbw_write(fd, buf, count);
281 return real_write(fd, buf, count);
285 ssize_t __write(int fd, void *buf, size_t count)
287 return write(fd, buf, count);
290 ssize_t _write(int fd, void *buf, size_t count)
292 return write(fd, buf, count);
298 int access(char *name, int mode)
300 if (smbw_path(name)) {
301 return smbw_access(name, mode);
304 return real_access(name, mode);
309 int chmod(char *name,mode_t mode)
311 if (smbw_path(name)) {
312 return smbw_chmod(name, mode);
315 return real_chmod(name, mode);
320 int chown(char *name,uid_t owner, gid_t group)
322 if (smbw_path(name)) {
323 return smbw_chown(name, owner, group);
326 return real_chown(name, owner, group);
330 char *getcwd(char *buf, size_t size)
332 return (char *)smbw_getcwd(buf, size);
338 int mkdir(char *name, mode_t mode)
340 if (smbw_path(name)) {
341 return smbw_mkdir(name, mode);
344 return real_mkdir(name, mode);
349 int __fxstat(int vers, int fd, void *st)
355 return smbw_fstat(fd, st);
358 ret = real_fstat(fd, xx);
359 xstat_convert(vers, st, xx);
365 int __xstat(int vers, char *name, void *st)
370 if (smbw_path(name)) {
371 return smbw_stat(name, st);
374 ret = real_stat(name, xx);
375 xstat_convert(vers, st, xx);
382 int __lxstat(int vers, char *name, void *st)
387 if (smbw_path(name)) {
388 return smbw_stat(name, st);
391 ret = real_lstat(name, xx);
392 xstat_convert(vers, st, xx);
398 int stat(char *name, void *st)
401 return __xstat(0, name, st);
403 if (smbw_path(name)) {
404 return smbw_stat(name, st);
406 return real_stat(name, st);
410 int lstat(char *name, void *st)
413 return __lxstat(0, name, st);
415 if (smbw_path(name)) {
416 return smbw_stat(name, st);
418 return real_lstat(name, st);
422 int fstat(int fd, void *st)
425 return __fxstat(0, fd, st);
428 return smbw_fstat(fd, st);
430 return real_fstat(fd, st);
435 int unlink(char *name)
437 if (smbw_path(name)) {
438 return smbw_unlink(name);
441 return real_unlink(name);
446 int utime(char *name,void *tvp)
448 if (smbw_path(name)) {
449 return smbw_utime(name, tvp);
452 return real_utime(name, tvp);
457 int utimes(char *name,void *tvp)
459 if (smbw_path(name)) {
460 return smbw_utimes(name, tvp);
463 return real_utimes(name, tvp);
467 int readlink(char *path, char *buf, size_t bufsize)
469 if (smbw_path(path)) {
470 return smbw_readlink(path, buf, bufsize);
473 return real_readlink(path, buf, bufsize);
477 int rename(char *oldname,char *newname)
480 p1 = smbw_path(oldname);
481 p2 = smbw_path(newname);
483 /* can't cross filesystem boundaries */
488 return smbw_rename(oldname, newname);
491 return real_rename(oldname, newname);
494 int rmdir(char *name)
496 if (smbw_path(name)) {
497 return smbw_rmdir(name);
500 return real_rmdir(name);
504 int symlink(char *topath,char *frompath)
507 p1 = smbw_path(topath);
508 p2 = smbw_path(frompath);
510 /* can't handle symlinks */
515 return real_symlink(topath, frompath);
527 int dup2(int oldfd, int newfd)
529 if (smbw_fd(newfd)) {
533 if (smbw_fd(oldfd)) {
534 return smbw_dup2(oldfd, newfd);
537 return real_dup2(oldfd, newfd);
541 void *opendir(char *name)
543 if (smbw_path(name)) {
544 return (void *)smbw_opendir(name);
547 return (void *)real_opendir(name);
552 void *readdir(void *dir)
554 if (smbw_dirp(dir)) {
555 return (void *)smbw_readdir(dir);
558 return (void *)real_readdir(dir);
563 int closedir(void *dir)
565 if (smbw_dirp(dir)) {
566 return smbw_closedir(dir);
569 return real_closedir(dir);
574 off_t telldir(void *dir)
576 if (smbw_dirp(dir)) {
577 return smbw_telldir(dir);
580 return real_telldir(dir);
585 int seekdir(void *dir, off_t offset)
587 if (smbw_dirp(dir)) {
588 smbw_seekdir(dir, offset);
592 real_seekdir(dir, offset);
598 #ifndef NO_ACL_WRAPPER
599 int acl(char *pathp, int cmd, int nentries, void *aclbufp)
601 if (smbw_path(pathp)) {
602 return smbw_acl(pathp, cmd, nentries, aclbufp);
605 return real_acl(pathp, cmd, nentries, aclbufp);
609 #ifndef NO_FACL_WRAPPER
610 int facl(int fd, int cmd, int nentries, void *aclbufp)
613 return smbw_facl(fd, cmd, nentries, aclbufp);
616 return real_facl(fd, cmd, nentries, aclbufp);
620 int creat(char *path, mode_t mode)
622 extern int creat_bits;
623 return open(path, creat_bits, mode);
627 int creat64(char *path, mode_t mode)
629 extern int creat_bits;
630 return open64(path, creat_bits, mode);
635 int stat64(char *name, void *st64)
637 if (smbw_path(name)) {
639 int ret = stat(name, xx);
640 stat64_convert(xx, st64);
643 return real_stat64(name, st64);
646 int fstat64(int fd, void *st64)
650 int ret = fstat(fd, xx);
651 stat64_convert(xx, st64);
654 return real_fstat64(fd, st64);
657 int lstat64(char *name, void *st64)
659 if (smbw_path(name)) {
661 int ret = lstat(name, xx);
662 stat64_convert(xx, st64);
665 return real_lstat64(name, st64);
670 offset_t llseek(int fd, offset_t ofs, int whence)
673 return lseek(fd, ofs, whence);
675 return real_llseek(fd, ofs, whence);
679 #ifdef HAVE_READDIR64
680 void *readdir64(void *dir)
682 if (smbw_dirp(dir)) {
683 static double xx[70];
685 d = (void *)readdir(dir);
687 dirent64_convert(d, xx);
690 return (void *)real_readdir64(dir);