vfs: Remove unused "msg_ctx" from SMB_VFS_BRL_UNLOCK_WINDOWS
[samba.git] / source3 / locking / proto.h
1 /*
2  *  Unix SMB/CIFS implementation.
3  *  Locking functions
4  *
5  *  Copyright (C) Andrew Tridgell       1992-2000
6  *  Copyright (C) Jeremy Allison        1992-2006
7  *  Copyright (C) Volker Lendecke       2005
8  *
9  *  This program is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; either version 3 of the License, or
12  *  (at your option) any later version.
13  *
14  *  This program is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *
19  *  You should have received a copy of the GNU General Public License
20  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  */
22
23 #ifndef _LOCKING_PROTO_H_
24 #define _LOCKING_PROTO_H_
25
26 /* The following definitions come from locking/brlock.c  */
27
28 void brl_init(bool read_only);
29 void brl_shutdown(void);
30
31 unsigned int brl_num_locks(const struct byte_range_lock *brl);
32 struct files_struct *brl_fsp(struct byte_range_lock *brl);
33 uint32_t brl_num_read_oplocks(const struct byte_range_lock *brl);
34 void brl_set_num_read_oplocks(struct byte_range_lock *brl,
35                               uint32_t num_read_oplocks);
36
37 NTSTATUS brl_lock_windows_default(struct byte_range_lock *br_lck,
38                                   struct lock_struct *plock);
39
40 NTSTATUS brl_lock(
41         struct byte_range_lock *br_lck,
42         uint64_t smblctx,
43         struct server_id pid,
44         br_off start,
45         br_off size,
46         enum brl_type lock_type,
47         enum brl_flavour lock_flav,
48         struct server_id *blocker_pid,
49         uint64_t *psmblctx);
50 bool brl_unlock(struct messaging_context *msg_ctx,
51                 struct byte_range_lock *br_lck,
52                 uint64_t smblctx,
53                 struct server_id pid,
54                 br_off start,
55                 br_off size,
56                 enum brl_flavour lock_flav);
57 bool brl_unlock_windows_default(struct byte_range_lock *br_lck,
58                                 const struct lock_struct *plock);
59 bool brl_locktest(struct byte_range_lock *br_lck,
60                   const struct lock_struct *rw_probe);
61 NTSTATUS brl_lockquery(struct byte_range_lock *br_lck,
62                 uint64_t *psmblctx,
63                 struct server_id pid,
64                 br_off *pstart,
65                 br_off *psize,
66                 enum brl_type *plock_type,
67                 enum brl_flavour lock_flav);
68 bool brl_mark_disconnected(struct files_struct *fsp);
69 bool brl_reconnect_disconnected(struct files_struct *fsp);
70 void brl_close_fnum(struct messaging_context *msg_ctx,
71                     struct byte_range_lock *br_lck);
72 int brl_forall(void (*fn)(struct file_id id, struct server_id pid,
73                           enum brl_type lock_type,
74                           enum brl_flavour lock_flav,
75                           br_off start, br_off size,
76                           void *private_data),
77                void *private_data);
78 struct byte_range_lock *brl_get_locks(TALLOC_CTX *mem_ctx,
79                                         files_struct *fsp);
80 struct byte_range_lock *brl_get_locks_readonly(files_struct *fsp);
81 bool brl_cleanup_disconnected(struct file_id fid, uint64_t open_persistent_id);
82
83 /* The following definitions come from locking/locking.c  */
84
85 const char *lock_type_name(enum brl_type lock_type);
86 const char *lock_flav_name(enum brl_flavour lock_flav);
87 void init_strict_lock_struct(files_struct *fsp,
88                                 uint64_t smblctx,
89                                 br_off start,
90                                 br_off size,
91                                 enum brl_type lock_type,
92                                 struct lock_struct *plock);
93 bool strict_lock_check_default(files_struct *fsp,
94                                struct lock_struct *plock);
95 NTSTATUS query_lock(files_struct *fsp,
96                         uint64_t *psmblctx,
97                         uint64_t *pcount,
98                         uint64_t *poffset,
99                         enum brl_type *plock_type,
100                         enum brl_flavour lock_flav);
101 NTSTATUS do_lock(files_struct *fsp,
102                  uint64_t smblctx,
103                  uint64_t count,
104                  uint64_t offset,
105                  enum brl_type lock_type,
106                  enum brl_flavour lock_flav,
107                  struct server_id *pblocker_pid,
108                  uint64_t *psmblctx);
109 NTSTATUS do_unlock(struct messaging_context *msg_ctx,
110                         files_struct *fsp,
111                         uint64_t smblctx,
112                         uint64_t count,
113                         uint64_t offset,
114                         enum brl_flavour lock_flav);
115 void locking_close_file(struct messaging_context *msg_ctx,
116                         files_struct *fsp,
117                         enum file_close_type close_type);
118 bool locking_init(void);
119 bool locking_init_readonly(void);
120 bool locking_end(void);
121 char *share_mode_str(TALLOC_CTX *ctx, int num,
122                      const struct file_id *id,
123                      const struct share_mode_entry *e);
124 struct share_mode_lock *get_existing_share_mode_lock(TALLOC_CTX *mem_ctx,
125                                                      struct file_id id);
126 struct share_mode_lock *get_share_mode_lock(
127         TALLOC_CTX *mem_ctx,
128         struct file_id id,
129         const char *servicepath,
130         const struct smb_filename *smb_fname,
131         const struct timespec *old_write_time);
132 struct share_mode_lock *fetch_share_mode_unlocked(TALLOC_CTX *mem_ctx,
133                                                   struct file_id id);
134 struct tevent_req *fetch_share_mode_send(TALLOC_CTX *mem_ctx,
135                                          struct tevent_context *ev,
136                                          struct file_id id,
137                                          bool *queued);
138 NTSTATUS fetch_share_mode_recv(struct tevent_req *req,
139                                TALLOC_CTX *mem_ctx,
140                                struct share_mode_lock **_lck);
141 bool rename_share_filename(struct messaging_context *msg_ctx,
142                         struct share_mode_lock *lck,
143                         struct file_id id,
144                         const char *servicepath,
145                         uint32_t orig_name_hash,
146                         uint32_t new_name_hash,
147                         const struct smb_filename *smb_fname);
148 void get_file_infos(struct file_id id,
149                     uint32_t name_hash,
150                     bool *delete_on_close,
151                     struct timespec *write_time);
152 bool is_valid_share_mode_entry(const struct share_mode_entry *e);
153 bool share_mode_stale_pid(struct share_mode_data *d, uint32_t idx);
154 bool set_share_mode(struct share_mode_lock *lck,
155                     struct files_struct *fsp,
156                     uid_t uid,
157                     uint64_t mid,
158                     uint16_t op_type,
159                     const struct GUID *client_guid,
160                     const struct smb2_lease_key *lease_key);
161 struct share_mode_entry *find_share_mode_entry(struct share_mode_lock *lck,
162                                                files_struct *fsp);
163 void remove_stale_share_mode_entries(struct share_mode_data *d);
164 bool del_share_mode(struct share_mode_lock *lck, files_struct *fsp);
165 bool mark_share_mode_disconnected(struct share_mode_lock *lck,
166                                   struct files_struct *fsp);
167 bool remove_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
168 bool downgrade_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
169 bool get_delete_on_close_token(struct share_mode_lock *lck,
170                                 uint32_t name_hash,
171                                 const struct security_token **pp_nt_tok,
172                                 const struct security_unix_token **pp_tok);
173 void reset_delete_on_close_lck(files_struct *fsp,
174                                struct share_mode_lock *lck);
175 void set_delete_on_close_lck(files_struct *fsp,
176                         struct share_mode_lock *lck,
177                         const struct security_token *nt_tok,
178                         const struct security_unix_token *tok);
179 bool set_delete_on_close(files_struct *fsp, bool delete_on_close,
180                         const struct security_token *nt_tok,
181                         const struct security_unix_token *tok);
182 bool is_delete_on_close_set(struct share_mode_lock *lck, uint32_t name_hash);
183 bool set_sticky_write_time(struct file_id fileid, struct timespec write_time);
184 bool set_write_time(struct file_id fileid, struct timespec write_time);
185 struct timespec get_share_mode_write_time(struct share_mode_lock *lck);
186 bool file_has_open_streams(files_struct *fsp);
187 int share_mode_forall(int (*fn)(struct file_id fid,
188                                 const struct share_mode_data *data,
189                                 void *private_data),
190                       void *private_data);
191 int share_entry_forall(int (*fn)(struct file_id fid,
192                                  const struct share_mode_data *data,
193                                  const struct share_mode_entry *entry,
194                                  void *private_data),
195                       void *private_data);
196 bool share_mode_cleanup_disconnected(struct file_id id,
197                                      uint64_t open_persistent_id);
198 bool share_mode_forall_leases(
199         struct share_mode_lock *lck,
200         bool (*fn)(struct share_mode_lock *lck,
201                    struct share_mode_entry *e,
202                    void *private_data),
203         void *private_data);
204
205
206 /* The following definitions come from locking/posix.c  */
207
208 bool is_posix_locked(files_struct *fsp,
209                         uint64_t *pu_offset,
210                         uint64_t *pu_count,
211                         enum brl_type *plock_type,
212                         enum brl_flavour lock_flav);
213 bool posix_locking_init(bool read_only);
214 bool posix_locking_end(void);
215 int fd_close_posix(const struct files_struct *fsp);
216 bool set_posix_lock_windows_flavour(files_struct *fsp,
217                         uint64_t u_offset,
218                         uint64_t u_count,
219                         enum brl_type lock_type,
220                         const struct lock_context *lock_ctx,
221                         const struct lock_struct *plocks,
222                         int num_locks,
223                         int *errno_ret);
224 bool release_posix_lock_windows_flavour(files_struct *fsp,
225                                 uint64_t u_offset,
226                                 uint64_t u_count,
227                                 enum brl_type deleted_lock_type,
228                                 const struct lock_context *lock_ctx,
229                                 const struct lock_struct *plocks,
230                                 int num_locks);
231 bool set_posix_lock_posix_flavour(files_struct *fsp,
232                         uint64_t u_offset,
233                         uint64_t u_count,
234                         enum brl_type lock_type,
235                         const struct lock_context *lock_ctx,
236                         int *errno_ret);
237 bool release_posix_lock_posix_flavour(files_struct *fsp,
238                                 uint64_t u_offset,
239                                 uint64_t u_count,
240                                 const struct lock_context *lock_ctx,
241                                 const struct lock_struct *plocks,
242                                 int num_locks);
243
244 /* The following definitions come from locking/leases_util.c */
245 uint32_t map_oplock_to_lease_type(uint16_t op_type);
246 uint32_t fsp_lease_type(const struct files_struct *fsp);
247 uint32_t lease_type_is_exclusive(uint32_t lease_type);
248 bool fsp_lease_type_is_exclusive(const struct files_struct *fsp);
249
250 #endif /* _LOCKING_PROTO_H_ */