diff options
author | Jeremy Allison <jra@samba.org> | 2001-04-16 00:34:03 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2001-04-16 00:34:03 +0000 |
commit | 71ae6a09cd2c4792f95459220645c424f7659913 (patch) | |
tree | 78d5e8ab28c0c03f45835e0cd2ac5f521bc94bb9 /source3 | |
parent | d5b74f71300f4366441511620d519b63442773b9 (diff) | |
download | samba-71ae6a09cd2c4792f95459220645c424f7659913.tar.gz samba-71ae6a09cd2c4792f95459220645c424f7659913.tar.bz2 samba-71ae6a09cd2c4792f95459220645c424f7659913.zip |
Finally got the semantics right (hurrah!).
Jeremy.
(This used to be commit 362574c5a32005d4247c7ac75a5aa9e35e894db0)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/smbd/open.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 7c40b0720e..c6d4a44688 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -143,12 +143,19 @@ static BOOL open_file(files_struct *fsp,connection_struct *conn, if ((accmode == O_RDONLY) && ((flags & O_TRUNC) == O_TRUNC)) local_flags = (flags & ~O_ACCMODE)|O_RDWR; + /* + * We can't actually truncate here as the file may be locked. + * open_file_shared will take care of the truncate later. JRA. + */ + + local_flags &= ~O_TRUNC; + /* actually do the open */ fsp->fd = fd_open(conn, fname, local_flags, mode); if (fsp->fd == -1) { - DEBUG(3,("Error opening file %s (%s) (flags=%d)\n", - fname,strerror(errno),flags)); + DEBUG(3,("Error opening file %s (%s) (local_flags=%d) (flags=%d)\n", + fname,strerror(errno),local_flags,flags)); check_for_pipe(fname); return False; } @@ -231,9 +238,6 @@ static int truncate_unless_locked(struct connection_struct *conn, files_struct * { SMB_BIG_UINT mask = (SMB_BIG_UINT)-1; - if (!fsp->can_write) - return -1; - if (is_locked(fsp,fsp->conn,mask,0,WRITE_LOCK)){ errno = EACCES; unix_ERR_class = ERRDOS; @@ -735,7 +739,11 @@ flags=0x%X flags2=0x%X mode=0%o returned %d\n", DEBUG(4,("calling open_file with flags=0x%X flags2=0x%X mode=0%o\n", flags,flags2,(int)mode)); - fsp_open = open_file(fsp,conn,fname,psbuf,flags|(flags2&~(O_TRUNC)),mode); + /* + * open_file strips any O_TRUNC flags itself. + */ + + fsp_open = open_file(fsp,conn,fname,psbuf,flags|flags2,mode); if (!fsp_open && (flags == O_RDWR) && (errno != ENOENT) && fcbopen) { if((fsp_open = open_file(fsp,conn,fname,psbuf,O_RDONLY,mode)) == True) |