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"
34 # define NULL ((void *)0)
37 int open(char *name, int flags, mode_t mode)
39 if (smbw_path(name)) {
40 return smbw_open(name, flags, mode);
43 return real_open(name, flags, mode);
47 int _open(char *name, int flags, mode_t mode)
49 return open(name, flags, mode);
52 int __open(char *name, int flags, mode_t mode)
54 return open(name, flags, mode);
60 int open64(char *name, int flags, mode_t mode)
62 if (smbw_path(name)) {
63 return smbw_open(name, flags, mode);
66 return real_open64(name, flags, mode);
70 #ifndef NO_OPEN64_ALIAS
72 int _open64(char *name, int flags, mode_t mode)
74 return open64(name, flags, mode);
77 int __open64(char *name, int flags, mode_t mode)
79 return open64(name, flags, mode);
85 ssize_t pread(int fd, void *buf, size_t size, off_t ofs)
88 return smbw_pread(fd, buf, size, ofs);
91 return real_pread(fd, buf, size, ofs);
95 #if defined(HAVE_PREAD64) && defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT)
96 ssize_t pread64(int fd, void *buf, size_t size, off64_t ofs)
99 return smbw_pread(fd, buf, size, ofs);
102 return real_pread64(fd, buf, size, ofs);
107 ssize_t pwrite(int fd, void *buf, size_t size, off_t ofs)
110 return smbw_pwrite(fd, buf, size, ofs);
113 return real_pwrite(fd, buf, size, ofs);
117 #if defined(HAVE_PWRITE64) && defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT)
118 ssize_t pwrite64(int fd, void *buf, size_t size, off64_t ofs)
121 return smbw_pwrite(fd, buf, size, ofs);
124 return real_pwrite64(fd, buf, size, ofs);
129 int chdir(char *name)
131 return smbw_chdir(name);
135 int __chdir(char *name)
140 int _chdir(char *name)
150 return smbw_close(fd);
152 if (smbw_local_fd(fd)) {
157 return real_close(fd);
175 return smbw_fchdir(fd);
191 int fcntl(int fd, int cmd, long arg)
194 return smbw_fcntl(fd, cmd, arg);
197 return real_fcntl(fd, cmd, arg);
202 int __fcntl(int fd, int cmd, long arg)
204 return fcntl(fd, cmd, arg);
207 int _fcntl(int fd, int cmd, long arg)
209 return fcntl(fd, cmd, arg);
216 int getdents(int fd, void *dirp, unsigned int count)
219 return smbw_getdents(fd, dirp, count);
222 return real_getdents(fd, dirp, count);
226 #ifdef HAVE___GETDENTS
227 int __getdents(int fd, void *dirp, unsigned int count)
229 return getdents(fd, dirp, count);
232 int _getdents(int fd, void *dirp, unsigned int count)
234 return getdents(fd, dirp, count);
239 off_t lseek(int fd, off_t offset, int whence)
242 return smbw_lseek(fd, offset, whence);
245 return real_lseek(fd, offset, whence);
249 off_t __lseek(int fd, off_t offset, int whence)
251 return lseek(fd, offset, whence);
254 off_t _lseek(int fd, off_t offset, int whence)
256 return lseek(fd, offset, whence);
261 ssize_t read(int fd, void *buf, size_t count)
264 return smbw_read(fd, buf, count);
267 return real_read(fd, buf, count);
271 ssize_t __read(int fd, void *buf, size_t count)
273 return read(fd, buf, count);
276 ssize_t _read(int fd, void *buf, size_t count)
278 return read(fd, buf, count);
283 ssize_t write(int fd, void *buf, size_t count)
286 return smbw_write(fd, buf, count);
289 return real_write(fd, buf, count);
293 ssize_t __write(int fd, void *buf, size_t count)
295 return write(fd, buf, count);
298 ssize_t _write(int fd, void *buf, size_t count)
300 return write(fd, buf, count);
306 int access(char *name, int mode)
308 if (smbw_path(name)) {
309 return smbw_access(name, mode);
312 return real_access(name, mode);
317 int chmod(char *name,mode_t mode)
319 if (smbw_path(name)) {
320 return smbw_chmod(name, mode);
323 return real_chmod(name, mode);
328 int chown(char *name,uid_t owner, gid_t group)
330 if (smbw_path(name)) {
331 return smbw_chown(name, owner, group);
334 return real_chown(name, owner, group);
338 char *getcwd(char *buf, size_t size)
340 return (char *)smbw_getcwd(buf, size);
346 int mkdir(char *name, mode_t mode)
348 if (smbw_path(name)) {
349 return smbw_mkdir(name, mode);
352 return real_mkdir(name, mode);
357 int __fxstat(int vers, int fd, void *st)
363 return smbw_fstat(fd, st);
366 ret = real_fstat(fd, xx);
367 xstat_convert(vers, st, xx);
373 int __xstat(int vers, char *name, void *st)
378 if (smbw_path(name)) {
379 return smbw_stat(name, st);
382 ret = real_stat(name, xx);
383 xstat_convert(vers, st, xx);
390 int __lxstat(int vers, char *name, void *st)
395 if (smbw_path(name)) {
396 return smbw_stat(name, st);
399 ret = real_lstat(name, xx);
400 xstat_convert(vers, st, xx);
406 int stat(char *name, void *st)
409 return __xstat(0, name, st);
411 if (smbw_path(name)) {
412 return smbw_stat(name, st);
414 return real_stat(name, st);
418 int lstat(char *name, void *st)
421 return __lxstat(0, name, st);
423 if (smbw_path(name)) {
424 return smbw_stat(name, st);
426 return real_lstat(name, st);
430 int fstat(int fd, void *st)
433 return __fxstat(0, fd, st);
436 return smbw_fstat(fd, st);
438 return real_fstat(fd, st);
443 int unlink(char *name)
445 if (smbw_path(name)) {
446 return smbw_unlink(name);
449 return real_unlink(name);
454 int utime(char *name,void *tvp)
456 if (smbw_path(name)) {
457 return smbw_utime(name, tvp);
460 return real_utime(name, tvp);
465 int utimes(const char *name, const struct timeval *tvp)
467 if (smbw_path(name)) {
468 return smbw_utimes(name, tvp);
471 return real_utimes(name, tvp);
475 int readlink(char *path, char *buf, size_t bufsize)
477 if (smbw_path(path)) {
478 return smbw_readlink(path, buf, bufsize);
481 return real_readlink(path, buf, bufsize);
485 int rename(char *oldname,char *newname)
488 p1 = smbw_path(oldname);
489 p2 = smbw_path(newname);
491 /* can't cross filesystem boundaries */
496 return smbw_rename(oldname, newname);
499 return real_rename(oldname, newname);
502 int rmdir(char *name)
504 if (smbw_path(name)) {
505 return smbw_rmdir(name);
508 return real_rmdir(name);
512 int symlink(char *topath,char *frompath)
515 p1 = smbw_path(topath);
516 p2 = smbw_path(frompath);
518 /* can't handle symlinks */
523 return real_symlink(topath, frompath);
535 int dup2(int oldfd, int newfd)
537 if (smbw_fd(newfd)) {
541 if (smbw_fd(oldfd)) {
542 return smbw_dup2(oldfd, newfd);
545 return real_dup2(oldfd, newfd);
549 void *opendir(char *name)
551 if (smbw_path(name)) {
552 return (void *)smbw_opendir(name);
555 return (void *)real_opendir(name);
560 void *readdir(void *dir)
562 if (smbw_dirp(dir)) {
563 return (void *)smbw_readdir(dir);
566 return (void *)real_readdir(dir);
571 int closedir(void *dir)
573 if (smbw_dirp(dir)) {
574 return smbw_closedir(dir);
577 return real_closedir(dir);
582 off_t telldir(void *dir)
584 if (smbw_dirp(dir)) {
585 return smbw_telldir(dir);
588 return real_telldir(dir);
593 int seekdir(void *dir, off_t offset)
595 if (smbw_dirp(dir)) {
596 smbw_seekdir(dir, offset);
600 real_seekdir(dir, offset);
606 #ifndef NO_ACL_WRAPPER
607 int acl(char *pathp, int cmd, int nentries, void *aclbufp)
609 if (smbw_path(pathp)) {
610 return smbw_acl(pathp, cmd, nentries, aclbufp);
613 return real_acl(pathp, cmd, nentries, aclbufp);
617 #ifndef NO_FACL_WRAPPER
618 int facl(int fd, int cmd, int nentries, void *aclbufp)
621 return smbw_facl(fd, cmd, nentries, aclbufp);
624 return real_facl(fd, cmd, nentries, aclbufp);
628 int creat(char *path, mode_t mode)
630 extern int creat_bits;
631 return open(path, creat_bits, mode);
635 int creat64(char *path, mode_t mode)
637 extern int creat_bits;
638 return open64(path, creat_bits, mode);
643 int stat64(char *name, void *st64)
645 if (smbw_path(name)) {
647 int ret = stat(name, xx);
648 stat64_convert(xx, st64);
651 return real_stat64(name, st64);
654 int fstat64(int fd, void *st64)
658 int ret = fstat(fd, xx);
659 stat64_convert(xx, st64);
662 return real_fstat64(fd, st64);
665 int lstat64(char *name, void *st64)
667 if (smbw_path(name)) {
669 int ret = lstat(name, xx);
670 stat64_convert(xx, st64);
673 return real_lstat64(name, st64);
678 offset_t llseek(int fd, offset_t ofs, int whence)
681 return lseek(fd, ofs, whence);
683 return real_llseek(fd, ofs, whence);
687 #ifdef HAVE_READDIR64
688 void *readdir64(void *dir)
690 if (smbw_dirp(dir)) {
691 static double xx[70];
693 d = (void *)readdir(dir);
695 dirent64_convert(d, xx);
698 return (void *)real_readdir64(dir);