unsigned int brl_num_locks(const struct byte_range_lock *brl);
struct files_struct *brl_fsp(struct byte_range_lock *brl);
-uint32_t brl_num_read_oplocks(const struct byte_range_lock *brl);
-void brl_set_num_read_oplocks(struct byte_range_lock *brl,
- uint32_t num_read_oplocks);
+TALLOC_CTX *brl_req_mem_ctx(const struct byte_range_lock *brl);
+const struct GUID *brl_req_guid(const struct byte_range_lock *brl);
+
+bool byte_range_valid(uint64_t ofs, uint64_t len);
+bool byte_range_overlap(uint64_t ofs1,
+ uint64_t len1,
+ uint64_t ofs2,
+ uint64_t len2);
NTSTATUS brl_lock_windows_default(struct byte_range_lock *br_lck,
- struct lock_struct *plock,
- bool blocking_lock);
+ struct lock_struct *plock);
-NTSTATUS brl_lock(struct messaging_context *msg_ctx,
- struct byte_range_lock *br_lck,
- uint64_t smblctx,
- struct server_id pid,
- br_off start,
- br_off size,
- enum brl_type lock_type,
- enum brl_flavour lock_flav,
- bool blocking_lock,
- struct server_id *blocker_pid,
- uint64_t *psmblctx);
-bool brl_unlock(struct messaging_context *msg_ctx,
- struct byte_range_lock *br_lck,
+NTSTATUS brl_lock(
+ struct byte_range_lock *br_lck,
+ uint64_t smblctx,
+ struct server_id pid,
+ br_off start,
+ br_off size,
+ enum brl_type lock_type,
+ enum brl_flavour lock_flav,
+ struct server_id *blocker_pid,
+ uint64_t *psmblctx);
+bool brl_unlock(struct byte_range_lock *br_lck,
uint64_t smblctx,
struct server_id pid,
br_off start,
br_off size,
enum brl_flavour lock_flav);
-bool brl_unlock_windows_default(struct messaging_context *msg_ctx,
- struct byte_range_lock *br_lck,
- const struct lock_struct *plock);
+bool brl_unlock_windows_default(struct byte_range_lock *br_lck,
+ const struct lock_struct *plock);
bool brl_locktest(struct byte_range_lock *br_lck,
const struct lock_struct *rw_probe);
NTSTATUS brl_lockquery(struct byte_range_lock *br_lck,
enum brl_flavour lock_flav);
bool brl_mark_disconnected(struct files_struct *fsp);
bool brl_reconnect_disconnected(struct files_struct *fsp);
-void brl_close_fnum(struct messaging_context *msg_ctx,
- struct byte_range_lock *br_lck);
+void brl_close_fnum(struct byte_range_lock *br_lck);
int brl_forall(void (*fn)(struct file_id id, struct server_id pid,
enum brl_type lock_type,
enum brl_flavour lock_flav,
br_off start, br_off size,
void *private_data),
void *private_data);
+struct byte_range_lock *brl_get_locks_for_locking(TALLOC_CTX *mem_ctx,
+ files_struct *fsp,
+ TALLOC_CTX *req_mem_ctx,
+ const struct GUID *req_guid);
struct byte_range_lock *brl_get_locks(TALLOC_CTX *mem_ctx,
files_struct *fsp);
struct byte_range_lock *brl_get_locks_readonly(files_struct *fsp);
uint64_t *poffset,
enum brl_type *plock_type,
enum brl_flavour lock_flav);
-NTSTATUS do_lock(struct messaging_context *msg_ctx,
- files_struct *fsp,
+NTSTATUS do_lock(files_struct *fsp,
+ TALLOC_CTX *req_mem_ctx,
+ const struct GUID *req_guid,
uint64_t smblctx,
uint64_t count,
uint64_t offset,
enum brl_flavour lock_flav,
struct server_id *pblocker_pid,
uint64_t *psmblctx);
-NTSTATUS do_unlock(struct messaging_context *msg_ctx,
- files_struct *fsp,
- uint64_t smblctx,
- uint64_t count,
- uint64_t offset,
- enum brl_flavour lock_flav);
-void locking_close_file(struct messaging_context *msg_ctx,
- files_struct *fsp,
+NTSTATUS do_unlock(files_struct *fsp,
+ uint64_t smblctx,
+ uint64_t count,
+ uint64_t offset,
+ enum brl_flavour lock_flav);
+void locking_close_file(files_struct *fsp,
enum file_close_type close_type);
bool locking_init(void);
bool locking_init_readonly(void);
const char *servicepath,
const struct smb_filename *smb_fname,
const struct timespec *old_write_time);
+
+bool file_has_read_lease(struct files_struct *fsp);
+
+struct db_record;
+NTSTATUS share_mode_do_locked(
+ struct file_id id,
+ void (*fn)(struct db_record *rec,
+ bool *modified_dependent,
+ void *private_data),
+ void *private_data);
+NTSTATUS share_mode_wakeup_waiters(struct file_id id);
+
struct share_mode_lock *fetch_share_mode_unlocked(TALLOC_CTX *mem_ctx,
struct file_id id);
struct tevent_req *fetch_share_mode_send(TALLOC_CTX *mem_ctx,
bool *delete_on_close,
struct timespec *write_time);
bool is_valid_share_mode_entry(const struct share_mode_entry *e);
+bool share_entry_stale_pid(struct share_mode_entry *e);
bool share_mode_stale_pid(struct share_mode_data *d, uint32_t idx);
bool set_share_mode(struct share_mode_lock *lck,
struct files_struct *fsp,
uid_t uid,
uint64_t mid,
uint16_t op_type,
- const struct GUID *client_guid,
- const struct smb2_lease_key *lease_key);
-struct share_mode_entry *find_share_mode_entry(struct share_mode_lock *lck,
- files_struct *fsp);
+ uint32_t share_access,
+ uint32_t access_mask);
+NTSTATUS remove_lease_if_stale(const struct share_mode_data *d,
+ const struct GUID *client_guid,
+ const struct smb2_lease_key *lease_key);
void remove_stale_share_mode_entries(struct share_mode_data *d);
bool del_share_mode(struct share_mode_lock *lck, files_struct *fsp);
bool mark_share_mode_disconnected(struct share_mode_lock *lck,
void *private_data),
void *private_data);
+bool share_mode_forall_entries(
+ struct share_mode_lock *lck,
+ bool (*fn)(struct share_mode_entry *e,
+ bool *modified,
+ void *private_data),
+ void *private_data);
+
/* The following definitions come from locking/posix.c */
/* The following definitions come from locking/leases_util.c */
uint32_t map_oplock_to_lease_type(uint16_t op_type);
-uint32_t fsp_lease_type(const struct files_struct *fsp);
-uint32_t lease_type_is_exclusive(uint32_t lease_type);
-bool fsp_lease_type_is_exclusive(const struct files_struct *fsp);
+uint32_t fsp_lease_type(struct files_struct *fsp);
+bool fsp_lease_type_is_exclusive(struct files_struct *fsp);
+const struct GUID *fsp_client_guid(const files_struct *fsp);
#endif /* _LOCKING_PROTO_H_ */