* [PATCH] fastboot: sparse: print descriptive error on overflowing destination
@ 2023-12-08 14:06 Ahmad Fatoum
2023-12-11 9:39 ` Bastian Krause
2023-12-13 6:49 ` Sascha Hauer
0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2023-12-08 14:06 UTC (permalink / raw)
To: barebox; +Cc: bst, Ahmad Fatoum
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fastboot: sparse: print descriptive error on overflowing destination
2023-12-08 14:06 [PATCH] fastboot: sparse: print descriptive error on overflowing destination Ahmad Fatoum
@ 2023-12-11 9:39 ` Bastian Krause
2023-12-13 6:49 ` Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Bastian Krause @ 2023-12-11 9:39 UTC (permalink / raw)
To: Ahmad Fatoum, barebox
On 12/8/23 15:06, Ahmad Fatoum wrote:
> 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>
Tested-by: Bastian Krause <bst@pengutronix.de>
Thanks!
Bastian
> ---
> 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;
> }
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fastboot: sparse: print descriptive error on overflowing destination
2023-12-08 14:06 [PATCH] fastboot: sparse: print descriptive error on overflowing destination Ahmad Fatoum
2023-12-11 9:39 ` Bastian Krause
@ 2023-12-13 6:49 ` Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2023-12-13 6:49 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox, bst
On Fri, Dec 08, 2023 at 03:06:30PM +0100, Ahmad Fatoum wrote:
> 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(-)
Applied, thanks
Sascha
>
> 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
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-12-13 6:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-08 14:06 [PATCH] fastboot: sparse: print descriptive error on overflowing destination Ahmad Fatoum
2023-12-11 9:39 ` Bastian Krause
2023-12-13 6:49 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox