* [PATCH v2] mkimage: Fix error message if write less data then expected
@ 2020-07-08 9:52 Mylène Josserand
2020-07-17 20:58 ` Tom Rini
0 siblings, 1 reply; 3+ messages in thread
From: Mylène Josserand @ 2020-07-08 9:52 UTC (permalink / raw)
To: u-boot
Add a new error message in case the size of data written
are shorter than the one expected.
Currently, it will lead to the following error message:
"mkimage: Write error on uImage: Success"
This is not explicit when the error is because the device
doesn't have enough space. Let's use a more understandable message:
"mkimage: Write only 4202432/4682240 bytes, probably no space left on the device"
Signed-off-by: Myl?ne Josserand <mylene.josserand@collabora.com>
Reviewed-by: Walter Lozano <walter.lozano@collabora.com>
---
Changes since v1:
Set the message to be more explicit and saying that it is probably a
"No space left on device"
tools/mkimage.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/tools/mkimage.c b/tools/mkimage.c
index d2cd1917874..7cb666d4822 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -674,7 +674,7 @@ copy_file (int ifd, const char *datafile, int pad)
int zero = 0;
uint8_t zeros[4096];
int offset = 0;
- int size;
+ int size, ret;
struct image_type_params *tparams = imagetool_get_type(params.type);
memset(zeros, 0, sizeof(zeros));
@@ -730,9 +730,16 @@ copy_file (int ifd, const char *datafile, int pad)
}
size = sbuf.st_size - offset;
- if (write(ifd, ptr + offset, size) != size) {
- fprintf (stderr, "%s: Write error on %s: %s\n",
- params.cmdname, params.imagefile, strerror(errno));
+
+ ret = write(ifd, ptr + offset, size);
+ if (ret != size) {
+ if (ret < 0)
+ fprintf (stderr, "%s: Write error on %s: %s\n",
+ params.cmdname, params.imagefile, strerror(errno));
+ else if (ret < size)
+ fprintf (stderr, "%s: Write only %d/%d bytes, "\
+ "probably no space left on the device\n",
+ params.cmdname, ret, size);
exit (EXIT_FAILURE);
}
--
2.27.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2] mkimage: Fix error message if write less data then expected
2020-07-08 9:52 [PATCH v2] mkimage: Fix error message if write less data then expected Mylène Josserand
@ 2020-07-17 20:58 ` Tom Rini
2020-07-20 12:15 ` Mylene Josserand
0 siblings, 1 reply; 3+ messages in thread
From: Tom Rini @ 2020-07-17 20:58 UTC (permalink / raw)
To: u-boot
On Wed, Jul 08, 2020 at 11:52:50AM +0200, Myl?ne Josserand wrote:
> Add a new error message in case the size of data written
> are shorter than the one expected.
>
> Currently, it will lead to the following error message:
>
> "mkimage: Write error on uImage: Success"
>
> This is not explicit when the error is because the device
> doesn't have enough space. Let's use a more understandable message:
>
> "mkimage: Write only 4202432/4682240 bytes, probably no space left on the device"
>
> Signed-off-by: Myl?ne Josserand <mylene.josserand@collabora.com>
> Reviewed-by: Walter Lozano <walter.lozano@collabora.com>
Applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200717/317ca743/attachment.sig>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] mkimage: Fix error message if write less data then expected
2020-07-17 20:58 ` Tom Rini
@ 2020-07-20 12:15 ` Mylene Josserand
0 siblings, 0 replies; 3+ messages in thread
From: Mylene Josserand @ 2020-07-20 12:15 UTC (permalink / raw)
To: u-boot
Hello,
On 7/17/20 10:58 PM, Tom Rini wrote:
> On Wed, Jul 08, 2020 at 11:52:50AM +0200, Myl?ne Josserand wrote:
>
>> Add a new error message in case the size of data written
>> are shorter than the one expected.
>>
>> Currently, it will lead to the following error message:
>>
>> "mkimage: Write error on uImage: Success"
>>
>> This is not explicit when the error is because the device
>> doesn't have enough space. Let's use a more understandable message:
>>
>> "mkimage: Write only 4202432/4682240 bytes, probably no space left on the device"
>>
>> Signed-off-by: Myl?ne Josserand <mylene.josserand@collabora.com>
>> Reviewed-by: Walter Lozano <walter.lozano@collabora.com>
>
> Applied to u-boot/master, thanks!
>
Great, thank you!
Best regards,
Myl?ne
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-07-20 12:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-08 9:52 [PATCH v2] mkimage: Fix error message if write less data then expected Mylène Josserand
2020-07-17 20:58 ` Tom Rini
2020-07-20 12:15 ` Mylene Josserand
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.