s3: smbd: Add lock_flav element to struct smbd_lock_element.
authorJeremy Allison <jra@samba.org>
Wed, 13 Dec 2017 20:00:33 +0000 (12:00 -0800)
committerJeremy Allison <jra@samba.org>
Mon, 25 Feb 2019 20:48:03 +0000 (12:48 -0800)
In preparation for passing through POSIX lock requests on a
posix-open smb2 handle using the normal lock calls.

Signed-off-by: Jeremy Allison <jra@samba.org>
source3/include/locking.h
source3/smbd/reply.c
source3/smbd/smb2_lock.c

index 97c138aead90386cebb4be73962fe0d2033d2a6e..88a07df9dfd6c43033bb016c9fad9d4ab795adfb 100644 (file)
@@ -85,6 +85,7 @@ struct blocking_lock_record {
 
 struct smbd_lock_element {
        uint64_t smblctx;
+       enum brl_flavour lock_flav;
        enum brl_type brltype;
        uint64_t offset;
        uint64_t count;
index d6795deaf6e876c4be306e277897e750d9674ed6..3e88f2a1583902f4c5cae8dd8a917f9f1b404c5f 100644 (file)
@@ -8119,8 +8119,9 @@ NTSTATUS smbd_do_locking(struct smb_request *req,
        for(i = 0; i < (int)num_locks; i++) {
                struct smbd_lock_element *e = &locks[i];
 
-               DEBUG(10,("smbd_do_locking: lock start=%.0f, len=%.0f for smblctx "
-                         "%llu, file %s timeout = %d\n",
+               DEBUG(10,("smbd_do_locking: lock type %s start=%.0f, len=%.0f"
+                       " for smblctx %llu, file %s timeout = %d\n",
+                         e->lock_flav == WINDOWS_LOCK ? "WINDOWS" : "POSIX",
                          (double)e->offset,
                          (double)e->count,
                          (unsigned long long)e->smblctx,
@@ -8164,7 +8165,7 @@ NTSTATUS smbd_do_locking(struct smb_request *req,
                                                e->smblctx,
                                                e->offset,
                                                e->count,
-                                               WINDOWS_LOCK,
+                                               e->lock_flav,
                                                type,
                                                NT_STATUS_FILE_LOCK_CONFLICT);
                                if (blr == NULL) {
@@ -8178,7 +8179,7 @@ NTSTATUS smbd_do_locking(struct smb_request *req,
                                                e->smblctx,
                                                e->count,
                                                e->offset,
-                                               WINDOWS_LOCK);
+                                               e->lock_flav);
                } else {
                        bool blocking_lock = timeout ? true : false;
                        bool defer_lock = false;
@@ -8191,7 +8192,7 @@ NTSTATUS smbd_do_locking(struct smb_request *req,
                                        e->count,
                                        e->offset, 
                                        e->brltype,
-                                       WINDOWS_LOCK,
+                                       e->lock_flav,
                                        blocking_lock,
                                        &status,
                                        &block_smblctx);
@@ -8239,7 +8240,7 @@ NTSTATUS smbd_do_locking(struct smb_request *req,
                                                        i,
                                                        e->smblctx,
                                                        e->brltype,
-                                                       WINDOWS_LOCK,
+                                                       e->lock_flav,
                                                        e->offset,
                                                        e->count,
                                                        block_smblctx)) {
@@ -8279,7 +8280,7 @@ NTSTATUS smbd_do_locking(struct smb_request *req,
                                e->smblctx,
                                e->count,
                                e->offset,
-                               WINDOWS_LOCK);
+                               e->lock_flav);
                }
                return status;
        }
@@ -8318,7 +8319,7 @@ NTSTATUS smbd_do_unlocking(struct smb_request *req,
                                e->smblctx,
                                e->count,
                                e->offset,
-                               WINDOWS_LOCK);
+                               e->lock_flav);
 
                DEBUG(10, ("%s: unlock returned %s\n", __func__,
                           nt_errstr(status)));
@@ -8486,6 +8487,7 @@ void reply_lockingX(struct smb_request *req)
                ulocks[i].smblctx = get_lock_pid(data, i, large_file_format);
                ulocks[i].count = get_lock_count(data, i, large_file_format);
                ulocks[i].offset = get_lock_offset(data, i, large_file_format);
+               ulocks[i].lock_flav = WINDOWS_LOCK;
                ulocks[i].brltype = UNLOCK_LOCK;
        }
 
@@ -8499,6 +8501,7 @@ void reply_lockingX(struct smb_request *req)
                locks[i].smblctx = get_lock_pid(data, i, large_file_format);
                locks[i].count = get_lock_count(data, i, large_file_format);
                locks[i].offset = get_lock_offset(data, i, large_file_format);
+               locks[i].lock_flav = WINDOWS_LOCK;
 
                if (locktype & LOCKING_ANDX_SHARED_LOCK) {
                        if (locktype & LOCKING_ANDX_CANCEL_LOCK) {
index a05470e52e4a923dd162afbb8a3a9e85eeacaeec..b419ddb8fd7968e87380525dc2a853edffd3ad18 100644 (file)
@@ -318,6 +318,7 @@ static struct tevent_req *smbd_smb2_lock_send(TALLOC_CTX *mem_ctx,
                locks[i].smblctx = fsp->op->global->open_persistent_id;
                locks[i].offset = in_locks[i].offset;
                locks[i].count  = in_locks[i].length;
+               locks[i].lock_flav = WINDOWS_LOCK;
 
                if (in_locks[i].flags & SMB2_LOCK_FLAG_EXCLUSIVE) {
                        locks[i].brltype = WRITE_LOCK;
@@ -746,7 +747,7 @@ static void reprocess_blocked_smb2_lock(struct smbd_smb2_request *smb2req,
                        e->count,
                        e->offset,
                        e->brltype,
-                       WINDOWS_LOCK,
+                       e->lock_flav,
                        true,
                        &status,
                        &blr->blocking_smblctx);