s3-locking: move locking prototypes out of proto.h.
[samba.git] / source3 / locking / proto.h
1
2 /* The following definitions come from locking/brlock.c  */
3
4 bool brl_same_context(const struct lock_context *ctx1,
5                              const struct lock_context *ctx2);
6 NTSTATUS brl_lock_failed(files_struct *fsp, const struct lock_struct *lock, bool blocking_lock);
7 void brl_init(bool read_only);
8 void brl_shutdown(void);
9
10 NTSTATUS brl_lock_windows_default(struct byte_range_lock *br_lck,
11                 struct lock_struct *plock,
12                 bool blocking_lock);
13
14 NTSTATUS brl_lock(struct messaging_context *msg_ctx,
15                 struct byte_range_lock *br_lck,
16                 uint64_t smblctx,
17                 struct server_id pid,
18                 br_off start,
19                 br_off size,
20                 enum brl_type lock_type,
21                 enum brl_flavour lock_flav,
22                 bool blocking_lock,
23                 uint64_t *psmblctx,
24                 struct blocking_lock_record *blr);
25 bool brl_unlock(struct messaging_context *msg_ctx,
26                 struct byte_range_lock *br_lck,
27                 uint64_t smblctx,
28                 struct server_id pid,
29                 br_off start,
30                 br_off size,
31                 enum brl_flavour lock_flav);
32 bool brl_unlock_windows_default(struct messaging_context *msg_ctx,
33                                struct byte_range_lock *br_lck,
34                                const struct lock_struct *plock);
35 bool brl_locktest(struct byte_range_lock *br_lck,
36                 uint64_t smblctx,
37                 struct server_id pid,
38                 br_off start,
39                 br_off size,
40                 enum brl_type lock_type,
41                 enum brl_flavour lock_flav);
42 NTSTATUS brl_lockquery(struct byte_range_lock *br_lck,
43                 uint64_t *psmblctx,
44                 struct server_id pid,
45                 br_off *pstart,
46                 br_off *psize,
47                 enum brl_type *plock_type,
48                 enum brl_flavour lock_flav);
49 bool brl_lock_cancel(struct byte_range_lock *br_lck,
50                 uint64_t smblctx,
51                 struct server_id pid,
52                 br_off start,
53                 br_off size,
54                 enum brl_flavour lock_flav,
55                 struct blocking_lock_record *blr);
56 bool brl_lock_cancel_default(struct byte_range_lock *br_lck,
57                 struct lock_struct *plock);
58 void brl_close_fnum(struct messaging_context *msg_ctx,
59                     struct byte_range_lock *br_lck);
60 int brl_forall(void (*fn)(struct file_id id, struct server_id pid,
61                           enum brl_type lock_type,
62                           enum brl_flavour lock_flav,
63                           br_off start, br_off size,
64                           void *private_data),
65                void *private_data);
66 struct byte_range_lock *brl_get_locks(TALLOC_CTX *mem_ctx,
67                                         files_struct *fsp);
68 struct byte_range_lock *brl_get_locks_readonly(files_struct *fsp);
69 void brl_register_msgs(struct messaging_context *msg_ctx);
70
71 /* The following definitions come from locking/locking.c  */
72
73 const char *lock_type_name(enum brl_type lock_type);
74 const char *lock_flav_name(enum brl_flavour lock_flav);
75 void init_strict_lock_struct(files_struct *fsp,
76                                 uint64_t smblctx,
77                                 br_off start,
78                                 br_off size,
79                                 enum brl_type lock_type,
80                                 struct lock_struct *plock);
81 bool strict_lock_default(files_struct *fsp,
82                                 struct lock_struct *plock);
83 void strict_unlock_default(files_struct *fsp,
84                                 struct lock_struct *plock);
85 NTSTATUS query_lock(files_struct *fsp,
86                         uint64_t *psmblctx,
87                         uint64_t *pcount,
88                         uint64_t *poffset,
89                         enum brl_type *plock_type,
90                         enum brl_flavour lock_flav);
91 struct byte_range_lock *do_lock(struct messaging_context *msg_ctx,
92                         files_struct *fsp,
93                         uint64_t smblctx,
94                         uint64_t count,
95                         uint64_t offset,
96                         enum brl_type lock_type,
97                         enum brl_flavour lock_flav,
98                         bool blocking_lock,
99                         NTSTATUS *perr,
100                         uint64_t *psmblctx,
101                         struct blocking_lock_record *blr);
102 NTSTATUS do_unlock(struct messaging_context *msg_ctx,
103                         files_struct *fsp,
104                         uint64_t smblctx,
105                         uint64_t count,
106                         uint64_t offset,
107                         enum brl_flavour lock_flav);
108 NTSTATUS do_lock_cancel(files_struct *fsp,
109                         uint64 smblctx,
110                         uint64_t count,
111                         uint64_t offset,
112                         enum brl_flavour lock_flav,
113                         struct blocking_lock_record *blr);
114 void locking_close_file(struct messaging_context *msg_ctx,
115                         files_struct *fsp,
116                         enum file_close_type close_type);
117 bool locking_init(void);
118 bool locking_init_readonly(void);
119 bool locking_end(void);
120 char *share_mode_str(TALLOC_CTX *ctx, int num, const struct share_mode_entry *e);
121 struct share_mode_lock *get_share_mode_lock(TALLOC_CTX *mem_ctx,
122                                             const struct file_id id,
123                                             const char *servicepath,
124                                             const struct smb_filename *smb_fname,
125                                             const struct timespec *old_write_time);
126 struct share_mode_lock *fetch_share_mode_unlocked(TALLOC_CTX *mem_ctx,
127                                                   const struct file_id id);
128 bool rename_share_filename(struct messaging_context *msg_ctx,
129                         struct share_mode_lock *lck,
130                         const char *servicepath,
131                         uint32_t orig_name_hash,
132                         uint32_t new_name_hash,
133                         const struct smb_filename *smb_fname);
134 void get_file_infos(struct file_id id,
135                     uint32_t name_hash,
136                     bool *delete_on_close,
137                     struct timespec *write_time);
138 bool is_valid_share_mode_entry(const struct share_mode_entry *e);
139 bool is_deferred_open_entry(const struct share_mode_entry *e);
140 bool is_unused_share_mode_entry(const struct share_mode_entry *e);
141 void set_share_mode(struct share_mode_lock *lck, files_struct *fsp,
142                     uid_t uid, uint64_t mid, uint16 op_type);
143 void add_deferred_open(struct share_mode_lock *lck, uint64_t mid,
144                        struct timeval request_time,
145                        struct server_id pid, struct file_id id);
146 bool del_share_mode(struct share_mode_lock *lck, files_struct *fsp);
147 void del_deferred_open_entry(struct share_mode_lock *lck, uint64_t mid,
148                              struct server_id pid);
149 bool remove_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
150 bool downgrade_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
151 NTSTATUS can_set_delete_on_close(files_struct *fsp, uint32 dosmode);
152 const struct security_unix_token *get_delete_on_close_token(struct share_mode_lock *lck, uint32_t name_hash);
153 void set_delete_on_close_lck(files_struct *fsp,
154                         struct share_mode_lock *lck,
155                         bool delete_on_close,
156                         const struct security_unix_token *tok);
157 bool set_delete_on_close(files_struct *fsp, bool delete_on_close, const struct security_unix_token *tok);
158 bool is_delete_on_close_set(struct share_mode_lock *lck, uint32_t name_hash);
159 bool set_sticky_write_time(struct file_id fileid, struct timespec write_time);
160 bool set_write_time(struct file_id fileid, struct timespec write_time);
161 int share_mode_forall(void (*fn)(const struct share_mode_entry *, const char *,
162                                  const char *, void *),
163                       void *private_data);
164
165 /* The following definitions come from locking/posix.c  */
166
167 bool is_posix_locked(files_struct *fsp,
168                         uint64_t *pu_offset,
169                         uint64_t *pu_count,
170                         enum brl_type *plock_type,
171                         enum brl_flavour lock_flav);
172 bool posix_locking_init(bool read_only);
173 bool posix_locking_end(void);
174 void reduce_windows_lock_ref_count(files_struct *fsp, unsigned int dcount);
175 int fd_close_posix(struct files_struct *fsp);
176 bool set_posix_lock_windows_flavour(files_struct *fsp,
177                         uint64_t u_offset,
178                         uint64_t u_count,
179                         enum brl_type lock_type,
180                         const struct lock_context *lock_ctx,
181                         const struct lock_struct *plocks,
182                         int num_locks,
183                         int *errno_ret);
184 bool release_posix_lock_windows_flavour(files_struct *fsp,
185                                 uint64_t u_offset,
186                                 uint64_t u_count,
187                                 enum brl_type deleted_lock_type,
188                                 const struct lock_context *lock_ctx,
189                                 const struct lock_struct *plocks,
190                                 int num_locks);
191 bool set_posix_lock_posix_flavour(files_struct *fsp,
192                         uint64_t u_offset,
193                         uint64_t u_count,
194                         enum brl_type lock_type,
195                         int *errno_ret);
196 bool release_posix_lock_posix_flavour(files_struct *fsp,
197                                 uint64_t u_offset,
198                                 uint64_t u_count,
199                                 const struct lock_context *lock_ctx,
200                                 const struct lock_struct *plocks,
201                                 int num_locks);