2 * Unix SMB/CIFS implementation.
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
,
38 NTSTATUS
brl_lock(struct messaging_context
*msg_ctx
,
39 struct byte_range_lock
*br_lck
,
44 enum brl_type lock_type
,
45 enum brl_flavour lock_flav
,
48 struct blocking_lock_record
*blr
);
49 bool brl_unlock(struct messaging_context
*msg_ctx
,
50 struct byte_range_lock
*br_lck
,
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
,
64 enum brl_type lock_type
,
65 enum brl_flavour lock_flav
);
66 NTSTATUS
brl_lockquery(struct byte_range_lock
*br_lck
,
71 enum brl_type
*plock_type
,
72 enum brl_flavour lock_flav
);
73 bool brl_lock_cancel(struct byte_range_lock
*br_lck
,
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
,
92 struct byte_range_lock
*brl_get_locks(TALLOC_CTX
*mem_ctx
,
94 struct byte_range_lock
*brl_get_locks_readonly(files_struct
*fsp
);
95 void brl_revalidate(struct messaging_context
*msg_ctx
,
98 struct server_id server_id
,
101 /* The following definitions come from locking/locking.c */
103 const char *lock_type_name(enum brl_type lock_type
);
104 const char *lock_flav_name(enum brl_flavour lock_flav
);
105 void init_strict_lock_struct(files_struct
*fsp
,
109 enum brl_type lock_type
,
110 struct lock_struct
*plock
);
111 bool strict_lock_default(files_struct
*fsp
,
112 struct lock_struct
*plock
);
113 void strict_unlock_default(files_struct
*fsp
,
114 struct lock_struct
*plock
);
115 NTSTATUS
query_lock(files_struct
*fsp
,
119 enum brl_type
*plock_type
,
120 enum brl_flavour lock_flav
);
121 struct byte_range_lock
*do_lock(struct messaging_context
*msg_ctx
,
126 enum brl_type lock_type
,
127 enum brl_flavour lock_flav
,
131 struct blocking_lock_record
*blr
);
132 NTSTATUS
do_unlock(struct messaging_context
*msg_ctx
,
137 enum brl_flavour lock_flav
);
138 NTSTATUS
do_lock_cancel(files_struct
*fsp
,
142 enum brl_flavour lock_flav
,
143 struct blocking_lock_record
*blr
);
144 void locking_close_file(struct messaging_context
*msg_ctx
,
146 enum file_close_type close_type
);
147 bool locking_init(void);
148 bool locking_init_readonly(void);
149 bool locking_end(void);
150 char *share_mode_str(TALLOC_CTX
*ctx
, int num
, const struct share_mode_entry
*e
);
151 struct share_mode_lock
*get_existing_share_mode_lock(TALLOC_CTX
*mem_ctx
,
152 const struct file_id id
);
153 struct share_mode_lock
*get_share_mode_lock(
155 const struct file_id id
,
156 const char *servicepath
,
157 const struct smb_filename
*smb_fname
,
158 const struct timespec
*old_write_time
);
159 struct share_mode_lock
*fetch_share_mode_unlocked(TALLOC_CTX
*mem_ctx
,
160 const struct file_id id
);
161 bool rename_share_filename(struct messaging_context
*msg_ctx
,
162 struct share_mode_lock
*lck
,
163 const char *servicepath
,
164 uint32_t orig_name_hash
,
165 uint32_t new_name_hash
,
166 const struct smb_filename
*smb_fname
);
167 void get_file_infos(struct file_id id
,
169 bool *delete_on_close
,
170 struct timespec
*write_time
);
171 bool is_valid_share_mode_entry(const struct share_mode_entry
*e
);
172 bool is_deferred_open_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 void add_deferred_open(struct share_mode_lock
*lck
, uint64_t mid
,
177 struct timeval request_time
,
178 struct server_id pid
, struct file_id id
);
179 bool del_share_mode(struct share_mode_lock
*lck
, files_struct
*fsp
);
180 bool mark_share_mode_disconnected(struct share_mode_lock
*lck
,
181 struct files_struct
*fsp
);
182 void del_deferred_open_entry(struct share_mode_lock
*lck
, uint64_t mid
,
183 struct server_id pid
);
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
,
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 int share_mode_forall(void (*fn
)(const struct share_mode_entry
*, const char *,
202 const char *, void *),
205 /* The following definitions come from locking/posix.c */
207 bool is_posix_locked(files_struct
*fsp
,
210 enum brl_type
*plock_type
,
211 enum brl_flavour lock_flav
);
212 bool posix_locking_init(bool read_only
);
213 bool posix_locking_end(void);
214 int fd_close_posix(struct files_struct
*fsp
);
215 bool set_posix_lock_windows_flavour(files_struct
*fsp
,
218 enum brl_type lock_type
,
219 const struct lock_context
*lock_ctx
,
220 const struct lock_struct
*plocks
,
223 bool release_posix_lock_windows_flavour(files_struct
*fsp
,
226 enum brl_type deleted_lock_type
,
227 const struct lock_context
*lock_ctx
,
228 const struct lock_struct
*plocks
,
230 bool set_posix_lock_posix_flavour(files_struct
*fsp
,
233 enum brl_type lock_type
,
235 bool release_posix_lock_posix_flavour(files_struct
*fsp
,
238 const struct lock_context
*lock_ctx
,
239 const struct lock_struct
*plocks
,
242 #endif /* _LOCKING_PROTO_H_ */