From 746d1aa42b3aade7082bef248bacf869bbeb7244 Mon Sep 17 00:00:00 2001 From: Anoop C S Date: Wed, 14 Aug 2019 18:03:01 +0530 Subject: [PATCH] vfs_glusterfs: Return fake fd from pipe() during open To workaround the problem of fcntl() acting upon fsp->fh->fd instead of VFS based open fd we have to provide a valid fd from the system. Also added a FIXME note for future reference when we have SMB_VFS_FCNTL in place to get this fixed properly. Signed-off-by: Anoop C S --- source3/modules/vfs_glusterfs.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c index 38517b7af5a..a732059f817 100644 --- a/source3/modules/vfs_glusterfs.c +++ b/source3/modules/vfs_glusterfs.c @@ -628,6 +628,7 @@ static int vfs_gluster_open(struct vfs_handle_struct *handle, { glfs_fd_t *glfd; glfs_fd_t **p_tmp; + int fakefd[2]; START_PROFILE(syscall_open); @@ -657,8 +658,23 @@ static int vfs_gluster_open(struct vfs_handle_struct *handle, *p_tmp = glfd; END_PROFILE(syscall_open); - /* An arbitrary value for error reporting, so you know its us. */ - return 13371337; + + // FIXME + /* Due to lack of SMB_VFS_FCNTL we return fake fd from pipe() to get + * past set_blocking() in open_file() code path. This is needed since + * O_NONBLOCK open flag is being added internally irrespective of + * 'kernel share modes' setting in smb.conf. vfs_glusterfs normally + * operates with 'kernel share modes' disabled. + * + * Refer https://bugzilla.samba.org/show_bug.cgi?id=14060 for details*/ + if (pipe(fakefd) == -1) { + DBG_ERR("pipe failed: %s\n", strerror(errno)); + return -1; + } + + close(fakefd[1]); + + return fakefd[0]; } static int vfs_gluster_close(struct vfs_handle_struct *handle, @@ -676,6 +692,8 @@ static int vfs_gluster_close(struct vfs_handle_struct *handle, return -1; } + close(fsp->fh->fd); + VFS_REMOVE_FSP_EXTENSION(handle, fsp); ret = glfs_close(glfd); -- 2.21.0