Skip to content

Commit

Permalink
fstrim -a/-A: Skip read-only volumes
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
stanislav-brabec authored and karelzak committed Jun 11, 2019
1 parent 4080be3 commit 2d22ac6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sys-utils/fstrim.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down

0 comments on commit 2d22ac6

Please sign in to comment.