
20 Mar
2014
20 Mar
'14
4:44 a.m.
This patch adds a function to mkimage.c called full_write() which calls write() in a loop until all the data has been written or write errors.
I was getting an error with mkimage running out of space on the device it was writing to, but instead of printing a useful error message it was printing:
mkimage: Write error on /tmp/flash.img: Success
Which is kinda confusing. It was printing this because write() was writing as many bytes as it could and then returning success. It needs to be called a second time to set errno. Also write(fd, data, count) isn't guranteed to write the full count bytes in one go anyway, so it needs to be called in a loop (that or use fwrite instead).