smbd: Give locking/share_mode_lock.c its own header file
authorVolker Lendecke <vl@samba.org>
Wed, 28 Oct 2020 11:09:39 +0000 (12:09 +0100)
committerJeremy Allison <jra@samba.org>
Tue, 10 Nov 2020 19:49:34 +0000 (19:49 +0000)
To me this is then easier to figure out what is defined there, and
where it's exactly used.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
26 files changed:
source3/locking/locking.c
source3/locking/proto.h
source3/locking/share_mode_lock.c
source3/locking/share_mode_lock.h [new file with mode: 0644]
source3/modules/vfs_delay_inject.c
source3/printing/queue_process.c
source3/printing/spoolssd.c
source3/rpc_server/srvsvc/srv_srvsvc_nt.c
source3/smbd/blocking.c
source3/smbd/close.c
source3/smbd/dir.c
source3/smbd/durable.c
source3/smbd/open.c
source3/smbd/oplock.c
source3/smbd/reply.c
source3/smbd/scavenger.c
source3/smbd/server.c
source3/smbd/server_exit.c
source3/smbd/smb2_lock.c
source3/smbd/smb2_query_directory.c
source3/smbd/smb2_setinfo.c
source3/torture/locktest2.c
source3/torture/vfstest.c
source3/utils/net_tdb.c
source3/utils/net_vfs.c
source3/utils/status.c

index 06c6a91cd594e49ef560fb4e774497dfecef504f..9c2674f7d1970d40a54a772f3dcf8f727c6c2d05 100644 (file)
@@ -39,6 +39,7 @@
 #include "lib/util/time_basic.h"
 #include "system/filesys.h"
 #include "lib/util/server_id.h"
+#include "share_mode_lock.h"
 #include "locking/proto.h"
 #include "smbd/globals.h"
 #include "dbwrap/dbwrap.h"
index 5c55ad9f8bad431c24f264d352b7d0f744273286..72d037040f2b1138610c84a2837e9acd02fdf854 100644 (file)
@@ -124,50 +124,12 @@ NTSTATUS do_unlock(files_struct *fsp,
                   enum brl_flavour lock_flav);
 void locking_close_file(files_struct *fsp,
                        enum file_close_type close_type);
-bool locking_init(void);
-bool locking_init_readonly(void);
-bool locking_end(void);
 char *share_mode_str(TALLOC_CTX *ctx, int num,
                     const struct file_id *id,
                     const struct share_mode_entry *e);
 struct share_mode_lock *get_existing_share_mode_lock(TALLOC_CTX *mem_ctx,
                                                     struct file_id id);
-struct share_mode_lock *get_share_mode_lock(
-       TALLOC_CTX *mem_ctx,
-       struct file_id id,
-       const char *servicepath,
-       const struct smb_filename *smb_fname,
-       const struct timespec *old_write_time);
 
