locking: move share_mode_flags_[gs]et to share_mode_lock.c
[samba.git] / source3 / locking / share_mode_lock.h
1 /*
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.
6  *
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.
11  *
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/>.
14  */
15
16 #ifndef __LOCKING_SHARE_MODE_LOCK_H__
17 #define __LOCKING_SHARE_MODE_LOCK_H__
18
19 struct share_mode_data;
20 struct share_mode_lock {
21         struct share_mode_data *data;
22 };
23
24 bool locking_init(void);
25 bool locking_init_readonly(void);
26 bool locking_end(void);
27
28 struct share_mode_lock *get_share_mode_lock(
29         TALLOC_CTX *mem_ctx,
30         struct file_id id,
31         const char *servicepath,
32         const struct smb_filename *smb_fname,
33         const struct timespec *old_write_time);
34
35 bool del_share_mode(struct share_mode_lock *lck, files_struct *fsp);
36 bool downgrade_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
37 bool remove_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
38 bool file_has_read_lease(struct files_struct *fsp);
39
40 bool set_share_mode(
41         struct share_mode_lock *lck,
42         struct files_struct *fsp,
43         uid_t uid,
44         uint64_t mid,
45         uint16_t op_type,
46         uint32_t share_access,
47         uint32_t access_mask);
48 bool reset_share_mode_entry(
49         struct share_mode_lock *lck,
50         struct server_id old_pid,
51         uint64_t old_share_file_id,
52         struct server_id new_pid,
53         uint64_t new_mid,
54         uint64_t new_share_file_id);
55
56 bool mark_share_mode_disconnected(
57         struct share_mode_lock *lck, struct files_struct *fsp);
58
59 struct share_mode_lock *fetch_share_mode_unlocked(
60         TALLOC_CTX *mem_ctx,
61         struct file_id id);
62
63 struct tevent_req *fetch_share_mode_send(
64         TALLOC_CTX *mem_ctx,
65         struct tevent_context *ev,
66         struct file_id id,
67         bool *queued);
68 NTSTATUS fetch_share_mode_recv(
69         struct tevent_req *req,
70         TALLOC_CTX *mem_ctx,
71         struct share_mode_lock **_lck);
72
73 int share_entry_forall(
74         int (*fn)(struct file_id fid,
75                   const struct share_mode_data *data,
76                   const struct share_mode_entry *entry,
77                   void *private_data),
78         void *private_data);
79
80 NTSTATUS share_mode_count_entries(struct file_id fid, size_t *num_share_modes);
81 NTSTATUS share_mode_do_locked(
82         struct file_id id,
83         void (*fn)(const uint8_t *buf,
84                    size_t buflen,
85                    bool *modified_dependent,
86                    void *private_data),
87         void *private_data);
88 int share_mode_forall(
89         int (*fn)(struct file_id fid,
90                   const struct share_mode_data *data,
91                   void *private_data),
92         void *private_data);
93 bool share_mode_forall_entries(
94         struct share_mode_lock *lck,
95         bool (*fn)(struct share_mode_entry *e,
96                    bool *modified,
97                    void *private_data),
98         void *private_data);
99 bool share_mode_have_entries(struct share_mode_lock *lck);
100
101 NTTIME share_mode_changed_write_time(struct share_mode_lock *lck);
102 const char *share_mode_servicepath(struct share_mode_lock *lck);
103 char *share_mode_filename(TALLOC_CTX *mem_ctx, struct share_mode_lock *lck);
104 char *share_mode_data_dump(
105         TALLOC_CTX *mem_ctx, struct share_mode_lock *lck);
106
107 void share_mode_flags_get(
108         struct share_mode_lock *lck,
109         uint32_t *access_mask,
110         uint32_t *share_mode,
111         uint32_t *lease_type);
112 void share_mode_flags_set(
113         struct share_mode_lock *lck,
114         uint32_t access_mask,
115         uint32_t share_mode,
116         uint32_t lease_type,
117         bool *modified);
118
119 struct tevent_req *share_mode_watch_send(
120         TALLOC_CTX *mem_ctx,
121         struct tevent_context *ev,
122         struct share_mode_lock *lck,
123         struct server_id blocker);
124 NTSTATUS share_mode_watch_recv(
125         struct tevent_req *req, bool *blockerdead, struct server_id *blocker);
126 NTSTATUS share_mode_wakeup_waiters(struct file_id id);
127
128 #endif