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