-bool file_has_read_lease(struct files_struct *fsp);
-
-NTSTATUS share_mode_do_locked(
-       struct file_id id,
-       void (*fn)(const uint8_t *buf,
-                  size_t buflen,
-                  bool *modified_dependent,
-                  void *private_data),
-       void *private_data);
-NTSTATUS share_mode_wakeup_waiters(struct file_id id);
-bool share_mode_have_entries(struct share_mode_lock *lck);
-
-struct tevent_req *share_mode_watch_send(
-       TALLOC_CTX *mem_ctx,
-       struct tevent_context *ev,
-       struct file_id id,
-       struct server_id blocker);
-NTSTATUS share_mode_watch_recv(
-       struct tevent_req *req, bool *blockerdead, struct server_id *blocker);
-
-struct share_mode_lock *fetch_share_mode_unlocked(TALLOC_CTX *mem_ctx,
-                                                 struct file_id id);
-struct tevent_req *fetch_share_mode_send(TALLOC_CTX *mem_ctx,
-                                        struct tevent_context *ev,
-                                        struct file_id id,
-                                        bool *queued);
-NTSTATUS fetch_share_mode_recv(struct tevent_req *req,
-                              TALLOC_CTX *mem_ctx,
-                              struct share_mode_lock **_lck);
 bool rename_share_filename(struct messaging_context *msg_ctx,
                        struct share_mode_lock *lck,
                        struct file_id id,
@@ -181,28 +143,9 @@ void get_file_infos(struct file_id id,
                    struct timespec *write_time);
 bool is_valid_share_mode_entry(const struct share_mode_entry *e);
 bool share_entry_stale_pid(struct share_mode_entry *e);
-bool set_share_mode(struct share_mode_lock *lck,
-                   struct files_struct *fsp,
-                   uid_t uid,
-                   uint64_t mid,
-                   uint16_t op_type,
-                   uint32_t share_access,
-                   uint32_t access_mask);
-bool reset_share_mode_entry(
-       struct share_mode_lock *lck,
-       struct server_id old_pid,
-       uint64_t old_share_file_id,
-       struct server_id new_pid,
-       uint64_t new_mid,
-       uint64_t new_share_file_id);
 NTSTATUS remove_lease_if_stale(struct share_mode_lock *lck,
                               const struct GUID *client_guid,
                               const struct smb2_lease_key *lease_key);
-bool del_share_mode(struct share_mode_lock *lck, files_struct *fsp);
-bool mark_share_mode_disconnected(struct share_mode_lock *lck,
-                                 struct files_struct *fsp);
-bool remove_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
-bool downgrade_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
 bool get_delete_on_close_token(struct share_mode_lock *lck,
                                uint32_t name_hash,
                                const struct security_token **pp_nt_tok,
@@ -221,32 +164,12 @@ bool set_sticky_write_time(struct file_id fileid, struct timespec write_time);
 bool set_write_time(struct file_id fileid, struct timespec write_time);
 struct timespec get_share_mode_write_time(struct share_mode_lock *lck);
 bool file_has_open_streams(files_struct *fsp);
-int share_mode_forall(int (*fn)(struct file_id fid,
-                               const struct share_mode_data *data,
-                               void *private_data),
-                     void *private_data);
-int share_entry_forall(int (*fn)(struct file_id fid,
-                                const struct share_mode_data *data,
-                                const struct share_mode_entry *entry,
-                                void *private_data),
-                     void *private_data);
-bool share_mode_cleanup_disconnected(struct file_id id,
-                                    uint64_t open_persistent_id);
 bool share_mode_forall_leases(
        struct share_mode_lock *lck,
        bool (*fn)(struct share_mode_entry *e,
                   void *private_data),
        void *private_data);
 
-bool share_mode_forall_entries(
-       struct share_mode_lock *lck,
-       bool (*fn)(struct share_mode_entry *e,
-                  bool *modified,
-                  void *private_data),
-       void *private_data);
-
-NTSTATUS share_mode_count_entries(struct file_id fid, size_t *num_share_modes);
-
 /* The following definitions come from locking/posix.c  */
 
 bool is_posix_locked(files_struct *fsp,
index 1c4d3a422214b2afbc23066f93f896622dbac4fe..ad69ef7c6e25af356eb5a4e9cef048a6a831811f 100644 (file)
@@ -38,6 +38,7 @@
 #include "includes.h"
 #include "system/filesys.h"
 #include "lib/util/server_id.h"
+#include "share_mode_lock.h"
 #include "locking/proto.h"
 #include "smbd/globals.h"
 #include "dbwrap/dbwrap.h"
diff --git a/source3/locking/share_mode_lock.h b/source3/locking/share_mode_lock.h
new file mode 100644 (file)
index 0000000..644f2bd
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __LOCKING_SHARE_MODE_LOCK_H__
+#define __LOCKING_SHARE_MODE_LOCK_H__
+
+bool locking_init(void);
+bool locking_init_readonly(void);
+bool locking_end(void);
+
+struct share_mode_lock *get_share_mode_lock(
+       TALLOC_CTX *mem_ctx,
+       struct file_id id,
+       const char *servicepath,
+       const struct smb_filename *smb_fname,
+       const struct timespec *old_write_time);
+
+bool del_share_mode(struct share_mode_lock *lck, files_struct *fsp);
+bool downgrade_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
+bool remove_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
+bool file_has_read_lease(struct files_struct *fsp);
+
+bool set_share_mode(
+       struct share_mode_lock *lck,
+       struct files_struct *fsp,
+       uid_t uid,
+       uint64_t mid,
+       uint16_t op_type,
+       uint32_t share_access,
+       uint32_t access_mask);
+bool reset_share_mode_entry(
+       struct share_mode_lock *lck,
+       struct server_id old_pid,
+       uint64_t old_share_file_id,
+       struct server_id new_pid,
+       uint64_t new_mid,
+       uint64_t new_share_file_id);
+
+bool mark_share_mode_disconnected(
+       struct share_mode_lock *lck, struct files_struct *fsp);
+
+struct share_mode_lock *fetch_share_mode_unlocked(
+       TALLOC_CTX *mem_ctx,
+       struct file_id id);
+
+struct tevent_req *fetch_share_mode_send(
+       TALLOC_CTX *mem_ctx,
+       struct tevent_context *ev,
+       struct file_id id,
+       bool *queued);
+NTSTATUS fetch_share_mode_recv(
+       struct tevent_req *req,
+       TALLOC_CTX *mem_ctx,
+       struct share_mode_lock **_lck);
+
+int share_entry_forall(
+       int (*fn)(struct file_id fid,
+                 const struct share_mode_data *data,
+                 const struct share_mode_entry *entry,
+                 void *private_data),
+       void *private_data);
+bool share_mode_cleanup_disconnected(
+       struct file_id fid,
+       uint64_t open_persistent_id);
+
+NTSTATUS share_mode_count_entries(struct file_id fid, size_t *num_share_modes);
+NTSTATUS share_mode_do_locked(
+       struct file_id id,
+       void (*fn)(const uint8_t *buf,
+                  size_t buflen,
+                  bool *modified_dependent,
+                  void *private_data),
+       void *private_data);
+int share_mode_forall(
+       int (*fn)(struct file_id fid,
+                 const struct share_mode_data *data,
+                 void *private_data),
+       void *private_data);
+bool share_mode_forall_entries(
+       struct share_mode_lock *lck,
+       bool (*fn)(struct share_mode_entry *e,
+                  bool *modified,
+                  void *private_data),
+       void *private_data);
+bool share_mode_have_entries(struct share_mode_lock *lck);
+
+struct tevent_req *share_mode_watch_send(
+       TALLOC_CTX *mem_ctx,
+       struct tevent_context *ev,
+       struct file_id id,
+       struct server_id blocker);
+NTSTATUS share_mode_watch_recv(
+       struct tevent_req *req, bool *blockerdead, struct server_id *blocker);
+NTSTATUS share_mode_wakeup_waiters(struct file_id id);
+
+#endif
index 6be9fe5729233043430bbd72ea936d4fe8256a49..d70c0f0cb6a4673e36269070fc3dafde5051faa6 100644 (file)
@@ -18,6 +18,7 @@
  */
 
 #include "includes.h"
+#include "locking/share_mode_lock.h"
 #include "smbd/smbd.h"
 #include "lib/util/tevent_unix.h"
 
index 56f1b876e6bea145d530b00aab5a8fbfb4b0ac48..7b14cd94568001a71ba0d4896fcceaddf0cc1557 100644 (file)
@@ -28,6 +28,7 @@
 #include "printing/pcap.h"
 #include "printing/queue_process.h"
 #include "locking/proto.h"
+#include "locking/share_mode_lock.h"
 #include "smbd/smbd.h"
 #include "rpc_server/rpc_config.h"
 #include "printing/load.h"
index 2fe11d5bfc6cfff06426d712b88fdb40883f943e..bf10b19e4a058073532dfecea01ca208520d54e4 100644 (file)
@@ -17,6 +17,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 #include "includes.h"
+#include "locking/share_mode_lock.h"
 #include "smbd/smbd.h"
 
 #include "messages.h"
index c0c67c792e2e42d9da6f278e62e940251a783cde..67477d7b4169dd8695a5d78fafbf7e0eeb2c925a 100644 (file)
@@ -35,6 +35,7 @@
 #include "dbwrap/dbwrap.h"
 #include "session.h"
 #include "../lib/util/util_pw.h"
+#include "locking/share_mode_lock.h"
 #include "smbd/smbd.h"
 #include "smbd/globals.h"
 #include "auth.h"
index a684c9e9043b7f2aba86d7dbf64481089ee93e94..30bb84c0a7bd6344f6c72aef691bd6d223b9a71c 100644 (file)
@@ -18,6 +18,7 @@
 */
 
 #include "includes.h"
+#include "locking/share_mode_lock.h"
 #include "smbd/smbd.h"
 #include "smbd/globals.h"
 #include "messages.h"
index 12735fc69dae83dd5a2d655a2c70c565c7e0ad4c..42bdf67c2dff248dedc637c8165104830f4eda0c 100644 (file)
@@ -23,6 +23,7 @@
 #include "system/filesys.h"
 #include "lib/util/server_id.h"
 #include "printing.h"
+#include "locking/share_mode_lock.h"
 #include "smbd/smbd.h"
 #include "smbd/globals.h"
 #include "smbd/scavenger.h"
index 14ce758422b10defc943b83e09425f3c1d2871b9..5602fa9ea159eae8c2ee7f11b62482b051ea637c 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "includes.h"
 #include "system/filesys.h"
+#include "locking/share_mode_lock.h"
 #include "smbd/smbd.h"
 #include "smbd/globals.h"
 #include "libcli/security/security.h"
index e3334e15ae59992cc8fedbe4c0b204ca8668e615..5a1dd79832c6ab557a81c00919819946540fd070 100644 (file)
@@ -23,6 +23,7 @@
 #include "includes.h"
 #include "system/filesys.h"
 #include "lib/util/server_id.h"
+#include "locking/share_mode_lock.h"
 #include "smbd/smbd.h"
 #include "smbd/globals.h"
 #include "libcli/security/security.h"
index 0250df69db0aa26774a86b56de777a5b9c4be719..b7f050b80dece64fd54a2588ce524ab4417e03c7 100644 (file)
@@ -25,6 +25,7 @@
 #include "system/filesys.h"
 #include "lib/util/server_id.h"
 #include "printing.h"
+#include "locking/share_mode_lock.h"
 #include "smbd/smbd.h"
 #include "smbd/globals.h"
 #include "fake_file.h"
index a83a076152de383301b0e79e7fe93fce18a19412..9feda47c922a72081ecbe1681a391242f4e5e5ce 100644 (file)
@@ -22,6 +22,7 @@
 #define DBGC_CLASS DBGC_LOCKING
 #include "includes.h"
 #include "lib/util/server_id.h"
+#include "locking/share_mode_lock.h"
 #include "smbd/smbd.h"
 #include "smbd/globals.h"
 #include "messages.h"
index 8dfc97c85868c05602587c81ee348a06d407c8b7..e5ca576f7f85a6807b0b9530d0f9de6e47a19ce6 100644 (file)
@@ -28,6 +28,7 @@
 #include "libsmb/namequery.h"
 #include "system/filesys.h"
 #include "printing.h"
+#include "locking/share_mode_lock.h"
 #include "smbd/smbd.h"
 #include "smbd/globals.h"
 #include "fake_file.h"
index de07719468b8069c1f7ed69c2fd9b6a70fcd5cc2..a24a5d7ccb908c531d75502392e75741f4a4d792 100644 (file)
@@ -23,6 +23,7 @@
 #include "serverid.h"
 #include "smbd/globals.h"
 #include "smbd/scavenger.h"
+#include "locking/share_mode_lock.h"
 #include "locking/proto.h"
 #include "lib/util/server_id.h"
 #include "lib/util/util_process.h"
index 3d9db5d84078d7624cd1c07d4f0d14e91a810850..ea2d08c13a066d20dac7f814a528afebaad33c5e 100644 (file)
@@ -25,6 +25,7 @@
 #include "system/filesys.h"
 #include "lib/util/server_id.h"
 #include "popt_common.h"
+#include "locking/share_mode_lock.h"
 #include "smbd/smbd.h"
 #include "smbd/globals.h"
 #include "registry/reg_init_full.h"
index 397ea81063356e1176317b84a49f744f1dedac40..aa5ebe5fcd42d0d5253fdda27aa9d1fc69532cef 100644 (file)
@@ -23,6 +23,7 @@
 */
 
 #include "includes.h"
+#include "locking/share_mode_lock.h"
 #include "smbd/smbd.h"
 #include "smbd/globals.h"
 #include "ntdomain.h"
index 80a174cb293f1c057b27f2900203b38efebd2ce7..12ad12aaf934369f92cc0e5101c0d53cbe1edd2f 100644 (file)
@@ -20,6 +20,7 @@
 */
 
 #include "includes.h"
+#include "locking/share_mode_lock.h"
 #include "smbd/smbd.h"
 #include "smbd/globals.h"
 #include "../libcli/smb/smb_common.h"
index b72639630b395b7050f86ec5ca38fb9f65d0ddbb..ba10f925a46ff88ca25449739b3ff4d3981de70f 100644 (file)
@@ -19,6 +19,7 @@
 */
 
 #include "includes.h"
+#include "locking/share_mode_lock.h"
 #include "smbd/smbd.h"
 #include "smbd/globals.h"
 #include "../libcli/smb/smb_common.h"
index fdda9b5af3cc5cebfda58152f5a4318746379b09..bd2caab862a3d77cb1f64eed4eabb99213b53de2 100644 (file)
@@ -20,6 +20,7 @@
 */
 
 #include "includes.h"
+#include "locking/share_mode_lock.h"
 #include "smbd/smbd.h"
 #include "smbd/globals.h"
 #include "../libcli/smb/smb_common.h"
index 62f60ee1fe44b2de01d542c99aa7784f1147ea99..27366a6fbb97d92f442017167c074ee0b275d19e 100644 (file)
@@ -20,6 +20,7 @@
 #include "includes.h"
 #include "libsmb/libsmb.h"
 #include "system/filesys.h"
+#include "locking/share_mode_lock.h"
 #include "locking/proto.h"
 #include "lib/util/string_wrappers.h"
 
index 6a2fe59a2d80ea6b2c1e9ec925fdca119993878a..b89596e487c7bda6c8f0dc97967fb9614f699fc1 100644 (file)
@@ -24,6 +24,7 @@
 */
 
 #include "includes.h"
+#include "locking/share_mode_lock.h"
 #include "smbd/smbd.h"
 #include "smbd/globals.h"
 #include "popt_common.h"
index 0b81acf18e55f91b62dd087bf4f01992bb3071e1..efca041d8e33c1610498c05dd519874e8ee9bcde 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "includes.h"
 #include "utils/net.h"
+#include "locking/share_mode_lock.h"
 #include "locking/proto.h"
 #include "librpc/gen_ndr/open_files.h"
 #include "librpc/gen_ndr/ndr_open_files.h"
index 59e9c60b3a6109795d18b8e32c37e3033cf26f17..72603e33c9f795371ff91ee615f55ec09a66e823 100644 (file)
@@ -28,6 +28,7 @@
 #include "lib/param/param.h"
 #include "libcli/security/security.h"
 #include "smbd/proto.h"
+#include "locking/share_mode_lock.h"
 #include "locking/proto.h"
 #include "auth.h"
 #include "client.h"
index 05cc46086fe327f93e4c2c85b86da29927ea7c29..46fd457c8c8e06af82dc8aff181e53d2f8d420c9 100644 (file)
@@ -39,6 +39,7 @@
 #include "dbwrap/dbwrap_open.h"
 #include "../libcli/security/security.h"
 #include "session.h"
+#include "locking/share_mode_lock.h"
 #include "locking/proto.h"
 #include "messages.h"
 #include "librpc/gen_ndr/open_files.h"