diff options
author | Jeremy Allison <jra@samba.org> | 2012-09-05 10:46:16 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2012-09-05 20:43:31 +0200 |
commit | d7fb237810f10c7a7d44cf425163152811eba64c (patch) | |
tree | 0bca5fc80f483754065483de17cd447e1d7c627a /source3/smbd | |
parent | 5e492f8d324d269c2eb0e12f6dca2cb8133c4b8e (diff) | |
download | samba-d7fb237810f10c7a7d44cf425163152811eba64c.tar.gz samba-d7fb237810f10c7a7d44cf425163152811eba64c.tar.bz2 samba-d7fb237810f10c7a7d44cf425163152811eba64c.zip |
Remove an unncessary FTRUNCATE call in the open path. We can rely on O_TRUC.
Suggested by Volker.
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/open.c | 30 |
1 files changed, 1 insertions, 29 deletions
diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 6378521d76..9c4ba369cd 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -710,13 +710,6 @@ static NTSTATUS open_file(files_struct *fsp, const char *wild; int ret; - /* - * We can't actually truncate here as the file may be locked. - * open_file_ntcreate will take care of the truncate later. JRA. - */ - - local_flags &= ~O_TRUNC; - #if defined(O_NONBLOCK) && defined(S_ISFIFO) /* * We would block on opening a FIFO with no one else on the @@ -725,6 +718,7 @@ static NTSTATUS open_file(files_struct *fsp, */ if (file_existed && S_ISFIFO(smb_fname->st.st_ex_mode)) { + local_flags &= ~O_TRUNC; /* Can't truncate a FIFO. */ local_flags |= O_NONBLOCK; } #endif @@ -2382,10 +2376,6 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn, (unsigned int)unx_mode, (unsigned int)access_mask, (unsigned int)open_access_mask)); - /* - * open_file strips any O_TRUNC flags itself. - */ - fsp_open = open_file(fsp, conn, req, parent_dir, flags|flags2, unx_mode, access_mask, open_access_mask, &new_file_created); @@ -2575,24 +2565,6 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn, */ /* - * If requested, truncate the file. - */ - - if (!new_file_created && (flags2&O_TRUNC)) { - /* - * We are modifying the file after open - update the stat - * struct.. - */ - if ((SMB_VFS_FTRUNCATE(fsp, 0) == -1) || - (SMB_VFS_FSTAT(fsp, &smb_fname->st)==-1)) { - status = map_nt_error_from_unix(errno); - TALLOC_FREE(lck); - fd_close(fsp); - return status; - } - } - - /* * According to Samba4, SEC_FILE_READ_ATTRIBUTE is always granted, * but we don't have to store this - just ignore it on access check. */ |