From: Jan Kara Date: Thu, 20 Jan 2022 12:16:38 +0000 (+0100) Subject: loopdev: Properly translate errors from ul_path_read_*() X-Git-Tag: v2.38-rc1~31 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fb4b6b11544df405fb0f486b399938a8ee3f03e6;p=thirdparty%2Futil-linux.git loopdev: Properly translate errors from ul_path_read_*() A few callsites do not translate error from ul_path_read_*() and just treat it as error code leading to confusing EPERM errors. Signed-off-by: Jan Kara --- diff --git a/lib/loopdev.c b/lib/loopdev.c index b5da1516e3..27ab06c668 100644 --- a/lib/loopdev.c +++ b/lib/loopdev.c @@ -739,7 +739,8 @@ int loopcxt_get_offset(struct loopdev_cxt *lc, uint64_t *offset) int rc = -EINVAL; if (sysfs) - rc = ul_path_read_u64(sysfs, offset, "loop/offset"); + if (ul_path_read_u64(sysfs, offset, "loop/offset") == 0) + rc = 0; if (rc && loopcxt_ioctl_enabled(lc)) { struct loop_info64 *lo = loopcxt_get_info(lc); @@ -767,7 +768,8 @@ int loopcxt_get_blocksize(struct loopdev_cxt *lc, uint64_t *blocksize) int rc = -EINVAL; if (sysfs) - rc = ul_path_read_u64(sysfs, blocksize, "queue/logical_block_size"); + if (ul_path_read_u64(sysfs, blocksize, "queue/logical_block_size") == 0) + rc = 0; /* Fallback based on BLKSSZGET ioctl */ if (rc) { @@ -799,7 +801,8 @@ int loopcxt_get_sizelimit(struct loopdev_cxt *lc, uint64_t *size) int rc = -EINVAL; if (sysfs) - rc = ul_path_read_u64(sysfs, size, "loop/sizelimit"); + if (ul_path_read_u64(sysfs, size, "loop/sizelimit") == 0) + rc = 0; if (rc && loopcxt_ioctl_enabled(lc)) { struct loop_info64 *lo = loopcxt_get_info(lc);