to avoid "FITRIM ioctl failed: Remote I/O error"
Addresses: https://github.com/karelzak/util-linux/issues/738
Signed-off-by: Karel Zak <kzak@redhat.com>
struct path_cxt *pc = NULL;
uint64_t dg = 0;
dev_t disk = 0, dev;
- int rc = -1;
+ int rc = -1, rdonly = 0;
dev = sysfs_devname_to_devno(devname);
if (!dev)
}
rc = ul_path_read_u64(pc, &dg, "queue/discard_granularity");
+ if (!rc)
+ ul_path_scanf(pc, "ro", "%d", &rdonly);
ul_unref_path(pc);
- return rc == 0 && dg > 0;
+ return rc == 0 && dg > 0 && rdonly == 0;
fail:
ul_unref_path(pc);
return 1;