Re: [PATCH 3/3] fstrim -a/-A: Skip read-only volumes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jun 10, 2019 at 09:59:45PM +0200, Stanislav Brabec wrote:
> Calling TRIM on some read-only volumes can fail with:
> fstrim: /win: FITRIM ioctl failed: Bad file descriptor

Did you try it with the current version from git? ... because we
interpret EBADF as "the discard operation is not supported" warning
rather than an error.

> Skipping all read-only mounts seems to be safe and logical strategy.
> 
> Fixes opensuse#1106214.
> 
> Signed-off-by: Stanislav Brabec <sbrabec@xxxxxxx>
> ---
>  sys-utils/fstrim.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/sys-utils/fstrim.c b/sys-utils/fstrim.c
> index 0491e2b54..e0e9e57a9 100644
> --- a/sys-utils/fstrim.c
> +++ b/sys-utils/fstrim.c
> @@ -328,6 +328,14 @@ static int fstrim_all(struct fstrim_control *ctl)
>  		if (rc)
>  			continue;	/* overlaying mount */
>  
> +		/* FSTRIM on read-only filesystem can fail, and it can fail */
> +		if (access(path, W_OK) != 0) {
> +			if (errno == EROFS)
> +				continue;
> +			if (errno == EACCES)
> +				continue;
> +		}
> +

Anyway, for fstrim_all() it's probably good idea to call access().

    Karel


-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux