1 | /*
|
---|
2 | * Unix SMB/CIFS implementation.
|
---|
3 | * Locking functions
|
---|
4 | *
|
---|
5 | * Copyright (C) Andrew Tridgell 1992-2000
|
---|
6 | * Copyright (C) Jeremy Allison 1992-2006
|
---|
7 | * Copyright (C) Volker Lendecke 2005
|
---|
8 | *
|
---|
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.
|
---|
13 | *
|
---|
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.
|
---|
18 | *
|
---|
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/>.
|
---|
21 | */
|
---|
22 |
|
---|
23 | #ifndef _LOCKING_PROTO_H_
|
---|
24 | #define _LOCKING_PROTO_H_
|
---|
25 |
|
---|
26 | /* The following definitions come from locking/brlock.c */
|
---|
27 |
|
---|
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);
|
---|
33 |
|
---|
34 | NTSTATUS brl_lock_windows_default(struct byte_range_lock *br_lck,
|
---|
35 | struct lock_struct *plock,
|
---|
36 | bool blocking_lock);
|
---|
37 |
|
---|
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 | void brl_close_fnum(struct messaging_context *msg_ctx,
|
---|
83 | struct byte_range_lock *br_lck);
|
---|
84 | int brl_forall(void (*fn)(struct file_id id, struct server_id pid,
|
---|
85 | enum brl_type lock_type,
|
---|
86 | enum brl_flavour lock_flav,
|
---|
87 | br_off start, br_off size,
|
---|
88 | void *private_data),
|
---|
89 | void *private_data);
|
---|
90 | struct byte_range_lock *brl_get_locks(TALLOC_CTX *mem_ctx,
|
---|
91 | files_struct *fsp);
|
---|
92 | struct byte_range_lock *brl_get_locks_readonly(files_struct *fsp);
|
---|
93 | void brl_register_msgs(struct messaging_context *msg_ctx);
|
---|
94 |
|
---|
95 | /* The following definitions come from locking/locking.c */
|
---|
96 |
|
---|
97 | const char *lock_type_name(enum brl_type lock_type);
|
---|
98 | const char *lock_flav_name(enum brl_flavour lock_flav);
|
---|
99 | void init_strict_lock_struct(files_struct *fsp,
|
---|
100 | uint64_t smblctx,
|
---|
101 | br_off start,
|
---|
102 | br_off size,
|
---|
103 | enum brl_type lock_type,
|
---|
104 | struct lock_struct *plock);
|
---|
105 | bool strict_lock_default(files_struct *fsp,
|
---|
106 | struct lock_struct *plock);
|
---|
107 | void strict_unlock_default(files_struct *fsp,
|
---|
108 | struct lock_struct *plock);
|
---|
109 | NTSTATUS query_lock(files_struct *fsp,
|
---|
110 | uint64_t *psmblctx,
|
---|
111 | uint64_t *pcount,
|
---|
112 | uint64_t *poffset,
|
---|
113 | enum brl_type *plock_type,
|
---|
114 | enum brl_flavour lock_flav);
|
---|
115 | struct byte_range_lock *do_lock(struct messaging_context *msg_ctx,
|
---|
116 | files_struct *fsp,
|
---|
117 | uint64_t smblctx,
|
---|
118 | uint64_t count,
|
---|
119 | uint64_t offset,
|
---|
120 | enum brl_type lock_type,
|
---|
121 | enum brl_flavour lock_flav,
|
---|
122 | bool blocking_lock,
|
---|
123 | NTSTATUS *perr,
|
---|
124 | uint64_t *psmblctx,
|
---|
125 | struct blocking_lock_record *blr);
|
---|
126 | NTSTATUS do_unlock(struct messaging_context *msg_ctx,
|
---|
127 | files_struct *fsp,
|
---|
128 | uint64_t smblctx,
|
---|
129 | uint64_t count,
|
---|
130 | uint64_t offset,
|
---|
131 | enum brl_flavour lock_flav);
|
---|
132 | NTSTATUS do_lock_cancel(files_struct *fsp,
|
---|
133 | uint64 smblctx,
|
---|
134 | uint64_t count,
|
---|
135 | uint64_t offset,
|
---|
136 | enum brl_flavour lock_flav,
|
---|
137 | struct blocking_lock_record *blr);
|
---|
138 | void locking_close_file(struct messaging_context *msg_ctx,
|
---|
139 | files_struct *fsp,
|
---|
140 | enum file_close_type close_type);
|
---|
141 | bool locking_init(void);
|
---|
142 | bool locking_init_readonly(void);
|
---|
143 | bool locking_end(void);
|
---|
144 | char *share_mode_str(TALLOC_CTX *ctx, int num, const struct share_mode_entry *e);
|
---|
145 | struct share_mode_lock *get_share_mode_lock(TALLOC_CTX *mem_ctx,
|
---|
146 | const struct file_id id,
|
---|
147 | const char *servicepath,
|
---|
148 | const struct smb_filename *smb_fname,
|
---|
149 | const struct timespec *old_write_time);
|
---|
150 | struct share_mode_lock *fetch_share_mode_unlocked(TALLOC_CTX *mem_ctx,
|
---|
151 | const struct file_id id);
|
---|
152 | bool rename_share_filename(struct messaging_context *msg_ctx,
|
---|
153 | struct share_mode_lock *lck,
|
---|
154 | const char *servicepath,
|
---|
155 | uint32_t orig_name_hash,
|
---|
156 | uint32_t new_name_hash,
|
---|
157 | const struct smb_filename *smb_fname);
|
---|
158 | void get_file_infos(struct file_id id,
|
---|
159 | uint32_t name_hash,
|
---|
160 | bool *delete_on_close,
|
---|
161 | struct timespec *write_time);
|
---|
162 | bool is_valid_share_mode_entry(const struct share_mode_entry *e);
|
---|
163 | bool is_deferred_open_entry(const struct share_mode_entry *e);
|
---|
164 | bool is_unused_share_mode_entry(const struct share_mode_entry *e);
|
---|
165 | void set_share_mode(struct share_mode_lock *lck, files_struct *fsp,
|
---|
166 | uid_t uid, uint64_t mid, uint16 op_type);
|
---|
167 | void add_deferred_open(struct share_mode_lock *lck, uint64_t mid,
|
---|
168 | struct timeval request_time,
|
---|
169 | struct server_id pid, struct file_id id);
|
---|
170 | bool del_share_mode(struct share_mode_lock *lck, files_struct *fsp);
|
---|
171 | void del_deferred_open_entry(struct share_mode_lock *lck, uint64_t mid,
|
---|
172 | struct server_id pid);
|
---|
173 | bool remove_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
|
---|
174 | bool downgrade_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
|
---|
175 | NTSTATUS can_set_delete_on_close(files_struct *fsp, uint32 dosmode);
|
---|
176 | bool get_delete_on_close_token(struct share_mode_lock *lck,
|
---|
177 | uint32_t name_hash,
|
---|
178 | const struct security_token **pp_nt_tok,
|
---|
179 | const struct security_unix_token **pp_tok);
|
---|
180 | void set_delete_on_close_lck(files_struct *fsp,
|
---|
181 | struct share_mode_lock *lck,
|
---|
182 | bool delete_on_close,
|
---|
183 | const struct security_token *nt_tok,
|
---|
184 | const struct security_unix_token *tok);
|
---|
185 | bool set_delete_on_close(files_struct *fsp, bool delete_on_close,
|
---|
186 | const struct security_token *nt_tok,
|
---|
187 | const struct security_unix_token *tok);
|
---|
188 | bool is_delete_on_close_set(struct share_mode_lock *lck, uint32_t name_hash);
|
---|
189 | bool set_sticky_write_time(struct file_id fileid, struct timespec write_time);
|
---|
190 | bool set_write_time(struct file_id fileid, struct timespec write_time);
|
---|
191 | int share_mode_forall(void (*fn)(const struct share_mode_entry *, const char *,
|
---|
192 | const char *, void *),
|
---|
193 | void *private_data);
|
---|
194 |
|
---|
195 | /* The following definitions come from locking/posix.c */
|
---|
196 |
|
---|
197 | bool is_posix_locked(files_struct *fsp,
|
---|
198 | uint64_t *pu_offset,
|
---|
199 | uint64_t *pu_count,
|
---|
200 | enum brl_type *plock_type,
|
---|
201 | enum brl_flavour lock_flav);
|
---|
202 | bool posix_locking_init(bool read_only);
|
---|
203 | bool posix_locking_end(void);
|
---|
204 | void reduce_windows_lock_ref_count(files_struct *fsp, unsigned int dcount);
|
---|
205 | int fd_close_posix(struct files_struct *fsp);
|
---|
206 | bool set_posix_lock_windows_flavour(files_struct *fsp,
|
---|
207 | uint64_t u_offset,
|
---|
208 | uint64_t u_count,
|
---|
209 | enum brl_type lock_type,
|
---|
210 | const struct lock_context *lock_ctx,
|
---|
211 | const struct lock_struct *plocks,
|
---|
212 | int num_locks,
|
---|
213 | int *errno_ret);
|
---|
214 | bool release_posix_lock_windows_flavour(files_struct *fsp,
|
---|
215 | uint64_t u_offset,
|
---|
216 | uint64_t u_count,
|
---|
217 | enum brl_type deleted_lock_type,
|
---|
218 | const struct lock_context *lock_ctx,
|
---|
219 | const struct lock_struct *plocks,
|
---|
220 | int num_locks);
|
---|
221 | bool set_posix_lock_posix_flavour(files_struct *fsp,
|
---|
222 | uint64_t u_offset,
|
---|
223 | uint64_t u_count,
|
---|
224 | enum brl_type lock_type,
|
---|
225 | int *errno_ret);
|
---|
226 | bool release_posix_lock_posix_flavour(files_struct *fsp,
|
---|
227 | uint64_t u_offset,
|
---|
228 | uint64_t u_count,
|
---|
229 | const struct lock_context *lock_ctx,
|
---|
230 | const struct lock_struct *plocks,
|
---|
231 | int num_locks);
|
---|
232 |
|
---|
233 | #endif /* _LOCKING_PROTO_H_ */
|
---|