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);
148 if (smbw_local_fd(fd)) {
153 return real_close(fd);
171 return smbw_fchdir(fd);
187 int fcntl(int fd, int cmd, long arg)
190 return smbw_fcntl(fd, cmd, arg);
193 return real_fcntl(fd, cmd, arg);
198 int __fcntl(int fd, int cmd, long arg)
200 return fcntl(fd, cmd, arg);
203 int _fcntl(int fd, int cmd, long arg)
205 return fcntl(fd, cmd, arg);
212 int getdents(int fd, void *dirp, unsigned int count)
215 return smbw_getdents(fd, dirp, count);
218 return real_getdents(fd, dirp, count);
222 #ifdef HAVE___GETDENTS
223 int __getdents(int fd, void *dirp, unsigned int count)
225 return getdents(fd, dirp, count);
228 int _getdents(int fd, void *dirp, unsigned int count)
230 return getdents(fd, dirp, count);
235 off_t lseek(int fd, off_t offset, int whence)
238 return smbw_lseek(fd, offset, whence);
241 return real_lseek(fd, offset, whence);
245 off_t __lseek(int fd, off_t offset, int whence)
247 return lseek(fd, offset, whence);
250 off_t _lseek(int fd, off_t offset, int whence)
252 return lseek(fd, offset, whence);
257 ssize_t read(int fd, void *buf, size_t count)
260 return smbw_read(fd, buf, count);
263 return real_read(fd, buf, count);
267 ssize_t __read(int fd, void *buf, size_t count)
269 return read(fd, buf, count);
272 ssize_t _read(int fd, void *buf, size_t count)
274 return read(fd, buf, count);
279 ssize_t write(int fd, void *buf, size_t count)
282 return smbw_write(fd, buf, count);
285 return real_write(fd, buf, count);
289 ssize_t __write(int fd, void *buf, size_t count)
291 return write(fd, buf, count);
294 ssize_t _write(int fd, void *buf, size_t count)
296 return write(fd, buf, count);
302 int access(char *name, int mode)
304 if (smbw_path(name)) {
305 return smbw_access(name, mode);
308 return real_access(name, mode);
313 int chmod(char *name,mode_t mode)
315 if (smbw_path(name)) {
316 return smbw_chmod(name, mode);
319 return real_chmod(name, mode);
324 int chown(char *name,uid_t owner, gid_t group)
326 if (smbw_path(name)) {
327 return smbw_chown(name, owner, group);
330 return real_chown(name, owner, group);
334 char *getcwd(char *buf, size_t size)
336 return (char *)smbw_getcwd(buf, size);
342 int mkdir(char *name, mode_t mode)
344 if (smbw_path(name)) {
345 return smbw_mkdir(name, mode);
348 return real_mkdir(name, mode);
353 int __fxstat(int vers, int fd, void *st)
359 return smbw_fstat(fd, st);
362 ret = real_fstat(fd, xx);
363 xstat_convert(vers, st, xx);
369 int __xstat(int vers, char *name, void *st)
374 if (smbw_path(name)) {
375 return smbw_stat(name, st);
378 ret = real_stat(name, xx);
379 xstat_convert(vers, st, xx);
386 int __lxstat(int vers, char *name, void *st)
391 if (smbw_path(name)) {
392 return smbw_stat(name, st);
395 ret = real_lstat(name, xx);
396 xstat_convert(vers, st, xx);
402 int stat(char *name, void *st)
405 return __xstat(0, name, st);
407 if (smbw_path(name)) {
408 return smbw_stat(name, st);
410 return real_stat(name, st);
414 int lstat(char *name, void *st)
417 return __lxstat(0, name, st);
419 if (smbw_path(name)) {
420 return smbw_stat(name, st);
422 return real_lstat(name, st);
426 int fstat(int fd, void *st)
429 return __fxstat(0, fd, st);
432 return smbw_fstat(fd, st);
434 return real_fstat(fd, st);
439 int unlink(char *name)
441 if (smbw_path(name)) {
442 return smbw_unlink(name);
445 return real_unlink(name);
450 int utime(char *name,void *tvp)
452 if (smbw_path(name)) {
453 return smbw_utime(name, tvp);
456 return real_utime(name, tvp);
461 int utimes(char *name,void *tvp)
463 if (smbw_path(name)) {
464 return smbw_utimes(name, tvp);
467 return real_utimes(name, tvp);
471 int readlink(char *path, char *buf, size_t bufsize)
473 if (smbw_path(path)) {
474 return smbw_readlink(path, buf, bufsize);
477 return real_readlink(path, buf, bufsize);
481 int rename(char *oldname,char *newname)
484 p1 = smbw_path(oldname);
485 p2 = smbw_path(newname);
487 /* can't cross filesystem boundaries */
492 return smbw_rename(oldname, newname);
495 return real_rename(oldname, newname);
498 int rmdir(char *name)
500 if (smbw_path(name)) {
501 return smbw_rmdir(name);
504 return real_rmdir(name);
508 int symlink(char *topath,char *frompath)
511 p1 = smbw_path(topath);
512 p2 = smbw_path(frompath);
514 /* can't handle symlinks */
519 return real_symlink(topath, frompath);
531 int dup2(int oldfd, int newfd)
533 if (smbw_fd(newfd)) {
537 if (smbw_fd(oldfd)) {
538 return smbw_dup2(oldfd, newfd);
541 return real_dup2(oldfd, newfd);
545 void *opendir(char *name)
547 if (smbw_path(name)) {
548 return (void *)smbw_opendir(name);
551 return (void *)real_opendir(name);
556 void *readdir(void *dir)
558 if (smbw_dirp(dir)) {
559 return (void *)smbw_readdir(dir);
562 return (void *)real_readdir(dir);
567 int closedir(void *dir)
569 if (smbw_dirp(dir)) {
570 return smbw_closedir(dir);
573 return real_closedir(dir);
578 off_t telldir(void *dir)
580 if (smbw_dirp(dir)) {
581 return smbw_telldir(dir);
584 return real_telldir(dir);
589 int seekdir(void *dir, off_t offset)
591 if (smbw_dirp(dir)) {
592 smbw_seekdir(dir, offset);
596 real_seekdir(dir, offset);
602 #ifndef NO_ACL_WRAPPER
603 int acl(char *pathp, int cmd, int nentries, void *aclbufp)
605 if (smbw_path(pathp)) {
606 return smbw_acl(pathp, cmd, nentries, aclbufp);
609 return real_acl(pathp, cmd, nentries, aclbufp);
613 #ifndef NO_FACL_WRAPPER
614 int facl(int fd, int cmd, int nentries, void *aclbufp)
617 return smbw_facl(fd, cmd, nentries, aclbufp);
620 return real_facl(fd, cmd, nentries, aclbufp);
624 int creat(char *path, mode_t mode)
626 extern int creat_bits;
627 return open(path, creat_bits, mode);
631 int creat64(char *path, mode_t mode)
633 extern int creat_bits;
634 return open64(path, creat_bits, mode);
639 int stat64(char *name, void *st64)
641 if (smbw_path(name)) {
643 int ret = stat(name, xx);
644 stat64_convert(xx, st64);
647 return real_stat64(name, st64);
650 int fstat64(int fd, void *st64)
654 int ret = fstat(fd, xx);
655 stat64_convert(xx, st64);
658 return real_fstat64(fd, st64);
661 int lstat64(char *name, void *st64)
663 if (smbw_path(name)) {
665 int ret = lstat(name, xx);
666 stat64_convert(xx, st64);
669 return real_lstat64(name, st64);
674 offset_t llseek(int fd, offset_t ofs, int whence)
677 return lseek(fd, ofs, whence);
679 return real_llseek(fd, ofs, whence);
683 #ifdef HAVE_READDIR64
684 void *readdir64(void *dir)
686 if (smbw_dirp(dir)) {
687 static double xx[70];
689 d = (void *)readdir(dir);
690 if (!d) return (void *)0;
691 dirent64_convert(d, xx);
694 return (void *)real_readdir64(dir);