s3:locking/proto.h: add GPL/Copyright header (cherry picked from commit 93b8e90b5beb5...
[Samba.git] / source3 / locking / proto.h
blob2726a1df2519d3ad3762ea4463b808e59f9518d5
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 /* 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,
33 bool blocking_lock);
35 NTSTATUS brl_lock(struct messaging_context *msg_ctx,
36 struct byte_range_lock *br_lck,
37 uint64_t smblctx,
38 struct server_id pid,
39 br_off start,
40 br_off size,
41 enum brl_type lock_type,
42 enum brl_flavour lock_flav,
43 bool blocking_lock,
44 uint64_t *psmblctx,
45 struct blocking_lock_record *blr);
46 bool brl_unlock(struct messaging_context *msg_ctx,
47 struct byte_range_lock *br_lck,
48 uint64_t smblctx,
49 struct server_id pid,
50 br_off start,
51 br_off size,
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,
57 uint64_t smblctx,
58 struct server_id pid,
59 br_off start,
60 br_off size,
61 enum brl_type lock_type,
62 enum brl_flavour lock_flav);
63 NTSTATUS brl_lockquery(struct byte_range_lock *br_lck,
64 uint64_t *psmblctx,
65 struct server_id pid,
66 br_off *pstart,
67 br_off *psize,
68 enum brl_type *plock_type,
69 enum brl_flavour lock_flav);
70 bool brl_lock_cancel(struct byte_range_lock *br_lck,
71 uint64_t smblctx,
72 struct server_id pid,
73 br_off start,
74 br_off size,
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,
85 void *private_data),
86 void *private_data);
87 struct byte_range_lock *brl_get_locks(TALLOC_CTX *mem_ctx,
88 files_struct *fsp);
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,
97 uint64_t smblctx,
98 br_off start,
99 br_off size,
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,
107 uint64_t *psmblctx,
108 uint64_t *pcount,
109 uint64_t *poffset,
110 enum brl_type *plock_type,
111 enum brl_flavour lock_flav);
112 struct byte_range_lock *do_lock(struct messaging_context *msg_ctx,
113 files_struct *fsp,
114 uint64_t smblctx,
115 uint64_t count,
116 uint64_t offset,
117 enum brl_type lock_type,
118 enum brl_flavour lock_flav,
119 bool blocking_lock,
120 NTSTATUS *perr,
121 uint64_t *psmblctx,
122 struct blocking_lock_record *blr);
123 NTSTATUS do_unlock(struct messaging_context *msg_ctx,
124 files_struct *fsp,
125 uint64_t smblctx,
126 uint64_t count,
127 uint64_t offset,
128 enum brl_flavour lock_flav);
129 NTSTATUS do_lock_cancel(files_struct *fsp,
130 uint64 smblctx,
131 uint64_t count,
132 uint64_t offset,
133 enum brl_flavour lock_flav,
134 struct blocking_lock_record *blr);
135 void locking_close_file(struct messaging_context *msg_ctx,
136 files_struct *fsp,
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,
156 uint32_t name_hash,
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 *),
184 void *private_data);
186 /* The following definitions come from locking/posix.c */
188 bool is_posix_locked(files_struct *fsp,
189 uint64_t *pu_offset,
190 uint64_t *pu_count,
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,
198 uint64_t u_offset,
199 uint64_t u_count,
200 enum brl_type lock_type,
201 const struct lock_context *lock_ctx,
202 const struct lock_struct *plocks,
203 int num_locks,
204 int *errno_ret);
205 bool release_posix_lock_windows_flavour(files_struct *fsp,
206 uint64_t u_offset,
207 uint64_t u_count,
208 enum brl_type deleted_lock_type,
209 const struct lock_context *lock_ctx,
210 const struct lock_struct *plocks,
211 int num_locks);
212 bool set_posix_lock_posix_flavour(files_struct *fsp,
213 uint64_t u_offset,
214 uint64_t u_count,
215 enum brl_type lock_type,
216 int *errno_ret);
217 bool release_posix_lock_posix_flavour(files_struct *fsp,
218 uint64_t u_offset,
219 uint64_t u_count,
220 const struct lock_context *lock_ctx,
221 const struct lock_struct *plocks,
222 int num_locks);