summaryrefslogtreecommitdiffstats
path: root/sys-utils
diff options
context:
space:
mode:
authorStanislav Brabec2019-06-10 21:59:45 +0200
committerKarel Zak2019-06-11 10:23:45 +0200
commit2d22ac64e4d6e6732640f38b7232b5bcdc84a877 (patch)
treebebd9f7bf720d660e6db7da419fabf1d64e32a14 /sys-utils
parentfstrim: Fix fstrim_all() comment (diff)
downloadkernel-qcow2-util-linux-2d22ac64e4d6e6732640f38b7232b5bcdc84a877.tar.gz
kernel-qcow2-util-linux-2d22ac64e4d6e6732640f38b7232b5bcdc84a877.tar.xz
kernel-qcow2-util-linux-2d22ac64e4d6e6732640f38b7232b5bcdc84a877.zip
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>
Diffstat (limited to 'sys-utils')
-rw-r--r--sys-utils/fstrim.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sys-utils/fstrim.c b/sys-utils/fstrim.c
index ff029015e..ea29a5695 100644
--- a/sys-utils/fstrim.c
+++ b/sys-utils/fstrim.c
@@ -311,6 +311,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;
+ }
+
if (!has_discard(src, &wholedisk))
continue;
cnt++;