File util-linux-fstrim-A-2.patch of Package util-linux-systemd.27340
From 2d22ac64e4d6e6732640f38b7232b5bcdc84a877 Mon Sep 17 00:00:00 2001
From: Stanislav Brabec <sbrabec@suse.cz>
Date: Mon, 10 Jun 2019 21:59:45 +0200
Subject: [PATCH 2/4] fstrim -a/-A: Skip read-only volumes
Calling TRIM on some read-only volumes can fail with:
fstrim: /win: FITRIM ioctl failed: Bad file descriptor
Skipping all read-only mounts seems to be safe and logical strategy.
Fixes opensuse#1106214.
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
---
sys-utils/fstrim.c | 8 ++++++++
1 file changed, 8 insertions(+)
Index: util-linux-2.33.1/sys-utils/fstrim.c
===================================================================
--- util-linux-2.33.1.orig/sys-utils/fstrim.c
+++ util-linux-2.33.1/sys-utils/fstrim.c
@@ -277,6 +277,14 @@ static int fstrim_all(struct fstrim_cont
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;
+ }
+
if (!has_discard(src, &wholedisk))
continue;
cnt++;