diff options
Diffstat (limited to 'source3/smbwrapper')
-rw-r--r-- | source3/smbwrapper/README | 2 | ||||
-rw-r--r-- | source3/smbwrapper/fchdir.c | 35 | ||||
-rw-r--r-- | source3/smbwrapper/realcalls.h | 2 | ||||
-rw-r--r-- | source3/smbwrapper/smbw.c | 31 |
4 files changed, 66 insertions, 4 deletions
diff --git a/source3/smbwrapper/README b/source3/smbwrapper/README index 14e7af700e..b2236eb8c9 100644 --- a/source3/smbwrapper/README +++ b/source3/smbwrapper/README @@ -22,7 +22,7 @@ This is code under development. Lots of things don't work yet. Things that I have tried and do seem to work include: emacs, tar, ls, cmp, cp, rsync, du, cat, rm, mv, less, more, wc, head, - tail, bash, tcsh, mkdir, rmdir, vim, xedit + tail, bash, tcsh, mkdir, rmdir, vim, xedit, diff things that I know don't work: diff --git a/source3/smbwrapper/fchdir.c b/source3/smbwrapper/fchdir.c new file mode 100644 index 0000000000..320d8fa6a4 --- /dev/null +++ b/source3/smbwrapper/fchdir.c @@ -0,0 +1,35 @@ +/* + Unix SMB/Netbios implementation. + Version 2.0 + SMB wrapper functions + Copyright (C) Andrew Tridgell 1998 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "wrapper.h" + +#ifdef linux +__asm__(".globl __fchdir; __fchdir = fchdir"); +#endif + + int fchdir(int fd) +{ + if (smbw_fd(fd)) { + return smbw_fchdir(fd); + } + + return real_fchdir(fd); +} diff --git a/source3/smbwrapper/realcalls.h b/source3/smbwrapper/realcalls.h index f9718a1ef1..53f110fe4a 100644 --- a/source3/smbwrapper/realcalls.h +++ b/source3/smbwrapper/realcalls.h @@ -35,6 +35,7 @@ struct dirent *__libc_readdir(DIR * dir); #define real_lseek(fd, offset, whence) (syscall(SYS_lseek, (fd), (offset), (whence))) #define real_write(fd, buf, count ) (syscall(SYS_write, (fd), (buf), (count))) #define real_close(fd) (syscall(SYS_close, (fd))) +#define real_fchdir(fd) (syscall(SYS_fchdir, (fd))) #define real_fcntl(fd,cmd,arg) (syscall(SYS_fcntl, (fd), (cmd), (arg))) #define real_symlink(fn1, fn2) (syscall(SYS_symlink, (fn1), (fn2))) #define real_unlink(fn) (syscall(SYS_unlink, (fn))) @@ -42,7 +43,6 @@ struct dirent *__libc_readdir(DIR * dir); #define real_mkdir(fn, mode) (syscall(SYS_mkdir, (fn), (mode))) #define real_utime(fn, buf) (syscall(SYS_utime, (fn), (buf))) #define real_utimes(fn, buf) (syscall(SYS_utimes, (fn), (buf))) -#define real_readlink(fn, buf, bufs) (syscall(SYS_readlink, (fn), (buf), (bufs))) #endif diff --git a/source3/smbwrapper/smbw.c b/source3/smbwrapper/smbw.c index 799a7f02cc..11d680befa 100644 --- a/source3/smbwrapper/smbw.c +++ b/source3/smbwrapper/smbw.c @@ -47,6 +47,7 @@ struct smbw_dir { int offset, count, malloced; struct smbw_server *srv; struct file_info *list; + char *path; }; static struct smbw_file *smbw_files; @@ -546,6 +547,7 @@ static void free_dir(struct smbw_dir *dir) if (dir->list) { free(dir->list); } + if (dir->path) free(dir->path); ZERO_STRUCTP(dir); free(dir); } @@ -602,6 +604,7 @@ int smbw_dir_open(const char *fname, int flags) struct smbw_dir *dir=NULL; pstring mask; int fd; + char *s; DEBUG(4,("%s\n", __FUNCTION__)); @@ -613,7 +616,7 @@ int smbw_dir_open(const char *fname, int flags) smbw_init(); /* work out what server they are after */ - smbw_parse_path(fname, server, share, path); + s = smbw_parse_path(fname, server, share, path); DEBUG(4,("dir_open share=%s\n", share)); @@ -665,6 +668,7 @@ int smbw_dir_open(const char *fname, int flags) dir->fd = fd + SMBW_FD_OFFSET; dir->srv = srv; + dir->path = strdup(s); DEBUG(4,(" -> %d\n", dir->count)); @@ -987,7 +991,7 @@ int smbw_dir_close(int fd) bitmap_clear(file_bmap, dir->fd - SMBW_FD_OFFSET); DLIST_REMOVE(smbw_dirs, dir); - + free_dir(dir); return 0; @@ -1634,3 +1638,26 @@ char *smbw_getcwd(char *buf, size_t size) smbw_busy--; return buf; } + +/***************************************************** +a wrapper for fchdir() +*******************************************************/ +int smbw_fchdir(unsigned int fd) +{ + struct smbw_dir *dir; + + DEBUG(4,("%s\n", __FUNCTION__)); + + smbw_busy++; + + dir = smbw_dir(fd); + if (!dir) { + errno = EBADF; + smbw_busy--; + return -1; + } + + smbw_busy--; + + return chdir(dir->path); +} |