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 /* The following definitions come from locking/brlock.c */
25 bool brl_same_context(const struct lock_context
*ctx1
,
26 const struct lock_context
*ctx2
);
27 NTSTATUS
brl_lock_failed(files_struct
*fsp
, const struct lock_struct
*lock
, bool blocking_lock
);
28 void brl_init(bool read_only
);
29 void brl_shutdown(void);
31 NTSTATUS
brl_lock_windows_default(struct byte_range_lock
*br_lck
,
32 struct lock_struct
*plock
,
35 NTSTATUS
brl_lock(struct messaging_context
*msg_ctx
,
36 struct byte_range_lock
*br_lck
,
41 enum brl_type lock_type
,
42 enum brl_flavour lock_flav
,
45 struct blocking_lock_record
*blr
);
46 bool brl_unlock(struct messaging_context
*msg_ctx
,
47 struct byte_range_lock
*br_lck
,
52 enum brl_flavour lock_flav
);
53 bool brl_unlock_windows_default(struct messaging_context
*msg_ctx
,
54 struct byte_range_lock
*br_lck
,
55 const struct lock_struct
*plock
);
56 bool brl_locktest(struct byte_range_lock
*br_lck
,
61 enum brl_type lock_type
,
62 enum brl_flavour lock_flav
);
63 NTSTATUS
brl_lockquery(struct byte_range_lock
*br_lck
,
68 enum brl_type
*plock_type
,
69 enum brl_flavour lock_flav
);
70 bool brl_lock_cancel(struct byte_range_lock
*br_lck
,
75 enum brl_flavour lock_flav
,
76 struct blocking_lock_record
*blr
);
77 bool brl_lock_cancel_default(struct byte_range_lock
*br_lck
,
78 struct lock_struct
*plock
);
79 void brl_close_fnum(struct messaging_context
*msg_ctx
,
80 struct byte_range_lock
*br_lck
);
81 int brl_forall(void (*fn
)(struct file_id id
, struct server_id pid
,
82 enum brl_type lock_type
,
83 enum brl_flavour lock_flav
,
84 br_off start
, br_off size
,
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 void brl_register_msgs(struct messaging_context
*msg_ctx
);
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 struct lock_struct
*plock
);
102 bool strict_lock_default(files_struct
*fsp
,
103 struct lock_struct
*plock
);
104 void strict_unlock_default(files_struct
*fsp
,
105 struct lock_struct
*plock
);
106 NTSTATUS
query_lock(files_struct
*fsp
,
110 enum brl_type
*plock_type
,
111 enum brl_flavour lock_flav
);
112 struct byte_range_lock
*do_lock(struct messaging_context
*msg_ctx
,
117 enum brl_type lock_type
,
118 enum brl_flavour lock_flav
,
122 struct blocking_lock_record
*blr
);
123 NTSTATUS
do_unlock(struct messaging_context
*msg_ctx
,
128 enum brl_flavour lock_flav
);
129 NTSTATUS
do_lock_cancel(files_struct
*fsp
,
133 enum brl_flavour lock_flav
,
134 struct blocking_lock_record
*blr
);
135 void locking_close_file(struct messaging_context
*msg_ctx
,
137 enum file_close_type close_type
);
138 bool locking_init(void);
139 bool locking_init_readonly(void);
140 bool locking_end(void);
141 char *share_mode_str(TALLOC_CTX
*ctx
, int num
, const struct share_mode_entry
*e
);
142 struct share_mode_lock
*get_share_mode_lock(TALLOC_CTX
*mem_ctx
,
143 const struct file_id id
,
144 const char *servicepath
,
145 const struct smb_filename
*smb_fname
,
146 const struct timespec
*old_write_time
);
147 struct share_mode_lock
*fetch_share_mode_unlocked(TALLOC_CTX
*mem_ctx
,
148 const struct file_id id
);
149 bool rename_share_filename(struct messaging_context
*msg_ctx
,
150 struct share_mode_lock
*lck
,
151 const char *servicepath
,
152 uint32_t orig_name_hash
,
153 uint32_t new_name_hash
,
154 const struct smb_filename
*smb_fname
);
155 void get_file_infos(struct file_id id
,
157 bool *delete_on_close
,
158 struct timespec
*write_time
);
159 bool is_valid_share_mode_entry(const struct share_mode_entry
*e
);
160 bool is_deferred_open_entry(const struct share_mode_entry
*e
);
161 bool is_unused_share_mode_entry(const struct share_mode_entry
*e
);
162 void set_share_mode(struct share_mode_lock
*lck
, files_struct
*fsp
,
163 uid_t uid
, uint64_t mid
, uint16 op_type
);
164 void add_deferred_open(struct share_mode_lock
*lck
, uint64_t mid
,
165 struct timeval request_time
,
166 struct server_id pid
, struct file_id id
);
167 bool del_share_mode(struct share_mode_lock
*lck
, files_struct
*fsp
);
168 void del_deferred_open_entry(struct share_mode_lock
*lck
, uint64_t mid
,
169 struct server_id pid
);
170 bool remove_share_oplock(struct share_mode_lock
*lck
, files_struct
*fsp
);
171 bool downgrade_share_oplock(struct share_mode_lock
*lck
, files_struct
*fsp
);
172 NTSTATUS
can_set_delete_on_close(files_struct
*fsp
, uint32 dosmode
);
173 const struct security_unix_token
*get_delete_on_close_token(struct share_mode_lock
*lck
, uint32_t name_hash
);
174 void set_delete_on_close_lck(files_struct
*fsp
,
175 struct share_mode_lock
*lck
,
176 bool delete_on_close
,
177 const struct security_unix_token
*tok
);
178 bool set_delete_on_close(files_struct
*fsp
, bool delete_on_close
, const struct security_unix_token
*tok
);
179 bool is_delete_on_close_set(struct share_mode_lock
*lck
, uint32_t name_hash
);
180 bool set_sticky_write_time(struct file_id fileid
, struct timespec write_time
);
181 bool set_write_time(struct file_id fileid
, struct timespec write_time
);
182 int share_mode_forall(void (*fn
)(const struct share_mode_entry
*, const char *,
183 const char *, void *),
186 /* The following definitions come from locking/posix.c */
188 bool is_posix_locked(files_struct
*fsp
,
191 enum brl_type
*plock_type
,
192 enum brl_flavour lock_flav
);
193 bool posix_locking_init(bool read_only
);
194 bool posix_locking_end(void);
195 void reduce_windows_lock_ref_count(files_struct
*fsp
, unsigned int dcount
);
196 int fd_close_posix(struct files_struct
*fsp
);
197 bool set_posix_lock_windows_flavour(files_struct
*fsp
,
200 enum brl_type lock_type
,
201 const struct lock_context
*lock_ctx
,
202 const struct lock_struct
*plocks
,
205 bool release_posix_lock_windows_flavour(files_struct
*fsp
,
208 enum brl_type deleted_lock_type
,
209 const struct lock_context
*lock_ctx
,
210 const struct lock_struct
*plocks
,
212 bool set_posix_lock_posix_flavour(files_struct
*fsp
,
215 enum brl_type lock_type
,
217 bool release_posix_lock_posix_flavour(files_struct
*fsp
,
220 const struct lock_context
*lock_ctx
,
221 const struct lock_struct
*plocks
,