summaryrefslogtreecommitdiff
path: root/source3/lib/system.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib/system.c')
-rw-r--r--source3/lib/system.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/source3/lib/system.c b/source3/lib/system.c
index a440ece410..9ee3f7cc26 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -379,6 +379,31 @@ FILE *sys_fopen(const char *path, const char *type)
#endif
}
+
+/*******************************************************************
+ A flock() wrapper that will perform the kernel flock.
+********************************************************************/
+
+void kernel_flock(int fd, uint32 share_mode)
+{
+#if HAVE_KERNEL_SHARE_MODES
+ int kernel_mode = 0;
+ if (share_mode == FILE_SHARE_WRITE) {
+ kernel_mode = LOCK_MAND|LOCK_WRITE;
+ } else if (share_mode == FILE_SHARE_READ) {
+ kernel_mode = LOCK_MAND|LOCK_READ;
+ } else if (share_mode == FILE_SHARE_NONE) {
+ kernel_mode = LOCK_MAND;
+ }
+ if (kernel_mode) {
+ flock(fd, kernel_mode);
+ }
+#endif
+ ;
+}
+
+
+
/*******************************************************************
An opendir wrapper that will deal with 64 bit filesizes.
********************************************************************/