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.
26 __asm__(".globl __open; __open = open");
29 int open(const char *name, int flags, mode_t mode)
31 if (smbw_path(name)) {
32 return smbw_open(name, flags, mode);
35 return real_open(name, flags, mode);
40 __asm__(".globl __chdir; __chdir = chdir");
43 int chdir(const char *name)
45 return smbw_chdir(name);
51 __asm__(".globl __close; __close = close");
57 return smbw_close(fd);
60 return real_close(fd);
65 __asm__(".globl __fchdir; __fchdir = fchdir");
71 return smbw_fchdir(fd);
74 return real_fchdir(fd);
79 __asm__(".globl __fcntl; __fcntl = fcntl");
82 int fcntl(int fd, int cmd, long arg)
85 return smbw_fcntl(fd, cmd, arg);
88 return real_fcntl(fd, cmd, arg);
94 __asm__(".globl __getdents; __getdents = getdents");
97 int getdents(unsigned int fd, struct dirent *dirp, unsigned int count)
100 return smbw_getdents(fd, dirp, count);
103 return real_getdents(fd, dirp, count);
108 __asm__(".globl __lseek; __lseek = lseek");
111 ssize_t lseek(int fd, off_t offset, int whence)
114 return smbw_lseek(fd, offset, whence);
117 return real_lseek(fd, offset, whence);
123 __asm__(".globl __read; __read = read");
126 ssize_t read(int fd, void *buf, size_t count)
129 return smbw_read(fd, buf, count);
132 return real_read(fd, buf, count);
137 __asm__(".globl __write; __write = write");
140 ssize_t write(int fd, void *buf, size_t count)
143 return smbw_write(fd, buf, count);
146 return real_write(fd, buf, count);
150 int access(const char *name, int mode)
152 if (smbw_path(name)) {
153 return smbw_access(name, mode);
156 return real_access(name, mode);
161 int chmod(const char *name,mode_t mode)
163 if (smbw_path(name)) {
164 return smbw_chmod(name, mode);
167 return real_chmod(name, mode);
172 int chown(const char *name,uid_t owner, gid_t group)
174 if (smbw_path(name)) {
175 return smbw_chown(name, owner, group);
178 return real_chown(name, owner, group);
181 int closedir(DIR *dir)
183 if (smbw_dirp(dir)) {
184 return smbw_closedir(dir);
187 return real_closedir(dir);
191 int __fxstat(int vers, int fd, struct stat *st)
193 struct kernel_stat kbuf;
197 return smbw_fstat(fd, st);
201 case _STAT_VER_LINUX_OLD:
202 /* Nothing to do. The struct is in the form the kernel expects
204 return real_fstat(fd, (struct kernel_stat *)st);
207 case _STAT_VER_LINUX:
208 /* Do the system call. */
209 ret = real_fstat(fd, &kbuf);
211 st->st_dev = kbuf.st_dev;
215 st->st_ino = kbuf.st_ino;
216 st->st_mode = kbuf.st_mode;
217 st->st_nlink = kbuf.st_nlink;
218 st->st_uid = kbuf.st_uid;
219 st->st_gid = kbuf.st_gid;
220 st->st_rdev = kbuf.st_rdev;
224 st->st_size = kbuf.st_size;
225 st->st_blksize = kbuf.st_blksize;
226 st->st_blocks = kbuf.st_blocks;
227 st->st_atime = kbuf.st_atime;
228 #ifdef _HAVE___UNUSED1
231 st->st_mtime = kbuf.st_mtime;
232 #ifdef _HAVE___UNUSED2
235 st->st_ctime = kbuf.st_ctime;
236 #ifdef _HAVE___UNUSED3
239 #ifdef _HAVE___UNUSED4
242 #ifdef _HAVE___UNUSED5
254 char *getcwd(char *buf, size_t size)
256 return smbw_getcwd(buf, size);
261 int __lxstat(int vers, const char *name, struct stat *st)
263 struct kernel_stat kbuf;
266 if (smbw_path(name)) {
267 return smbw_stat(name, st);
271 case _STAT_VER_LINUX_OLD:
272 /* Nothing to do. The struct is in the form the kernel expects
274 return real_lstat(name, (struct kernel_stat *)st);
277 case _STAT_VER_LINUX:
278 /* Do the system call. */
279 ret = real_lstat(name, &kbuf);
281 st->st_dev = kbuf.st_dev;
285 st->st_ino = kbuf.st_ino;
286 st->st_mode = kbuf.st_mode;
287 st->st_nlink = kbuf.st_nlink;
288 st->st_uid = kbuf.st_uid;
289 st->st_gid = kbuf.st_gid;
290 st->st_rdev = kbuf.st_rdev;
294 st->st_size = kbuf.st_size;
295 st->st_blksize = kbuf.st_blksize;
296 st->st_blocks = kbuf.st_blocks;
297 st->st_atime = kbuf.st_atime;
298 #ifdef _HAVE___UNUSED1
301 st->st_mtime = kbuf.st_mtime;
302 #ifdef _HAVE___UNUSED2
305 st->st_ctime = kbuf.st_ctime;
306 #ifdef _HAVE___UNUSED3
309 #ifdef _HAVE___UNUSED4
312 #ifdef _HAVE___UNUSED5
325 int mkdir(const char *name, mode_t mode)
327 if (smbw_path(name)) {
328 return smbw_mkdir(name, mode);
331 return real_mkdir(name, mode);
335 void seekdir(DIR *dir, off_t offset)
337 if (smbw_dirp(dir)) {
338 smbw_seekdir(dir, offset);
342 real_seekdir(dir, offset);
346 int __xstat(int vers, const char *name, struct stat *st)
348 struct kernel_stat kbuf;
351 if (smbw_path(name)) {
352 return smbw_stat(name, st);
356 case _STAT_VER_LINUX_OLD:
357 /* Nothing to do. The struct is in the form the kernel expects
359 return real_stat(name, (struct kernel_stat *)st);
362 case _STAT_VER_LINUX:
363 /* Do the system call. */
364 ret = real_stat(name, &kbuf);
366 st->st_dev = kbuf.st_dev;
370 st->st_ino = kbuf.st_ino;
371 st->st_mode = kbuf.st_mode;
372 st->st_nlink = kbuf.st_nlink;
373 st->st_uid = kbuf.st_uid;
374 st->st_gid = kbuf.st_gid;
375 st->st_rdev = kbuf.st_rdev;
379 st->st_size = kbuf.st_size;
380 st->st_blksize = kbuf.st_blksize;
381 st->st_blocks = kbuf.st_blocks;
382 st->st_atime = kbuf.st_atime;
383 #ifdef _HAVE___UNUSED1
386 st->st_mtime = kbuf.st_mtime;
387 #ifdef _HAVE___UNUSED2
390 st->st_ctime = kbuf.st_ctime;
391 #ifdef _HAVE___UNUSED3
394 #ifdef _HAVE___UNUSED4
397 #ifdef _HAVE___UNUSED5
408 int stat(const char *name, struct stat *st)
410 return __xstat(_STAT_VER, name, st);
414 off_t telldir(DIR *dir)
416 if (smbw_dirp(dir)) {
417 return smbw_telldir(dir);
420 return real_telldir(dir);
424 int unlink(const char *name)
426 if (smbw_path(name)) {
427 return smbw_unlink(name);
430 return real_unlink(name);
434 int utime(const char *name,void *tvp)
436 if (smbw_path(name)) {
437 return smbw_utime(name, tvp);
440 return real_utime(name, tvp);
443 DIR *opendir(const char *name)
445 if (smbw_path(name)) {
446 return smbw_opendir(name);
449 return real_opendir(name);
453 struct dirent *readdir(DIR *dir)
455 if (smbw_dirp(dir)) {
456 return smbw_readdir(dir);
459 return real_readdir(dir);
462 int readlink(char *path, char *buf, size_t bufsize)
464 if (smbw_path(path)) {
465 return smbw_readlink(path, buf, bufsize);
468 return real_readlink(path, buf, bufsize);
472 int rename(const char *oldname,const char *newname)
475 p1 = smbw_path(oldname);
476 p2 = smbw_path(newname);
478 /* can't cross filesystem boundaries */
483 return smbw_rename(oldname, newname);
486 return real_rename(oldname, newname);
489 int rmdir(const char *name)
491 if (smbw_path(name)) {
492 return smbw_rmdir(name);
495 return real_rmdir(name);
499 int symlink(const char *topath,const char *frompath)
502 p1 = smbw_path(topath);
503 p2 = smbw_path(frompath);
505 /* can't handle symlinks */
510 return real_symlink(topath, frompath);