From f94f053b7618157f6caaa1d65553c1abb3aba917 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 15 Jun 2000 09:35:37 +0000 Subject: 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) --- source3/smbd/open.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'source3/smbd/open.c') 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 -- cgit