[Libguestfs] [PATCH v2] file: Normalize errno value for ENODEV

Eric Blake eblake at redhat.com
Mon Jul 30 18:23:39 UTC 2018


On 07/30/2018 12:02 PM, Nir Soffer wrote:
> Fix issues Eric found in the original patch:
> https://www.redhat.com/archives/libguestfs/2018-July/msg00072.html
> 
> - When handling ENODEV, the caller is expecting EOPNOTSUPP to trigger
>    fallback.
> - ENODEV should be ignored in file_trim.
> 
> Tested only on Fedora 28 and RHEL 7.5.
> ---
>   plugins/file/file.c | 33 ++++++++++++++++++++++++---------
>   1 file changed, 24 insertions(+), 9 deletions(-)
> 

> +#if defined(FALLOC_FL_PUNCH_HOLE) || defined(FALLOC_FL_ZERO_RANGE)
> +static int
> +do_fallocate(int fd, int mode, off_t offset, off_t len)
> +{
> +  int r = -1;
> +  r = fallocate (fd, mode, offset, len);

Dead assignment to r in the declaration. Could merge these two lines 
into one.  Not necessarily worth a respin just for that.

> +  /* kernel 3.10 fails with ENODEV for block device. Kernel >= 4.9 fails
> +     with EOPNOTSUPP in this case. Normalize errno to simplify callers. */

Comment is slightly misleading - new enough kernels coupled with decent 
enough block device drivers actually succeed rather than failing. But 
I'm fine with checking in the comment as worded.

ACK

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org




More information about the Libguestfs mailing list