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>
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++;