vfs_fruit: fix close for fake_fd
authorRalph Boehme <slow@samba.org>
Fri, 11 Dec 2020 11:59:28 +0000 (12:59 +0100)
committerKarolin Seeger <kseeger@samba.org>
Wed, 13 Jan 2021 13:45:00 +0000 (13:45 +0000)
If the next backend doesn't use kernel fd's should not
pass a fake_fd to the next backend.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri Jan  8 21:38:18 UTC 2021 on sn-devel-184

(back-ported from commit 564b62a6f7c0a9b9712946d723118122b9c3785f)

Autobuild-User(v4-12-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-12-test): Wed Jan 13 13:45:00 UTC 2021 on sn-devel-184

source3/modules/vfs_fruit.c

index 5f0ac1d28b3bcbd95322a7db70d193c32885ef14..a3b823fc6afbf7537b8d483e56041cb53aa804d6 100644 (file)
@@ -1632,6 +1632,7 @@ static int fruit_open(vfs_handle_struct *handle,
 static int fruit_close_meta(vfs_handle_struct *handle,
                            files_struct *fsp)
 {
+       struct fio *fio = (struct fio *)VFS_FETCH_FSP_EXTENSION(handle, fsp);
        int ret;
        struct fruit_config_data *config = NULL;
 
@@ -1640,7 +1641,12 @@ static int fruit_close_meta(vfs_handle_struct *handle,
 
        switch (config->meta) {
        case FRUIT_META_STREAM:
-               ret = SMB_VFS_NEXT_CLOSE(handle, fsp);
+               if (fio->fake_fd) {
+                       ret = vfs_fake_fd_close(fsp->fh->fd);
+                       fsp->fh->fd = -1;
+               } else {
+                       ret = SMB_VFS_NEXT_CLOSE(handle, fsp);
+               }
                break;
 
        case FRUIT_META_NETATALK:
@@ -2529,13 +2535,13 @@ static ssize_t fruit_pwrite_meta_stream(vfs_handle_struct *handle,
        }
 
        if (fio->fake_fd) {
-               int fd;
+               int fd = fsp->fh->fd;
 
-               ret = SMB_VFS_NEXT_CLOSE(handle, fsp);
+               ret = vfs_fake_fd_close(fd);
+               fsp->fh->fd = -1;
                if (ret != 0) {
                        DBG_ERR("Close [%s] failed: %s\n",
                                fsp_str_dbg(fsp), strerror(errno));
-                       fsp->fh->fd = -1;
                        return -1;
                }