From 4fe70bcee2ec8515f123d8c826631b54bbf793e7 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Thu, 9 Nov 2006 20:29:31 +0000 Subject: r19647: Add some GPFS support in a vfs mod. Also adds the kernel flock op to the vfs layer, since gpfs supports it. Thanks to Volker, Christian, Mathias, Chetan, and Peter. (This used to be commit 0620658890fa9c68a9848538728023192319c81a) --- source3/smbd/open.c | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) (limited to 'source3/smbd/open.c') diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 4e91cdfd2a..1899a6fce7 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -783,28 +783,6 @@ static void defer_open(struct share_mode_lock *lck, srv_defer_sign_response(mid); } -/**************************************************************************** - Set a kernel flock on a file for NFS interoperability. - This requires a patch to Linux. -****************************************************************************/ - -static void kernel_flock(files_struct *fsp, 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(fsp->fh->fd, kernel_mode); - } -#endif - ; -} /**************************************************************************** On overwrite open ensure that the attributes match. @@ -1126,6 +1104,8 @@ NTSTATUS open_file_ntcreate(connection_struct *conn, struct share_mode_lock *lck = NULL; uint32 open_access_mask = access_mask; NTSTATUS status; + int ret_flock; + if (conn->printer) { /* @@ -1644,9 +1624,18 @@ NTSTATUS open_file_ntcreate(connection_struct *conn, 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 */ + the kernel refuses the operations then the kernel is wrong. + note that GPFS supports it as well - jmcd */ + + ret_flock = SMB_VFS_KERNEL_FLOCK(fsp, fsp->fh->fd, share_access); + if(ret_flock == -1 ){ - kernel_flock(fsp, share_access); + talloc_free(lck); + fd_close(conn, fsp); + file_free(fsp); + + return NT_STATUS_SHARING_VIOLATION; + } /* * At this point onwards, we can guarentee that the share entry -- cgit