mtd: fix reading of image magic bytes in smaller chunks
authorblogic <blogic@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Thu, 3 Mar 2016 20:24:38 +0000 (20:24 +0000)
committerblogic <blogic@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Thu, 3 Mar 2016 20:24:38 +0000 (20:24 +0000)
commit891755fa71eba8375d3152e5f35ff69619a9c723
tree127d9daddad0f56954592ec0b2cb94168fa4d021
parentdb5da20e34cc382883fd7a803b0eb11af31f488e
mtd: fix reading of image magic bytes in smaller chunks

The image_check currently fails when it cannot read all magic bytes in a
single chunk. But this can happen when the data are read from a pipe. This
currently breaks the openmesh.sh upgrade script with musl because it uses
dd with a blocksize of 1 to copy the image file to the mtd process.

The read can simply be repeated until enough bytes are read for the magic
byte check. It only stops when either an error was returned or 0 bytes were
read.

Signed-off-by: Sven Eckelmann <sven.eckelmann@open-mesh.com>
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@48891 3c298f89-4303-0410-b956-a3cf2f4a3e73
package/system/mtd/src/mtd.c