1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-26 10:04:02 +03:00

implemented unix semantics for rename in smbwrapper

This commit is contained in:
Andrew Tridgell -
parent b7ecbca3af
commit a5c18f9c82
5 changed files with 34 additions and 7 deletions

View File

@ -216,6 +216,7 @@ implemented */
#define ERRfilexists 80 /* File in operation already exists */
#define ERRcannotopen 110 /* Cannot open the file specified */
#define ERRunknownlevel 124
#define ERRrename 183
#define ERRbadpipe 230 /* Named pipe invalid */
#define ERRpipebusy 231 /* All instances of pipe are busy */
#define ERRpipeclosing 232 /* named pipe close in progress */

View File

@ -1196,6 +1196,8 @@ size_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t
int mid;
int blocks = (size + (block-1)) / block;
if (size == 0) return 0;
while (received < blocks) {
int size2;
@ -1295,6 +1297,8 @@ size_t cli_write(struct cli_state *cli, int fnum, char *buf, off_t offset, size_
int mid;
int blocks = (size + (block-1)) / block;
if (size == 0) return 0;
while (received < blocks) {
int size2;
@ -2309,6 +2313,8 @@ int cli_error(struct cli_state *cli, uint8 *eclass, uint32 *num)
case ERRbadfile: return ENOENT;
case ERRbadpath: return ENOTDIR;
case ERRnoaccess: return EACCES;
case ERRfilexists: return EEXIST;
case ERRrename: return EEXIST;
}
}
if (rcls == ERRSRV) {

View File

@ -3210,7 +3210,7 @@ int rename_internals(connection_struct *conn,
if (!count) exists = file_exist(directory,NULL);
if (!count && exists && file_exist(newname,NULL)) {
exists = True;
error = 183;
error = ERRrename;
}
} else {
/*

View File

@ -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--;

View File

@ -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;