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__
19 struct share_mode_data;
20 struct share_mode_lock;
22 bool locking_init(void);
23 bool locking_init_readonly(void);
24 bool locking_end(void);
26 struct share_mode_lock *get_share_mode_lock(
29 const char *servicepath,
30 const struct smb_filename *smb_fname,
31 const struct timespec *old_write_time);
33 bool del_share_mode(struct share_mode_lock *lck, files_struct *fsp);
34 bool downgrade_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
35 bool remove_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
36 bool file_has_read_lease(struct files_struct *fsp);
39 struct share_mode_lock *lck,
40 struct files_struct *fsp,
44 uint32_t share_access,
45 uint32_t access_mask);
46 bool reset_share_mode_entry(
47 struct share_mode_lock *lck,
48 struct server_id old_pid,
49 uint64_t old_share_file_id,
50 struct server_id new_pid,
52 uint64_t new_share_file_id);
54 bool mark_share_mode_disconnected(
55 struct share_mode_lock *lck, struct files_struct *fsp);
57 struct share_mode_lock *fetch_share_mode_unlocked(
61 struct tevent_req *fetch_share_mode_send(
63 struct tevent_context *ev,
66 NTSTATUS fetch_share_mode_recv(
67 struct tevent_req *req,
69 struct share_mode_lock **_lck);
71 int share_entry_forall(
72 int (*fn)(struct file_id fid,
73 const struct share_mode_data *data,
74 const struct share_mode_entry *entry,
78 NTSTATUS share_mode_count_entries(struct file_id fid, size_t *num_share_modes);
79 NTSTATUS share_mode_do_locked(
81 void (*fn)(const uint8_t *buf,
83 bool *modified_dependent,
86 int share_mode_forall(
87 int (*fn)(struct file_id fid,
88 const struct share_mode_data *data,
91 bool share_mode_forall_entries(
92 struct share_mode_lock *lck,
93 bool (*fn)(struct share_mode_entry *e,
97 bool share_mode_have_entries(struct share_mode_lock *lck);
99 NTTIME share_mode_changed_write_time(struct share_mode_lock *lck);
100 const char *share_mode_servicepath(struct share_mode_lock *lck);
101 char *share_mode_filename(TALLOC_CTX *mem_ctx, struct share_mode_lock *lck);
102 char *share_mode_data_dump(
103 TALLOC_CTX *mem_ctx, struct share_mode_lock *lck);
105 void share_mode_flags_get(
106 struct share_mode_lock *lck,
107 uint32_t *access_mask,
108 uint32_t *share_mode,
109 uint32_t *lease_type);
110 void share_mode_flags_set(
111 struct share_mode_lock *lck,
112 uint32_t access_mask,
117 struct tevent_req *share_mode_watch_send(
119 struct tevent_context *ev,
120 struct share_mode_lock *lck,
121 struct server_id blocker);
122 NTSTATUS share_mode_watch_recv(
123 struct tevent_req *req, bool *blockerdead, struct server_id *blocker);
124 NTSTATUS share_mode_wakeup_waiters(struct file_id id);