"stat open" lseek(fd = -1)
Jeremy Allison
jra at samba.org
Mon Mar 4 17:41:14 UTC 2019
On Mon, Mar 04, 2019 at 12:03:32PM +0100, David Disseldorp wrote:
>
> Yes, very much so - thanks Jeremy!
>
> reply_lseek() bails on check_fsp() failure (triggered on -1 fd), so I
> think that covers all callers and allows for removal of the VFS check.
> Please see attached.
>
> Cheers, David
LGTM. RB+ and (hotel network permitting :-) pushed !
> From f6d739c7f6ebc4be8a6172e45a05bf356aaaeb15 Mon Sep 17 00:00:00 2001
> From: David Disseldorp <ddiss at samba.org>
> Date: Mon, 4 Mar 2019 11:35:45 +0100
> Subject: [PATCH] vfs: drop lseek stat-open checks
>
> b9e91d2a8e41a43d7ebb7d7eed807a7d8de9b329 added fd==-1 checks to the
> lseek() path to handle "stat opens". Current reply.c and
> smb2_ioctl_filesys.c callers do not invoke SMB_VFS_LSEEK() with
> stat-open fsp structs, so the fd==-1 checks can be removed from the
> VFS.
>
> Signed-off-by: David Disseldorp <ddiss at samba.org>
> ---
> source3/modules/vfs_ceph.c | 5 +----
> source3/modules/vfs_default.c | 5 +----
> 2 files changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c
> index 67b8d139891..38ffe08887e 100644
> --- a/source3/modules/vfs_ceph.c
> +++ b/source3/modules/vfs_ceph.c
> @@ -575,10 +575,7 @@ static off_t cephwrap_lseek(struct vfs_handle_struct *handle, files_struct *fsp,
> off_t result = 0;
>
> DBG_DEBUG("[CEPH] cephwrap_lseek\n");
> - /* Cope with 'stat' file opens. */
> - if (fsp->fh->fd != -1) {
> - result = ceph_lseek(handle->data, fsp->fh->fd, offset, whence);
> - }
> + result = ceph_lseek(handle->data, fsp->fh->fd, offset, whence);
> WRAP_RETURN(result);
> }
>
> diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
> index cb5537e096e..1ed2c810667 100644
> --- a/source3/modules/vfs_default.c
> +++ b/source3/modules/vfs_default.c
> @@ -1025,10 +1025,7 @@ static off_t vfswrap_lseek(vfs_handle_struct *handle, files_struct *fsp, off_t o
>
> START_PROFILE(syscall_lseek);
>
> - /* Cope with 'stat' file opens. */
> - if (fsp->fh->fd != -1)
> - result = lseek(fsp->fh->fd, offset, whence);
> -
> + result = lseek(fsp->fh->fd, offset, whence);
> /*
> * We want to maintain the fiction that we can seek
> * on a fifo for file system purposes. This allows
> --
> 2.16.4
>
More information about the samba-technical
mailing list