diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2021-10-06 15:14:22 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-11-10 08:55:19 +0100 |
commit | 408c741232b001894e12287f240b3e6c33efada8 (patch) | |
tree | 7258c6a1e14c2d0180aff87406bbf0d3a9864f3b /scripts/rkimage.c | |
parent | c72514fc3a11a907c13b253e7f7a247268eb790a (diff) | |
download | barebox-408c741232b001894e12287f240b3e6c33efada8.tar.gz barebox-408c741232b001894e12287f240b3e6c33efada8.tar.xz |
scripts/common: Add write_full() and read_full()
We have different implementations of read_full() and write_full() in our
host tools, use a common implementation for these.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts/rkimage.c')
-rw-r--r-- | scripts/rkimage.c | 39 |
1 files changed, 3 insertions, 36 deletions
diff --git a/scripts/rkimage.c b/scripts/rkimage.c index dde9724886..21a2838146 100644 --- a/scripts/rkimage.c +++ b/scripts/rkimage.c @@ -13,6 +13,9 @@ #include <errno.h> #include <stdbool.h> +#include "common.h" +#include "common.c" + #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) #define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) @@ -149,42 +152,6 @@ static void usage(const char *prgname) prgname); } -static int read_full(int fd, void *buf, size_t size) -{ - size_t insize = size; - int now; - int total = 0; - - while (size) { - now = read(fd, buf, size); - if (now == 0) - return total; - if (now < 0) - return now; - total += now; - size -= now; - buf += now; - } - - return insize; -} - -static int write_full(int fd, void *buf, size_t size) -{ - size_t insize = size; - int now; - - while (size) { - now = write(fd, buf, size); - if (now <= 0) - return now; - size -= now; - buf += now; - } - - return insize; -} - int main(int argc, char *argv[]) { int opt, i, fd; |