1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-28 01:58:17 +03:00

Finally got the semantics right (hurrah!).

Jeremy.
(This used to be commit 362574c5a32005d4247c7ac75a5aa9e35e894db0)
This commit is contained in:
Jeremy Allison 2001-04-16 00:34:03 +00:00
parent d5b74f7130
commit 71ae6a09cd

View File

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