vfs_glusterfs: Return fake fd from pipe() during open
authorAnoop C S <anoopcs@redhat.com>
Wed, 14 Aug 2019 12:33:01 +0000 (18:03 +0530)
committerGünther Deschner <gd@samba.org>
Fri, 17 Jan 2020 17:14:43 +0000 (17:14 +0000)
GlusterFS currently doesn't have an API implementation to set flags on
open file descriptor. Thus we use pipe() to provide valid file descriptor
from the system.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14241

Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Autobuild-User(master): Günther Deschner <gd@samba.org>
Autobuild-Date(master): Fri Jan 17 17:14:43 UTC 2020 on sn-devel-184

source3/modules/vfs_glusterfs.c

index bce7ae5e84ad3706086a71a24fbdf10c5011dc70..2520382c42f809b6a7c51b8ffe2b920ecc375260 100644 (file)
@@ -630,6 +630,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);
 
@@ -659,8 +660,15 @@ 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;
+
+       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,
@@ -678,6 +686,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);