On Tue, Mar 8, 2011 at 4:39 PM, Loïc Minier <[email protected]> wrote:
> On Wed, Mar 09, 2011, Shawn Guo wrote:
>> I just added this one, and it does not help. The l-m-c still fails at
>> the last step.
>> mkimage: Write error on /tmp/tmpUiR_m1/boot-disc/uImage: Success
>
> This error sounded a bit weird; I checked the u-boot sources, and this
> string is used in a bunch of places, but essentially it's either on
> write() or on close() that this fails. I bet it's on write() as I
> don't see close() failing without an useful errno, but I could imagine
> the write tests failing:
> if (write(ifd, tparams->hdr, tparams->header_size)
> != tparams->header_size) {
> fprintf (stderr, "%s: Write error on %s: %s\n",
> params.cmdname, params.imagefile, strerror(errno));
> notably if this is a partial write.
libc.info in particular says (of write()):
"The return value is the number of bytes actually written. This
may be SIZE, but can always be smaller. Your program should
always call `write' in a loop, iterating until all the data is
written."
>
> We could change mkimage's write()s to actually account for the number
> of bytes written rather than just failing when not all bytes were
> written.
There's no reason I can see for mkimage to use the low-level POSIX
read/write interface. Life would be simpler (and more portable) if it
just used stdio, because it provides the desired semantics...
More realistically, we could just propose a write() wrapper contains
the necessary loop to provide the expected semantics.
We should check for other instances of the same error, possibly
including calls to read() as well. However, I can't find clear
documentation on whether a short read() should ever occur on a normal
file in the absence of signals, provided there is enough data in the
file. Usually I assume that short reads might happen because
otherwise the program won't work properly on pipes, sockets etc., but
this is probably not so much of a concern for mkimage.
The natty version of u-boot has just the same error with write(); see:
http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/natty/u-boot/natty/view/head:/tools/mkimage.c
The upstream master branch of U-Boot on git://git.denx.de/u-boot.git
has the bug too.
Cheers
---Dave
_______________________________________________
linaro-dev mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/linaro-dev