mirror of
https://github.com/samba-team/samba.git
synced 2025-03-10 12:58:35 +03:00
added fchdir() support
(This used to be commit a42729dbf5414f54e5d623514533958c62ada5f6)
This commit is contained in:
parent
f2d8f110db
commit
86701c6a3c
@ -200,7 +200,7 @@ SMBWRAPPER_OBJ = smbwrapper/open.o smbwrapper/stat.o \
|
||||
smbwrapper/write.o smbwrapper/readlink.o smbwrapper/unlink.o \
|
||||
smbwrapper/rename.o smbwrapper/utime.o smbwrapper/chown.o \
|
||||
smbwrapper/chmod.o smbwrapper/lseek.o smbwrapper/getcwd.o \
|
||||
smbwrapper/mkdir.o smbwrapper/rmdir.o \
|
||||
smbwrapper/mkdir.o smbwrapper/rmdir.o smbwrapper/fchdir.o \
|
||||
$(LIBSMB_OBJ) $(PARAM_OBJ) \
|
||||
$(UBIQX_OBJ) $(LIB_OBJ)
|
||||
|
||||
|
@ -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:
|
||||
|
||||
|
35
source3/smbwrapper/fchdir.c
Normal file
35
source3/smbwrapper/fchdir.c
Normal file
@ -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);
|
||||
}
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user