summaryrefslogtreecommitdiff
path: root/source3/smbd/open.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2000-06-15 09:35:37 +0000
committerAndrew Tridgell <tridge@samba.org>2000-06-15 09:35:37 +0000
commitf94f053b7618157f6caaa1d65553c1abb3aba917 (patch)
treecd2d3ffa7fc95942bc5ad906dabc3f38a4fa5b92 /source3/smbd/open.c
parentb41b1daa36c9ff48616fe23c99da1a00bf11ff84 (diff)
downloadsamba-f94f053b7618157f6caaa1d65553c1abb3aba917.tar.gz
samba-f94f053b7618157f6caaa1d65553c1abb3aba917.tar.bz2
samba-f94f053b7618157f6caaa1d65553c1abb3aba917.zip
added support for kernel level share modes. These are a (small) hack,
I suspect we will either get rid of them or do them properly at some stage. (This used to be commit fabe1f350e1fc58db33d22cebd38652950697ced)
Diffstat (limited to 'source3/smbd/open.c')
-rw-r--r--source3/smbd/open.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 23d95eadfd..5a0493e625 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -492,9 +492,24 @@ dev = %x, inode = %.0f\n", old_shares[i].op_type, fname, (unsigned int)dev, (dou
}
/****************************************************************************
- Open a file with a share mode.
+set a kernel flock on a file for NFS interoperability
+this requires a patch to Linux
****************************************************************************/
+static void kernel_flock(files_struct *fsp, int deny_mode)
+{
+#if HAVE_KERNEL_SHARE_MODES
+ int kernel_mode = 0;
+ if (deny_mode == DENY_READ) kernel_mode = LOCK_MAND|LOCK_WRITE;
+ else if (deny_mode == DENY_WRITE) kernel_mode = LOCK_MAND|LOCK_READ;
+ else if (deny_mode == DENY_ALL) kernel_mode = LOCK_MAND;
+ if (kernel_mode) flock(fsp->fd, kernel_mode);
+#endif
+}
+
+/****************************************************************************
+ Open a file with a share mode.
+****************************************************************************/
files_struct *open_file_shared(connection_struct *conn,char *fname,int share_mode,int ofun,
mode_t mode,int oplock_request, int *Access,int *action)
{
@@ -653,6 +668,14 @@ files_struct *open_file_shared(connection_struct *conn,char *fname,int share_mod
return NULL;
}
+ /* not that we ignore failure for the following. It is
+ basically a hack for NFS, and NFS will never set one of
+ these only read them. Nobody but Samba can ever set a deny
+ mode and we have already checked our more authoritative
+ locking database for permission to set this deny mode. If
+ the kernel refuses the operations then the kernel is wrong */
+ kernel_flock(fsp, deny_mode);
+
/*
* Deal with the race condition where two smbd's detect the file doesn't
* exist and do the create at the same time. One of them will win and