[SCM] Samba Shared Repository - branch master updated

Michael Adam obnox at samba.org
Fri Jun 8 15:21:03 MDT 2012


The branch, master has been updated
       via  8a338c6 s3:smbd: change set_file_oplock() to return NTSTATUS
       via  088ca00 s3: Replace an if with a boolean short circuit
       via  a3b4a5d s3: Assigning ?True:False to a bool is a bit pointless
       via  4aea0c1 s3: Remove unnecessary ()
       via  a512780 s3: Replace an if with a boolean short circuit
       via  91be6b4 s3: Assigning ?True:False to a bool is a bit pointless
       via  e1e1fbc s3: Remove unnecessary ()
      from  b725154 tevent: change version to 0.9.16

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 8a338c65a1824ae8a93bef7bc8fac65684c285c8
Author: Michael Adam <obnox at samba.org>
Date:   Fri Jun 8 17:47:31 2012 +0200

    s3:smbd: change set_file_oplock() to return NTSTATUS
    
    Pair-Programmed-With: Volker Lendecke <vl at samba.org>
    Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
    
    Autobuild-User(master): Michael Adam <obnox at samba.org>
    Autobuild-Date(master): Fri Jun  8 23:20:20 CEST 2012 on sn-devel-104

commit 088ca00b926894575e75a03756642b9726f421d7
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jun 8 14:26:52 2012 +0200

    s3: Replace an if with a boolean short circuit
    
    Signed-off-by: Michael Adam <obnox at samba.org>

commit a3b4a5d7793b208436e541f2382c96c35fa31089
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jun 8 14:29:41 2012 +0200

    s3: Assigning ?True:False to a bool is a bit pointless
    
    Signed-off-by: Michael Adam <obnox at samba.org>

commit 4aea0c1fa1dab5f9480a9e5e1ea5e4af18ac061e
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jun 8 14:24:41 2012 +0200

    s3: Remove unnecessary ()
    
    Signed-off-by: Michael Adam <obnox at samba.org>

commit a51278067b47a7c2afe9ca0f32bc8fd340ce6a57
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jun 8 14:26:52 2012 +0200

    s3: Replace an if with a boolean short circuit
    
    Signed-off-by: Michael Adam <obnox at samba.org>

commit 91be6b42f1a23d716d5f1116ebbb0ad71619ed1a
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jun 8 14:25:23 2012 +0200

    s3: Assigning ?True:False to a bool is a bit pointless
    
    Signed-off-by: Michael Adam <obnox at samba.org>

commit e1e1fbcfe6fd79f588b2daea7827c90cd1f24008
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jun 8 14:24:41 2012 +0200

    s3: Remove unnecessary ()
    
    Signed-off-by: Michael Adam <obnox at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 source3/smbd/files.c  |   10 ++++------
 source3/smbd/open.c   |   14 ++++++--------
 source3/smbd/oplock.c |   11 ++++++-----
 source3/smbd/proto.h  |    2 +-
 4 files changed, 17 insertions(+), 20 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/smbd/files.c b/source3/smbd/files.c
index 33adaea..c0ebb98 100644
--- a/source3/smbd/files.c
+++ b/source3/smbd/files.c
@@ -603,12 +603,10 @@ NTSTATUS dup_file_fsp(struct smb_request *req, files_struct *from,
 	to->share_access = share_access;
 	to->oplock_type = from->oplock_type;
 	to->can_lock = from->can_lock;
-	to->can_read = (access_mask & (FILE_READ_DATA)) ? True : False;
-	if (!CAN_WRITE(from->conn)) {
-		to->can_write = False;
-	} else {
-		to->can_write = (access_mask & (FILE_WRITE_DATA | FILE_APPEND_DATA)) ? True : False;
-	}
+	to->can_read = ((access_mask & FILE_READ_DATA) != 0);
+	to->can_write =
+		CAN_WRITE(from->conn) &&
+		((access_mask & (FILE_WRITE_DATA | FILE_APPEND_DATA)) != 0);
 	to->modified = from->modified;
 	to->is_directory = from->is_directory;
 	to->aio_write_behind = from->aio_write_behind;
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index e753e78..4581553 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -776,13 +776,10 @@ static NTSTATUS open_file(files_struct *fsp,
 	fsp->vuid = req ? req->vuid : UID_FIELD_INVALID;
 	fsp->file_pid = req ? req->smbpid : 0;
 	fsp->can_lock = True;
-	fsp->can_read = (access_mask & (FILE_READ_DATA)) ? True : False;
-	if (!CAN_WRITE(conn)) {
-		fsp->can_write = False;
-	} else {
-		fsp->can_write = (access_mask & (FILE_WRITE_DATA | FILE_APPEND_DATA)) ?
-			True : False;
-	}
+	fsp->can_read = ((access_mask & FILE_READ_DATA) != 0);
+	fsp->can_write =
+		CAN_WRITE(conn) &&
+		((access_mask & (FILE_WRITE_DATA | FILE_APPEND_DATA)) != 0);
 	fsp->print_file = NULL;
 	fsp->modified = False;
 	fsp->sent_oplock_break = NO_BREAK_SENT;
@@ -2411,7 +2408,8 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
 	 * file structs.
 	 */
 
-	if (!set_file_oplock(fsp, fsp->oplock_type)) {
+	status = set_file_oplock(fsp, fsp->oplock_type);
+	if (!NT_STATUS_IS_OK(status)) {
 		/*
 		 * Could not get the kernel oplock or there are byte-range
 		 * locks on the file.
diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c
index 19886fc..835ea36 100644
--- a/source3/smbd/oplock.c
+++ b/source3/smbd/oplock.c
@@ -51,7 +51,7 @@ void break_kernel_oplock(struct messaging_context *msg_ctx, files_struct *fsp)
  if oplock set.
 ****************************************************************************/
 
-bool set_file_oplock(files_struct *fsp, int oplock_type)
+NTSTATUS set_file_oplock(files_struct *fsp, int oplock_type)
 {
 	struct smbd_server_connection *sconn = fsp->conn->sconn;
 	struct kernel_oplocks *koplocks = sconn->oplocks.kernel_ops;
@@ -62,15 +62,16 @@ bool set_file_oplock(files_struct *fsp, int oplock_type)
 		    !(koplocks->flags & KOPLOCKS_LEVEL2_SUPPORTED)) {
 			DEBUG(10, ("Refusing level2 oplock, kernel oplocks "
 				   "don't support them\n"));
-			return false;
+			return NT_STATUS_NOT_SUPPORTED;
 		}
 	}
 
 	if ((fsp->oplock_type != NO_OPLOCK) &&
 	    (fsp->oplock_type != FAKE_LEVEL_II_OPLOCK) &&
 	    use_kernel &&
-	    !koplocks->ops->set_oplock(koplocks, fsp, oplock_type)) {
-		return False;
+	    !koplocks->ops->set_oplock(koplocks, fsp, oplock_type))
+	{
+		return map_nt_error_from_unix(errno);
 	}
 
 	fsp->oplock_type = oplock_type;
@@ -87,7 +88,7 @@ bool set_file_oplock(files_struct *fsp, int oplock_type)
 		 fsp->fh->gen_id, (int)fsp->open_time.tv_sec,
 		 (int)fsp->open_time.tv_usec ));
 
-	return True;
+	return NT_STATUS_OK;
 }
 
 /****************************************************************************
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index b527d20..d81feef 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -654,7 +654,7 @@ NTSTATUS get_relative_fid_filename(connection_struct *conn,
 /* The following definitions come from smbd/oplock.c  */
 
 void break_kernel_oplock(struct messaging_context *msg_ctx, files_struct *fsp);
-bool set_file_oplock(files_struct *fsp, int oplock_type);
+NTSTATUS set_file_oplock(files_struct *fsp, int oplock_type);
 void release_file_oplock(files_struct *fsp);
 bool remove_oplock(files_struct *fsp);
 bool downgrade_oplock(files_struct *fsp);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list