s3:locking: add share_mode_lock_access_private_data()
authorStefan Metzmacher <metze@samba.org>
Fri, 26 Aug 2022 08:24:52 +0000 (10:24 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 20 Sep 2022 00:34:35 +0000 (00:34 +0000)
In future we should avoid dereference 'struct share_mode_lock'
as much as possible.

This will also allow us to load struct share_mode_data
only if required in future.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/locking/share_mode_lock.c
source3/locking/share_mode_lock_private.h

index d0954b8033626e8938b6a8825017dd75dfab6ab5..4fd9d1b3b5015c940561947a4b898d6d4c2712aa 100644 (file)
@@ -839,6 +839,18 @@ static NTSTATUS get_static_share_mode_data(
        return NT_STATUS_OK;
 }
 
+NTSTATUS share_mode_lock_access_private_data(struct share_mode_lock *lck,
+                                            struct share_mode_data **data)
+{
+       /*
+        * For now we always have lck->data,
+        * but we may change that in future.
+        */
+       SMB_ASSERT(lck->data != NULL);
+       *data = lck->data;
+       return NT_STATUS_OK;
+}
+
 /*******************************************************************
  Get a share_mode_lock, Reference counted to allow nested calls.
 ********************************************************************/
index 14a3c1b2a476731410e87aa8a4c267033d21746f..7e11d58fa7a190254747afe39809beeda1823124 100644 (file)
@@ -21,4 +21,7 @@ struct share_mode_lock {
        struct share_mode_data *data;
 };
 
+NTSTATUS share_mode_lock_access_private_data(struct share_mode_lock *lck,
+                                            struct share_mode_data **data);
+
 #endif