util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] loopdev: Properly translate errors from ul_path_read_*()
@ 2022-01-20 12:16 Jan Kara
  2022-01-20 12:16 ` [PATCH 2/2] loopdev: Do not treat errors when detecting overlap as fatal Jan Kara
  2022-01-25 16:31 ` [PATCH 1/2] loopdev: Properly translate errors from ul_path_read_*() Karel Zak
  0 siblings, 2 replies; 3+ messages in thread
From: Jan Kara @ 2022-01-20 12:16 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux, Jan Kara

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 <jack@suse.cz>
---
 lib/loopdev.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lib/loopdev.c b/lib/loopdev.c
index b5da1516e37f..27ab06c66848 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);
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-25 16:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-20 12:16 [PATCH 1/2] loopdev: Properly translate errors from ul_path_read_*() Jan Kara
2022-01-20 12:16 ` [PATCH 2/2] loopdev: Do not treat errors when detecting overlap as fatal Jan Kara
2022-01-25 16:31 ` [PATCH 1/2] loopdev: Properly translate errors from ul_path_read_*() Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).