summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2011-10-19 14:23:38 -0700
committerJeremy Allison <jra@samba.org>2011-10-20 00:58:29 +0200
commit7b4edc11e3c0eb9b9a8717e28b70cb00e95cf7ec (patch)
tree7b5a2a5b428ebdd4b207e1ff178452b21843994a /source3
parent3712006faacbc468d7df3d577c796508e533617c (diff)
downloadsamba-7b4edc11e3c0eb9b9a8717e28b70cb00e95cf7ec.tar.gz
samba-7b4edc11e3c0eb9b9a8717e28b70cb00e95cf7ec.tar.bz2
samba-7b4edc11e3c0eb9b9a8717e28b70cb00e95cf7ec.zip
Make use of the "dir_exists" we already have on directory open.
Diffstat (limited to 'source3')
-rw-r--r--source3/smbd/open.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index f3fccd01d2..7d7e9d44c4 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -2631,6 +2631,15 @@ static NTSTATUS open_directory(connection_struct *conn,
/* If directory exists error. If directory doesn't
* exist create. */
+ if (dir_existed) {
+ status = NT_STATUS_OBJECT_NAME_COLLISION;
+ DEBUG(2, ("open_directory: unable to create "
+ "%s. Error was %s\n",
+ smb_fname_str_dbg(smb_dname),
+ nt_errstr(status)));
+ return status;
+ }
+
status = mkdir_internal(conn, smb_dname,
file_attributes);
@@ -2651,18 +2660,29 @@ static NTSTATUS open_directory(connection_struct *conn,
* exist create.
*/
- status = mkdir_internal(conn, smb_dname,
+ if (dir_existed) {
+ status = NT_STATUS_OK;
+ info = FILE_WAS_OPENED;
+ } else {
+ status = mkdir_internal(conn, smb_dname,
file_attributes);
- if (NT_STATUS_IS_OK(status)) {
- info = FILE_WAS_CREATED;
+ if (NT_STATUS_IS_OK(status)) {
+ info = FILE_WAS_CREATED;
+ } else {
+ /* Cope with create race. */
+ if (!NT_STATUS_EQUAL(status,
+ NT_STATUS_OBJECT_NAME_COLLISION)) {
+ DEBUG(2, ("open_directory: unable to create "
+ "%s. Error was %s\n",
+ smb_fname_str_dbg(smb_dname),
+ nt_errstr(status)));
+ return status;
+ }
+ info = FILE_WAS_OPENED;
+ }
}
- if (NT_STATUS_EQUAL(status,
- NT_STATUS_OBJECT_NAME_COLLISION)) {
- info = FILE_WAS_OPENED;
- status = NT_STATUS_OK;
- }
break;
case FILE_SUPERSEDE: