s3:smbd: change set_file_oplock() to return NTSTATUS
authorMichael Adam <obnox@samba.org>
Fri, 8 Jun 2012 15:47:31 +0000 (17:47 +0200)
committerMichael Adam <obnox@samba.org>
Fri, 8 Jun 2012 21:20:20 +0000 (23:20 +0200)
Pair-Programmed-With: Volker Lendecke <vl@samba.org>
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Fri Jun  8 23:20:20 CEST 2012 on sn-devel-104

source3/smbd/open.c
source3/smbd/oplock.c
source3/smbd/proto.h

index 7708833f97d9749c29f2d037a3c807add5969f40..4581553be2f8e1af26503a4de47eb636836e516e 100644 (file)
@@ -2408,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.
index 19886fc79da9ecd557b558d84fa0c2fb0391eeeb..835ea366f9f55f85a2f9a7633953ed0107180d77 100644 (file)
@@ -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;
 }
 
 /****************************************************************************
index b527d208b6ecd1dbc1057d04a50f23fdb36f708f..d81feef073db0cd517650edd99e8c1539901b1d8 100644 (file)
@@ -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);