2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 3 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #ifndef __LOCKING_SHARE_MODE_LOCK_H__
17 #define __LOCKING_SHARE_MODE_LOCK_H__
21 #include "librpc/gen_ndr/file_id.h"
22 #include "lib/util/time.h"
24 struct share_mode_data;
25 struct share_mode_lock;
26 struct share_mode_entry;
30 bool locking_init(void);
31 bool locking_init_readonly(void);
32 bool locking_end(void);
34 struct share_mode_lock *get_share_mode_lock(
37 const char *servicepath,
38 const struct smb_filename *smb_fname,
39 const struct timespec *old_write_time);
41 bool del_share_mode(struct share_mode_lock *lck,
42 struct files_struct *fsp);
43 bool downgrade_share_oplock(struct share_mode_lock *lck,
44 struct files_struct *fsp);
45 bool remove_share_oplock(struct share_mode_lock *lck,
46 struct files_struct *fsp);
47 bool file_has_read_lease(struct files_struct *fsp);
50 struct share_mode_lock *lck,
51 struct files_struct *fsp,
55 uint32_t share_access,
56 uint32_t access_mask);
57 bool reset_share_mode_entry(
58 struct share_mode_lock *lck,
59 struct server_id old_pid,
60 uint64_t old_share_file_id,
61 struct server_id new_pid,
63 uint64_t new_share_file_id);
65 bool mark_share_mode_disconnected(
66 struct share_mode_lock *lck, struct files_struct *fsp);
68 struct share_mode_lock *fetch_share_mode_unlocked(
72 struct tevent_req *fetch_share_mode_send(
74 struct tevent_context *ev,
77 NTSTATUS fetch_share_mode_recv(
78 struct tevent_req *req,
80 struct share_mode_lock **_lck);
82 int share_entry_forall(
83 int (*fn)(struct file_id fid,
84 const struct share_mode_data *data,
85 const struct share_mode_entry *entry,
89 NTSTATUS share_mode_count_entries(struct file_id fid, size_t *num_share_modes);
90 NTSTATUS share_mode_do_locked(
92 void (*fn)(const uint8_t *buf,
94 bool *modified_dependent,
97 int share_mode_forall(
98 int (*fn)(struct file_id fid,
99 const struct share_mode_data *data,
102 bool share_mode_forall_entries(
103 struct share_mode_lock *lck,
104 bool (*fn)(struct share_mode_entry *e,
109 NTTIME share_mode_changed_write_time(struct share_mode_lock *lck);
110 const char *share_mode_servicepath(struct share_mode_lock *lck);
111 char *share_mode_filename(TALLOC_CTX *mem_ctx, struct share_mode_lock *lck);
112 char *share_mode_data_dump(
113 TALLOC_CTX *mem_ctx, struct share_mode_lock *lck);
115 void share_mode_flags_get(
116 struct share_mode_lock *lck,
117 uint32_t *access_mask,
118 uint32_t *share_mode,
119 uint32_t *lease_type);
120 void share_mode_flags_set(
121 struct share_mode_lock *lck,
122 uint32_t access_mask,
127 struct tevent_req *share_mode_watch_send(
129 struct tevent_context *ev,
130 struct share_mode_lock *lck,
131 struct server_id blocker);
132 NTSTATUS share_mode_watch_recv(
133 struct tevent_req *req, bool *blockerdead, struct server_id *blocker);
134 NTSTATUS share_mode_wakeup_waiters(struct file_id id);