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_
28 /* The following definitions come from locking/brlock.c */
30 void brl_init(bool read_only
);
31 void brl_shutdown(void);
33 unsigned int brl_num_locks(const struct byte_range_lock
*brl
);
34 struct files_struct
*brl_fsp(struct byte_range_lock
*brl
);
35 TALLOC_CTX
*brl_req_mem_ctx(const struct byte_range_lock
*brl
);
36 const struct GUID
*brl_req_guid(const struct byte_range_lock
*brl
);
38 bool byte_range_valid(uint64_t ofs
, uint64_t len
);
39 bool byte_range_overlap(uint64_t ofs1
,
44 NTSTATUS
brl_lock_windows_default(struct byte_range_lock
*br_lck
,
45 struct lock_struct
*plock
);
48 struct byte_range_lock
*br_lck
,
53 enum brl_type lock_type
,
54 enum brl_flavour lock_flav
,
55 struct server_id
*blocker_pid
,
57 bool brl_unlock(struct byte_range_lock
*br_lck
,
62 enum brl_flavour lock_flav
);
63 bool brl_unlock_windows_default(struct byte_range_lock
*br_lck
,
64 const struct lock_struct
*plock
);
65 bool brl_locktest(struct byte_range_lock
*br_lck
,
66 const struct lock_struct
*rw_probe
);
67 NTSTATUS
brl_lockquery(struct byte_range_lock
*br_lck
,
72 enum brl_type
*plock_type
,
73 enum brl_flavour lock_flav
);
74 bool brl_mark_disconnected(struct files_struct
*fsp
);
75 bool brl_reconnect_disconnected(struct files_struct
*fsp
);
76 void brl_close_fnum(struct byte_range_lock
*br_lck
);
77 int brl_forall(void (*fn
)(struct file_id id
, struct server_id pid
,
78 enum brl_type lock_type
,
79 enum brl_flavour lock_flav
,
80 br_off start
, br_off size
,
83 struct byte_range_lock
*brl_get_locks_for_locking(TALLOC_CTX
*mem_ctx
,
85 TALLOC_CTX
*req_mem_ctx
,
86 const struct GUID
*req_guid
);
87 struct byte_range_lock
*brl_get_locks(TALLOC_CTX
*mem_ctx
,
89 struct byte_range_lock
*brl_get_locks_readonly(files_struct
*fsp
);
90 bool brl_cleanup_disconnected(struct file_id fid
, uint64_t open_persistent_id
);
92 /* The following definitions come from locking/locking.c */
94 const char *lock_type_name(enum brl_type lock_type
);
95 const char *lock_flav_name(enum brl_flavour lock_flav
);
96 void init_strict_lock_struct(files_struct
*fsp
,
100 enum brl_type lock_type
,
101 enum brl_flavour lock_flav
,
102 struct lock_struct
*plock
);
103 bool strict_lock_check_default(files_struct
*fsp
,
104 struct lock_struct
*plock
);
105 NTSTATUS
query_lock(files_struct
*fsp
,
109 enum brl_type
*plock_type
,
110 enum brl_flavour lock_flav
);
111 NTSTATUS
do_lock(files_struct
*fsp
,
112 TALLOC_CTX
*req_mem_ctx
,
113 const struct GUID
*req_guid
,
117 enum brl_type lock_type
,
118 enum brl_flavour lock_flav
,
119 struct server_id
*pblocker_pid
,
121 NTSTATUS
do_unlock(files_struct
*fsp
,
125 enum brl_flavour lock_flav
);
126 void locking_close_file(files_struct
*fsp
,
127 enum file_close_type close_type
);
128 char *share_mode_str(TALLOC_CTX
*ctx
, int num
,
129 const struct file_id
*id
,
130 const struct share_mode_entry
*e
);
132 bool rename_share_filename(struct messaging_context
*msg_ctx
,
133 struct share_mode_lock
*lck
,
135 const char *servicepath
,
136 uint32_t orig_name_hash
,
137 uint32_t new_name_hash
,
138 const struct smb_filename
*smb_fname
);
139 void get_file_infos(struct file_id id
,
141 bool *delete_on_close
,
142 struct timespec
*write_time
);
143 bool is_valid_share_mode_entry(const struct share_mode_entry
*e
);
144 bool share_entry_stale_pid(struct share_mode_entry
*e
);
145 NTSTATUS
remove_lease_if_stale(struct share_mode_lock
*lck
,
146 const struct GUID
*client_guid
,
147 const struct smb2_lease_key
*lease_key
);
148 bool get_delete_on_close_token(struct share_mode_lock
*lck
,
150 const struct security_token
**pp_nt_tok
,
151 const struct security_unix_token
**pp_tok
);
152 void reset_delete_on_close_lck(files_struct
*fsp
,
153 struct share_mode_lock
*lck
);
154 void set_delete_on_close_lck(files_struct
*fsp
,
155 struct share_mode_lock
*lck
,
156 const struct security_token
*nt_tok
,
157 const struct security_unix_token
*tok
);
158 bool set_delete_on_close(files_struct
*fsp
, bool delete_on_close
,
159 const struct security_token
*nt_tok
,
160 const struct security_unix_token
*tok
);
161 bool is_delete_on_close_set(struct share_mode_lock
*lck
, uint32_t name_hash
);
162 bool set_sticky_write_time(struct file_id fileid
, struct timespec write_time
);
163 bool set_write_time(struct file_id fileid
, struct timespec write_time
);
164 struct timespec
get_share_mode_write_time(struct share_mode_lock
*lck
);
165 bool file_has_open_streams(files_struct
*fsp
);
166 bool share_mode_forall_leases(
167 struct share_mode_lock
*lck
,
168 bool (*fn
)(struct share_mode_entry
*e
,
172 /* The following definitions come from locking/posix.c */
174 bool is_posix_locked(files_struct
*fsp
,
177 enum brl_type
*plock_type
,
178 enum brl_flavour lock_flav
);
179 bool posix_locking_init(bool read_only
);
180 bool posix_locking_end(void);
181 int fd_close_posix(const struct files_struct
*fsp
);
182 bool set_posix_lock_windows_flavour(files_struct
*fsp
,
185 enum brl_type lock_type
,
186 const struct lock_context
*lock_ctx
,
187 const struct lock_struct
*plocks
,
190 bool release_posix_lock_windows_flavour(files_struct
*fsp
,
193 enum brl_type deleted_lock_type
,
194 const struct lock_context
*lock_ctx
,
195 const struct lock_struct
*plocks
,
197 bool set_posix_lock_posix_flavour(files_struct
*fsp
,
200 enum brl_type lock_type
,
201 const struct lock_context
*lock_ctx
,
203 bool release_posix_lock_posix_flavour(files_struct
*fsp
,
206 const struct lock_context
*lock_ctx
,
207 const struct lock_struct
*plocks
,
210 /* The following definitions come from locking/leases_util.c */
211 uint32_t map_oplock_to_lease_type(uint16_t op_type
);
212 uint32_t fsp_lease_type(struct files_struct
*fsp
);
213 const struct GUID
*fsp_client_guid(const files_struct
*fsp
);
215 #endif /* _LOCKING_PROTO_H_ */