summaryrefslogtreecommitdiff
path: root/source3/smbwrapper
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1998-10-06 13:10:06 +0000
committerAndrew Tridgell <tridge@samba.org>1998-10-06 13:10:06 +0000
commit404f14fb36577ee182fd8a928e6cb7b374e4ecb9 (patch)
tree980f944f086c8810ed25106b2089b836f80950e1 /source3/smbwrapper
parentfff618aeb4142773ff388ac9b52d127a510c6690 (diff)
downloadsamba-404f14fb36577ee182fd8a928e6cb7b374e4ecb9.tar.gz
samba-404f14fb36577ee182fd8a928e6cb7b374e4ecb9.tar.bz2
samba-404f14fb36577ee182fd8a928e6cb7b374e4ecb9.zip
implemented unix semantics for rename in smbwrapper
(This used to be commit a5c18f9c82f5f76b00ff29c5668b4f0d3e8d6bd0)
Diffstat (limited to 'source3/smbwrapper')
-rw-r--r--source3/smbwrapper/smbw.c30
-rw-r--r--source3/smbwrapper/smbw_dir.c2
2 files changed, 26 insertions, 6 deletions
diff --git a/source3/smbwrapper/smbw.c b/source3/smbwrapper/smbw.c
index 6096f096a3..6b8796fb5d 100644
--- a/source3/smbwrapper/smbw.c
+++ b/source3/smbwrapper/smbw.c
@@ -647,6 +647,8 @@ ssize_t smbw_read(int fd, void *buf, size_t count)
struct smbw_file *file;
int ret;
+ DEBUG(4,("smbw_read(%d, %d)\n", fd, (int)count));
+
smbw_busy++;
file = smbw_file(fd);
@@ -666,6 +668,8 @@ ssize_t smbw_read(int fd, void *buf, size_t count)
}
file->f->offset += ret;
+
+ DEBUG(4,(" -> %d\n", ret));
smbw_busy--;
return ret;
@@ -793,8 +797,19 @@ a wrapper for access()
int smbw_access(const char *name, int mode)
{
struct stat st;
- /* how do we map this properly ?? */
- return smbw_stat(name, &st);
+
+ DEBUG(4,("smbw_access(%s, 0x%x)\n", name, mode));
+
+ if (smbw_stat(name, &st)) return -1;
+
+ if (((mode & R_OK) && !(st.st_mode & S_IRUSR)) ||
+ ((mode & W_OK) && !(st.st_mode & S_IWUSR)) ||
+ ((mode & X_OK) && !(st.st_mode & S_IXUSR))) {
+ errno = EACCES;
+ return -1;
+ }
+
+ return 0;
}
/*****************************************************
@@ -887,6 +902,8 @@ int smbw_rename(const char *oldname, const char *newname)
smbw_init();
+ DEBUG(4,("smbw_rename(%s,%s)\n", oldname, newname));
+
smbw_busy++;
/* work out what server they are after */
@@ -907,8 +924,13 @@ int smbw_rename(const char *oldname, const char *newname)
}
if (!cli_rename(&srv->cli, path1, path2)) {
- errno = smbw_errno(&srv->cli);
- goto failed;
+ int eno = smbw_errno(&srv->cli);
+ if (eno != EEXIST ||
+ !cli_unlink(&srv->cli, path2) ||
+ !cli_rename(&srv->cli, path1, path2)) {
+ errno = eno;
+ goto failed;
+ }
}
smbw_busy--;
diff --git a/source3/smbwrapper/smbw_dir.c b/source3/smbwrapper/smbw_dir.c
index 2c1b7ef9ec..f6d648b91f 100644
--- a/source3/smbwrapper/smbw_dir.c
+++ b/source3/smbwrapper/smbw_dir.c
@@ -320,8 +320,6 @@ int smbw_getdents(unsigned int fd, struct dirent *dirp, int count)
return -1;
}
- DEBUG(4,("sizeof(*dirp)=%d\n", sizeof(*dirp)));
-
while (count>=DIRP_SIZE && (dir->offset < dir->count)) {
dirp->d_off = (dir->offset+1)*DIRP_SIZE;
dirp->d_reclen = DIRP_SIZE;