summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorRalph Boehme <slow@samba.org>2017-05-04 11:50:56 +0200
committerRalph Boehme <slow@samba.org>2017-05-06 19:01:14 +0200
commitf631e95e2de857ea98204609a71e6db00993994b (patch)
tree5f784c78fec838aec6babba8a88cf1f17688ab67 /source3
parent952701dce09b1ee89a0f6a450ac244fd6451955b (diff)
downloadsamba-f631e95e2de857ea98204609a71e6db00993994b.tar.gz
s3/locking: helper functions for lease types
Add some helper functions that will be used to update a bunch of checks for exclusive oplocks to the lease area. Bug: https://bugzilla.samba.org/show_bug.cgi?id=12766 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3')
-rw-r--r--source3/locking/leases_util.c17
-rw-r--r--source3/locking/proto.h2
2 files changed, 19 insertions, 0 deletions
diff --git a/source3/locking/leases_util.c b/source3/locking/leases_util.c
index 5d07ff9dd7b..af1e8374128 100644
--- a/source3/locking/leases_util.c
+++ b/source3/locking/leases_util.c
@@ -53,3 +53,20 @@ uint32_t fsp_lease_type(const struct files_struct *fsp)
}
return map_oplock_to_lease_type(fsp->oplock_type);
}
+
+uint32_t lease_type_is_exclusive(uint32_t lease_type)
+{
+ if ((lease_type & (SMB2_LEASE_READ | SMB2_LEASE_WRITE)) ==
+ (SMB2_LEASE_READ | SMB2_LEASE_WRITE)) {
+ return true;
+ }
+
+ return false;
+}
+
+bool fsp_lease_type_is_exclusive(const struct files_struct *fsp)
+{
+ uint32_t lease_type = fsp_lease_type(fsp);
+
+ return lease_type_is_exclusive(lease_type);
+}
diff --git a/source3/locking/proto.h b/source3/locking/proto.h
index 44ab315660b..5d2326a40aa 100644
--- a/source3/locking/proto.h
+++ b/source3/locking/proto.h
@@ -258,5 +258,7 @@ bool release_posix_lock_posix_flavour(files_struct *fsp,
/* 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);
#endif /* _LOCKING_PROTO_H_ */