From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: bst@pengutronix.de, Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] fastboot: sparse: print descriptive error on overflowing destination
Date: Fri, 8 Dec 2023 15:06:30 +0100 [thread overview]
Message-ID: <20231208140630.1986278-1-a.fatoum@pengutronix.de> (raw)
Fastboot flash of both regular files and barebox update handlers will
print a message if the file being written doesn't fit the destination:
barebox update: "Image (%zd) is too big for device (%lld)\n"
fastboot: "write: No space left on device\n"
With sparse images however, not the write will fail, but the lseek to
the new offset, triggering a cryptic:
"writing sparse image: Invalid argument"
Let's improve upon this a bit by translating lseek -EINVAL to -ENOSPC,
so we get:
"writing sparse image: No space left on device"
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
common/fastboot.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common/fastboot.c b/common/fastboot.c
index 65d1d30f9092..261283d50a3a 100644
--- a/common/fastboot.c
+++ b/common/fastboot.c
@@ -598,7 +598,7 @@ static int fastboot_handle_sparse(struct fastboot *fb,
pos = lseek(fd, pos, SEEK_SET);
if (pos == -1) {
- ret = -errno;
+ ret = errno == EINVAL ? -ENOSPC : -errno;
goto out;
}
--
2.39.2
next reply other threads:[~2023-12-08 14:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-08 14:06 Ahmad Fatoum [this message]
2023-12-11 9:39 ` Bastian Krause
2023-12-13 6:49 ` Sascha Hauer
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=20231208140630.1986278-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=bst@pengutronix.de \
/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