s4:samba_kcc: Use 'dburl' passed from command line rather than lp.samdb_url()
[Samba.git] / source3 / locking / proto.h
blobdc115e1d9695918684896b0ff5e2de8647edcbea
1 /*
2 * Unix SMB/CIFS implementation.
3 * Locking functions
5 * Copyright (C) Andrew Tridgell 1992-2000
6 * Copyright (C) Jeremy Allison 1992-2006
7 * Copyright (C) Volker Lendecke 2005
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.
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.
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/>.
23 #ifndef _LOCKING_PROTO_H_
24 #define _LOCKING_PROTO_H_
26 /* The following definitions come from locking/brlock.c */
28 void brl_init(bool read_only);
29 void brl_shutdown(void);
31 unsigned int brl_num_locks(const struct byte_range_lock *brl);
32 struct files_struct *brl_fsp(struct byte_range_lock *brl);
33 bool brl_have_read_oplocks(const struct byte_range_lock *brl);
34 void brl_set_have_read_oplocks(struct byte_range_lock *brl,
35 bool have_read_oplocks);
37 NTSTATUS brl_lock_windows_default(struct byte_range_lock *br_lck,
38 struct lock_struct *plock,
39 bool blocking_lock);
41 NTSTATUS 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,
51 struct blocking_lock_record *blr);
52 bool brl_unlock(struct messaging_context *msg_ctx,
53 struct byte_range_lock *br_lck,
54 uint64_t smblctx,
55 struct server_id pid,
56 br_off start,
57 br_off size,
58 enum brl_flavour lock_flav);
59 bool brl_unlock_windows_default(struct messaging_context *msg_ctx,
60 struct byte_range_lock *br_lck,
61 const struct lock_struct *plock);
62 bool brl_locktest(struct byte_range_lock *br_lck,
63 uint64_t smblctx,
64 struct server_id pid,
65 br_off start,
66 br_off size,
67 enum brl_type lock_type,
68 enum brl_flavour lock_flav);
69 NTSTATUS brl_lockquery(struct byte_range_lock *br_lck,
70 uint64_t *psmblctx,
71 struct server_id pid,
72 br_off *pstart,
73 br_off *psize,
74 enum brl_type *plock_type,
75 enum brl_flavour lock_flav);
76 bool brl_lock_cancel(struct byte_range_lock *br_lck,
77 uint64_t smblctx,
78 struct server_id pid,
79 br_off start,
80 br_off size,
81 enum brl_flavour lock_flav,
82 struct blocking_lock_record *blr);
83 bool brl_lock_cancel_default(struct byte_range_lock *br_lck,
84 struct lock_struct *plock);
85 bool brl_mark_disconnected(struct files_struct *fsp);
86 bool brl_reconnect_disconnected(struct files_struct *fsp);
87 void brl_close_fnum(struct messaging_context *msg_ctx,
88 struct byte_range_lock *br_lck);
89 int brl_forall(void (*fn)(struct file_id id, struct server_id pid,
90 enum brl_type lock_type,
91 enum brl_flavour lock_flav,
92 br_off start, br_off size,
93 void *private_data),
94 void *private_data);
95 struct byte_range_lock *brl_get_locks(TALLOC_CTX *mem_ctx,
96 files_struct *fsp);
97 struct byte_range_lock *brl_get_locks_readonly(files_struct *fsp);
98 void brl_revalidate(struct messaging_context *msg_ctx,
99 void *private_data,
100 uint32_t msg_type,
101 struct server_id server_id,
102 DATA_BLOB *data);
103 bool brl_cleanup_disconnected(struct file_id fid, uint64_t open_persistent_id);
105 /* The following definitions come from locking/locking.c */
107 const char *lock_type_name(enum brl_type lock_type);
108 const char *lock_flav_name(enum brl_flavour lock_flav);
109 void init_strict_lock_struct(files_struct *fsp,
110 uint64_t smblctx,
111 br_off start,
112 br_off size,
113 enum brl_type lock_type,
114 struct lock_struct *plock);
115 bool strict_lock_default(files_struct *fsp,
116 struct lock_struct *plock);
117 void strict_unlock_default(files_struct *fsp,
118 struct lock_struct *plock);
119 NTSTATUS query_lock(files_struct *fsp,
120 uint64_t *psmblctx,
121 uint64_t *pcount,
122 uint64_t *poffset,
123 enum brl_type *plock_type,
124 enum brl_flavour lock_flav);
125 struct byte_range_lock *do_lock(struct messaging_context *msg_ctx,
126 files_struct *fsp,
127 uint64_t smblctx,
128 uint64_t count,
129 uint64_t offset,
130 enum brl_type lock_type,
131 enum brl_flavour lock_flav,
132 bool blocking_lock,
133 NTSTATUS *perr,
134 uint64_t *psmblctx,
135 struct blocking_lock_record *blr);
136 NTSTATUS do_unlock(struct messaging_context *msg_ctx,
137 files_struct *fsp,
138 uint64_t smblctx,
139 uint64_t count,
140 uint64_t offset,
141 enum brl_flavour lock_flav);
142 NTSTATUS do_lock_cancel(files_struct *fsp,
143 uint64 smblctx,
144 uint64_t count,
145 uint64_t offset,
146 enum brl_flavour lock_flav,
147 struct blocking_lock_record *blr);
148 void locking_close_file(struct messaging_context *msg_ctx,
149 files_struct *fsp,
150 enum file_close_type close_type);
151 bool locking_init(void);
152 bool locking_init_readonly(void);
153 bool locking_end(void);
154 char *share_mode_str(TALLOC_CTX *ctx, int num, const struct share_mode_entry *e);
155 struct share_mode_lock *get_existing_share_mode_lock(TALLOC_CTX *mem_ctx,
156 struct file_id id);
157 struct share_mode_lock *get_share_mode_lock(
158 TALLOC_CTX *mem_ctx,
159 struct file_id id,
160 const char *servicepath,
161 const struct smb_filename *smb_fname,
162 const struct timespec *old_write_time);
163 struct share_mode_lock *fetch_share_mode_unlocked(TALLOC_CTX *mem_ctx,
164 struct file_id id);
165 bool rename_share_filename(struct messaging_context *msg_ctx,
166 struct share_mode_lock *lck,
167 struct file_id id,
168 const char *servicepath,
169 uint32_t orig_name_hash,
170 uint32_t new_name_hash,
171 const struct smb_filename *smb_fname);
172 void get_file_infos(struct file_id id,
173 uint32_t name_hash,
174 bool *delete_on_close,
175 struct timespec *write_time);
176 bool is_valid_share_mode_entry(const struct share_mode_entry *e);
177 bool share_mode_stale_pid(struct share_mode_data *d, uint32_t idx);
178 bool set_share_mode(struct share_mode_lock *lck, files_struct *fsp,
179 uid_t uid, uint64_t mid, uint16 op_type);
180 void remove_stale_share_mode_entries(struct share_mode_data *d);
181 bool del_share_mode(struct share_mode_lock *lck, files_struct *fsp);
182 bool mark_share_mode_disconnected(struct share_mode_lock *lck,
183 struct files_struct *fsp);
184 bool remove_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
185 bool downgrade_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
186 bool get_delete_on_close_token(struct share_mode_lock *lck,
187 uint32_t name_hash,
188 const struct security_token **pp_nt_tok,
189 const struct security_unix_token **pp_tok);
190 void set_delete_on_close_lck(files_struct *fsp,
191 struct share_mode_lock *lck,
192 bool delete_on_close,
193 const struct security_token *nt_tok,
194 const struct security_unix_token *tok);
195 bool set_delete_on_close(files_struct *fsp, bool delete_on_close,
196 const struct security_token *nt_tok,
197 const struct security_unix_token *tok);
198 bool is_delete_on_close_set(struct share_mode_lock *lck, uint32_t name_hash);
199 bool set_sticky_write_time(struct file_id fileid, struct timespec write_time);
200 bool set_write_time(struct file_id fileid, struct timespec write_time);
201 struct timespec get_share_mode_write_time(struct share_mode_lock *lck);
202 int share_mode_forall(void (*fn)(const struct share_mode_entry *, const char *,
203 const char *, void *),
204 void *private_data);
205 bool share_mode_cleanup_disconnected(struct file_id id,
206 uint64_t open_persistent_id);
209 /* The following definitions come from locking/posix.c */
211 bool is_posix_locked(files_struct *fsp,
212 uint64_t *pu_offset,
213 uint64_t *pu_count,
214 enum brl_type *plock_type,
215 enum brl_flavour lock_flav);
216 bool posix_locking_init(bool read_only);
217 bool posix_locking_end(void);
218 int fd_close_posix(struct files_struct *fsp);
219 bool set_posix_lock_windows_flavour(files_struct *fsp,
220 uint64_t u_offset,
221 uint64_t u_count,
222 enum brl_type lock_type,
223 const struct lock_context *lock_ctx,
224 const struct lock_struct *plocks,
225 int num_locks,
226 int *errno_ret);
227 bool release_posix_lock_windows_flavour(files_struct *fsp,
228 uint64_t u_offset,
229 uint64_t u_count,
230 enum brl_type deleted_lock_type,
231 const struct lock_context *lock_ctx,
232 const struct lock_struct *plocks,
233 int num_locks);
234 bool set_posix_lock_posix_flavour(files_struct *fsp,
235 uint64_t u_offset,
236 uint64_t u_count,
237 enum brl_type lock_type,
238 int *errno_ret);
239 bool release_posix_lock_posix_flavour(files_struct *fsp,
240 uint64_t u_offset,
241 uint64_t u_count,
242 const struct lock_context *lock_ctx,
243 const struct lock_struct *plocks,
244 int num_locks);
246 #endif /* _LOCKING_PROTO_H_ */