source: vendor/current/source3/locking/proto.h

Last change on this file was 988, checked in by Silvan Scherrer, 9 years ago

Samba Server: update vendor to version 4.4.3

File size: 8.8 KB
Line 
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
28void brl_init(bool read_only);
29void brl_shutdown(void);
30
31unsigned int brl_num_locks(const struct byte_range_lock *brl);
32struct files_struct *brl_fsp(struct byte_range_lock *brl);
33uint32_t brl_num_read_oplocks(const struct byte_range_lock *brl);
34void brl_set_num_read_oplocks(struct byte_range_lock *brl,
35 uint32_t num_read_oplocks);
36
37NTSTATUS brl_lock_windows_default(struct byte_range_lock *br_lck,
38 struct lock_struct *plock,
39 bool blocking_lock);
40
41NTSTATUS brl_lock(struct messaging_context *msg_ctx,
42 struct byte_range_lock *br_lck,
43 uint64_t smblctx,
44 struct server_id pid,
45 br_off start,
46 br_off size,
47 enum brl_type lock_type,
48 enum brl_flavour lock_flav,
49 bool blocking_lock,
50 uint64_t *psmblctx);
51bool brl_unlock(struct messaging_context *msg_ctx,
52 struct byte_range_lock *br_lck,
53 uint64_t smblctx,
54 struct server_id pid,
55 br_off start,
56 br_off size,
57 enum brl_flavour lock_flav);
58bool brl_unlock_windows_default(struct messaging_context *msg_ctx,
59 struct byte_range_lock *br_lck,
60 const struct lock_struct *plock);
61bool brl_locktest(struct byte_range_lock *br_lck,
62 const struct lock_struct *rw_probe);
63NTSTATUS brl_lockquery(struct byte_range_lock *br_lck,
64 uint64_t *psmblctx,
65 struct server_id pid,
66 br_off *pstart,
67 br_off *psize,
68 enum brl_type *plock_type,
69 enum brl_flavour lock_flav);
70bool brl_lock_cancel(struct byte_range_lock *br_lck,
71 uint64_t smblctx,
72 struct server_id pid,
73 br_off start,
74 br_off size,
75 enum brl_flavour lock_flav);
76bool brl_lock_cancel_default(struct byte_range_lock *br_lck,
77 struct lock_struct *plock);
78bool brl_mark_disconnected(struct files_struct *fsp);
79bool brl_reconnect_disconnected(struct files_struct *fsp);
80void brl_close_fnum(struct messaging_context *msg_ctx,
81 struct byte_range_lock *br_lck);
82int brl_forall(void (*fn)(struct file_id id, struct server_id pid,
83 enum brl_type lock_type,
84 enum brl_flavour lock_flav,
85 br_off start, br_off size,
86 void *private_data),
87 void *private_data);
88struct byte_range_lock *brl_get_locks(TALLOC_CTX *mem_ctx,
89 files_struct *fsp);
90struct byte_range_lock *brl_get_locks_readonly(files_struct *fsp);
91void brl_revalidate(struct messaging_context *msg_ctx,
92 void *private_data,
93 uint32_t msg_type,
94 struct server_id server_id,
95 DATA_BLOB *data);
96bool brl_cleanup_disconnected(struct file_id fid, uint64_t open_persistent_id);
97
98/* The following definitions come from locking/locking.c */
99
100const char *lock_type_name(enum brl_type lock_type);
101const char *lock_flav_name(enum brl_flavour lock_flav);
102void init_strict_lock_struct(files_struct *fsp,
103 uint64_t smblctx,
104 br_off start,
105 br_off size,
106 enum brl_type lock_type,
107 struct lock_struct *plock);
108bool strict_lock_default(files_struct *fsp,
109 struct lock_struct *plock);
110void strict_unlock_default(files_struct *fsp,
111 struct lock_struct *plock);
112NTSTATUS query_lock(files_struct *fsp,
113 uint64_t *psmblctx,
114 uint64_t *pcount,
115 uint64_t *poffset,
116 enum brl_type *plock_type,
117 enum brl_flavour lock_flav);
118struct byte_range_lock *do_lock(struct messaging_context *msg_ctx,
119 files_struct *fsp,
120 uint64_t smblctx,
121 uint64_t count,
122 uint64_t offset,
123 enum brl_type lock_type,
124 enum brl_flavour lock_flav,
125 bool blocking_lock,
126 NTSTATUS *perr,
127 uint64_t *psmblctx);
128NTSTATUS do_unlock(struct messaging_context *msg_ctx,
129 files_struct *fsp,
130 uint64_t smblctx,
131 uint64_t count,
132 uint64_t offset,
133 enum brl_flavour lock_flav);
134NTSTATUS do_lock_cancel(files_struct *fsp,
135 uint64_t smblctx,
136 uint64_t count,
137 uint64_t offset,
138 enum brl_flavour lock_flav);
139void locking_close_file(struct messaging_context *msg_ctx,
140 files_struct *fsp,
141 enum file_close_type close_type);
142bool locking_init(void);
143bool locking_init_readonly(void);
144bool locking_end(void);
145char *share_mode_str(TALLOC_CTX *ctx, int num, const struct share_mode_entry *e);
146struct share_mode_lock *get_existing_share_mode_lock(TALLOC_CTX *mem_ctx,
147 struct file_id id);
148struct share_mode_lock *get_share_mode_lock(
149 TALLOC_CTX *mem_ctx,
150 struct file_id id,
151 const char *servicepath,
152 const struct smb_filename *smb_fname,
153 const struct timespec *old_write_time);
154struct share_mode_lock *fetch_share_mode_unlocked(TALLOC_CTX *mem_ctx,
155 struct file_id id);
156bool rename_share_filename(struct messaging_context *msg_ctx,
157 struct share_mode_lock *lck,
158 struct file_id id,
159 const char *servicepath,
160 uint32_t orig_name_hash,
161 uint32_t new_name_hash,
162 const struct smb_filename *smb_fname);
163void get_file_infos(struct file_id id,
164 uint32_t name_hash,
165 bool *delete_on_close,
166 struct timespec *write_time);
167bool is_valid_share_mode_entry(const struct share_mode_entry *e);
168bool share_mode_stale_pid(struct share_mode_data *d, uint32_t idx);
169bool set_share_mode(struct share_mode_lock *lck, struct files_struct *fsp,
170 uid_t uid, uint64_t mid, uint16_t op_type,
171 uint32_t lease_idx);
172void remove_stale_share_mode_entries(struct share_mode_data *d);
173bool del_share_mode(struct share_mode_lock *lck, files_struct *fsp);
174bool mark_share_mode_disconnected(struct share_mode_lock *lck,
175 struct files_struct *fsp);
176bool remove_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
177bool downgrade_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
178struct share_mode_lease;
179NTSTATUS downgrade_share_lease(struct smbd_server_connection *sconn,
180 struct share_mode_lock *lck,
181 const struct smb2_lease_key *key,
182 uint32_t new_lease_state,
183 struct share_mode_lease **_l);
184bool get_delete_on_close_token(struct share_mode_lock *lck,
185 uint32_t name_hash,
186 const struct security_token **pp_nt_tok,
187 const struct security_unix_token **pp_tok);
188void reset_delete_on_close_lck(files_struct *fsp,
189 struct share_mode_lock *lck);
190void set_delete_on_close_lck(files_struct *fsp,
191 struct share_mode_lock *lck,
192 const struct security_token *nt_tok,
193 const struct security_unix_token *tok);
194bool set_delete_on_close(files_struct *fsp, bool delete_on_close,
195 const struct security_token *nt_tok,
196 const struct security_unix_token *tok);
197bool is_delete_on_close_set(struct share_mode_lock *lck, uint32_t name_hash);
198bool set_sticky_write_time(struct file_id fileid, struct timespec write_time);
199bool set_write_time(struct file_id fileid, struct timespec write_time);
200struct timespec get_share_mode_write_time(struct share_mode_lock *lck);
201int share_mode_forall(int (*fn)(struct file_id fid,
202 const struct share_mode_data *data,
203 void *private_data),
204 void *private_data);
205int share_entry_forall(int (*fn)(const struct share_mode_entry *,
206 const char *, const char *,
207 const char *, void *),
208 void *private_data);
209bool share_mode_cleanup_disconnected(struct file_id id,
210 uint64_t open_persistent_id);
211
212
213/* The following definitions come from locking/posix.c */
214
215bool is_posix_locked(files_struct *fsp,
216 uint64_t *pu_offset,
217 uint64_t *pu_count,
218 enum brl_type *plock_type,
219 enum brl_flavour lock_flav);
220bool posix_locking_init(bool read_only);
221bool posix_locking_end(void);
222int fd_close_posix(struct files_struct *fsp);
223bool set_posix_lock_windows_flavour(files_struct *fsp,
224 uint64_t u_offset,
225 uint64_t u_count,
226 enum brl_type lock_type,
227 const struct lock_context *lock_ctx,
228 const struct lock_struct *plocks,
229 int num_locks,
230 int *errno_ret);
231bool release_posix_lock_windows_flavour(files_struct *fsp,
232 uint64_t u_offset,
233 uint64_t u_count,
234 enum brl_type deleted_lock_type,
235 const struct lock_context *lock_ctx,
236 const struct lock_struct *plocks,
237 int num_locks);
238bool set_posix_lock_posix_flavour(files_struct *fsp,
239 uint64_t u_offset,
240 uint64_t u_count,
241 enum brl_type lock_type,
242 int *errno_ret);
243bool release_posix_lock_posix_flavour(files_struct *fsp,
244 uint64_t u_offset,
245 uint64_t u_count,
246 const struct lock_context *lock_ctx,
247 const struct lock_struct *plocks,
248 int num_locks);
249
250#endif /* _LOCKING_PROTO_H_ */
Note: See TracBrowser for help on using the repository browser.