summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/reply.c16
-rw-r--r--source3/smbd/server.c14
2 files changed, 14 insertions, 16 deletions
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 35189883e2..c9daf14b4b 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -2150,7 +2150,7 @@ int reply_writebraw(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
}
if (lp_syncalways(SNUM(cnum)) || write_through)
- sync_file(fnum);
+ sync_file(cnum,fnum);
DEBUG(3,("%s writebraw2 fnum=%d cnum=%d start=%d num=%d wrote=%d\n",
timestring(),fnum,cnum,startpos,numtowrite,total_written));
@@ -2202,7 +2202,7 @@ int reply_writeunlock(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
nwritten = write_file(fnum,data,numtowrite);
if (lp_syncalways(SNUM(cnum)))
- sync_file(fnum);
+ sync_file(cnum,fnum);
if(((nwritten == 0) && (numtowrite != 0))||(nwritten < 0))
return(UNIXERROR(ERRDOS,ERRnoaccess));
@@ -2257,7 +2257,7 @@ int reply_write(char *inbuf,char *outbuf,int dum_size,int dum_buffsize)
nwritten = write_file(fnum,data,numtowrite);
if (lp_syncalways(SNUM(cnum)))
- sync_file(fnum);
+ sync_file(cnum,fnum);
if(((nwritten == 0) && (numtowrite != 0))||(nwritten < 0))
return(UNIXERROR(ERRDOS,ERRnoaccess));
@@ -2330,7 +2330,7 @@ int reply_write_and_X(char *inbuf,char *outbuf,int length,int bufsize)
chain_fnum = fnum;
if (lp_syncalways(SNUM(cnum)) || write_through)
- sync_file(fnum);
+ sync_file(cnum,fnum);
return chain_reply(inbuf,outbuf,length,bufsize);
}
@@ -2398,10 +2398,10 @@ int reply_flush(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
int i;
for (i=0;i<MAX_FNUMS;i++)
if (OPEN_FNUM(i))
- sync_file(i);
+ sync_file(cnum,i);
}
else
- sync_file(fnum);
+ sync_file(cnum,fnum);
DEBUG(3,("%s flush fnum=%d\n",timestring(),fnum));
return(outsize);
@@ -3866,7 +3866,7 @@ int reply_writebmpx(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
nwritten = write_file(fnum,data,numtowrite);
if(lp_syncalways(SNUM(cnum)) || write_through)
- sync_file(fnum);
+ sync_file(cnum,fnum);
if(nwritten < numtowrite)
return(UNIXERROR(ERRHRD,ERRdiskfull));
@@ -3967,7 +3967,7 @@ int reply_writebs(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
nwritten = write_file(fnum,data,numtowrite);
if(lp_syncalways(SNUM(cnum)) || write_through)
- sync_file(fnum);
+ sync_file(cnum,fnum);
if (nwritten < numtowrite)
{
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 49ce759945..151a6d7ded 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -1435,12 +1435,9 @@ static void open_file(int fnum,int cnum,char *fname1,int flags,int mode, struct
#else /* No EROFS */
if((fd_ptr->fd == -1) && (errno == EACCES)) {
#endif /* EROFS */
- if(flags & O_WRONLY) {
- fd_ptr->fd = fd_attempt_open(fname, open_flags|O_WRONLY, mode);
- fd_ptr->real_open_flags = O_WRONLY;
- } else {
- fd_ptr->fd = fd_attempt_open(fname, open_flags|O_RDONLY, mode);
- fd_ptr->real_open_flags = O_RDONLY;
+ if(accmode != O_RDWR) {
+ fd_ptr->fd = fd_attempt_open(fname, open_flags|accmode, mode);
+ fd_ptr->real_open_flags = accmode;
}
}
}
@@ -1564,10 +1561,11 @@ static void open_file(int fnum,int cnum,char *fname1,int flags,int mode, struct
/*******************************************************************
sync a file
********************************************************************/
-void sync_file(int fnum)
+void sync_file(int cnum, int fnum)
{
#ifndef NO_FSYNC
- fsync(Files[fnum].fd_ptr->fd);
+ if(lp_strict_sync(SNUM(cnum)))
+ fsync(Files[fnum].fd_ptr->fd);
#endif
}