From: Jan Kara <jack@suse.cz>
To: Karel Zak <kzak@redhat.com>
Cc: util-linux@vger.kernel.org, Jan Kara <jack@suse.cz>
Subject: [PATCH 1/2] loopdev: Properly translate errors from ul_path_read_*()
Date: Thu, 20 Jan 2022 13:16:38 +0100 [thread overview]
Message-ID: <20220120121639.13047-1-jack@suse.cz> (raw)
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
next reply other threads:[~2022-01-20 12:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-20 12:16 Jan Kara [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220120121639.13047-1-jack@suse.cz \
--to=jack@suse.cz \
--cc=kzak@redhat.com \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).