[U-Boot] [PATCH 1/2] tools: mkenvimage: Fix reading from slow pipe

Alexander Dahl ada at thorsis.com
Mon Jul 1 06:31:52 UTC 2019


Hello Andre,

Am Sonntag, 30. Juni 2019, 02:45:00 CEST schrieb Andre Przywara:
> It is perfectly fine for the read(2) syscall to return with less than
> the requested number of bytes read (short read, see the "RETURN VALUE"
> section of the man page). This typically happens with slow input
> (keyboard, network) or with complex pipes.
> 
> So far mkenvimage expects the exact number of requested bytes to be
> read, assuming an end-of-file condition otherwise. This wrong behaviour
> can be easily shown with:
> $ (echo "foo=bar"; sleep 1; echo "bar=baz") | mkenvimage -s 256 -o out -
> The second line will be missing from the output.
> 
> Correct this by checking for any positive, non-zero return value.
> 
> This fixes a problem with a complex pipe in one of my scripts, where
> the environment consist of two parts.
> 
> Signed-off-by: Andre Przywara <andre.przywara at arm.com>

>From reading the code and 'man 2 read' again, not tested locally:

Acked-by: Alexander Dahl <ada at thorsis.com>

Greets
Alex



More information about the U-Boot mailing list