diff options
author | Jeremy Allison <jra@samba.org> | 2003-10-09 21:04:51 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2003-10-09 21:04:51 +0000 |
commit | 73e7390c1c318d6b5550e8f09eb4256b04965acf (patch) | |
tree | 8be7b58ccc0a4cfa5f75593bf1a528b6b882da30 | |
parent | 12d2580ad7b80bdbae04b32e85abc375b332f0ab (diff) | |
download | samba-73e7390c1c318d6b5550e8f09eb4256b04965acf.tar.gz samba-73e7390c1c318d6b5550e8f09eb4256b04965acf.tar.bz2 samba-73e7390c1c318d6b5550e8f09eb4256b04965acf.zip |
Match W2K insanty w.r.t. writelock and writeclose. Samba4 torture tester.
Jeremy.
(This used to be commit 1c1c4ee8be9473d9d0ea676f7da2a1d359aaa7ee)
-rw-r--r-- | source3/smbd/reply.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 5c9451cf37..89bb5eeb94 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -2159,7 +2159,7 @@ int reply_writeunlock(connection_struct *conn, char *inbuf,char *outbuf, size_t numtowrite; SMB_OFF_T startpos; char *data; - NTSTATUS status; + NTSTATUS status = NT_STATUS_OK; files_struct *fsp = file_fsp(inbuf,smb_vwv0); int outsize = 0; START_PROFILE(SMBwriteunlock); @@ -2171,7 +2171,7 @@ int reply_writeunlock(connection_struct *conn, char *inbuf,char *outbuf, startpos = IVAL_TO_SMB_OFF_T(inbuf,smb_vwv2); data = smb_buf(inbuf) + 3; - if (is_locked(fsp,conn,(SMB_BIG_UINT)numtowrite,(SMB_BIG_UINT)startpos, + if (numtowrite && is_locked(fsp,conn,(SMB_BIG_UINT)numtowrite,(SMB_BIG_UINT)startpos, WRITE_LOCK,False)) { END_PROFILE(SMBwriteunlock); return ERROR_DOS(ERRDOS,ERRlock); @@ -2193,11 +2193,13 @@ int reply_writeunlock(connection_struct *conn, char *inbuf,char *outbuf, return(UNIXERROR(ERRHRD,ERRdiskfull)); } - status = do_unlock(fsp, conn, SVAL(inbuf,smb_pid), (SMB_BIG_UINT)numtowrite, - (SMB_BIG_UINT)startpos); - if (NT_STATUS_V(status)) { - END_PROFILE(SMBwriteunlock); - return ERROR_NT(status); + if (numtowrite) { + status = do_unlock(fsp, conn, SVAL(inbuf,smb_pid), (SMB_BIG_UINT)numtowrite, + (SMB_BIG_UINT)startpos); + if (NT_STATUS_V(status)) { + END_PROFILE(SMBwriteunlock); + return ERROR_NT(status); + } } outsize = set_message(outbuf,1,0,True); @@ -2620,7 +2622,7 @@ int reply_writeclose(connection_struct *conn, mtime = make_unix_date3(inbuf+smb_vwv4); data = smb_buf(inbuf) + 1; - if (is_locked(fsp,conn,(SMB_BIG_UINT)numtowrite,(SMB_BIG_UINT)startpos, WRITE_LOCK,False)) { + if (numtowrite && is_locked(fsp,conn,(SMB_BIG_UINT)numtowrite,(SMB_BIG_UINT)startpos, WRITE_LOCK,False)) { END_PROFILE(SMBwriteclose); return ERROR_DOS(ERRDOS,ERRlock); } @@ -2629,7 +2631,16 @@ int reply_writeclose(connection_struct *conn, set_filetime(conn, fsp->fsp_name,mtime); - close_err = close_file(fsp,True); + /* + * More insanity. W2K only closes the file if writelen > 0. + * JRA. + */ + + if (numtowrite) { + DEBUG(3,("reply_writeclose: zero length write doesn't close file %s\n", + fsp->fsp_name )); + close_err = close_file(fsp,True); + } DEBUG(3,("writeclose fnum=%d num=%d wrote=%d (numopen=%d)\n", fsp->fnum, (int)numtowrite, (int)nwritten, |