summaryrefslogtreecommitdiff
path: root/usr
diff options
context:
space:
mode:
Diffstat (limited to 'usr')
-rw-r--r--usr/gen_init_cpio.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/usr/gen_init_cpio.c b/usr/gen_init_cpio.c
index ea4b9b5fed01..aa73afd3756c 100644
--- a/usr/gen_init_cpio.c
+++ b/usr/gen_init_cpio.c
@@ -354,6 +354,7 @@ static int cpio_mkfile(const char *name, const char *location,
int namesize;
unsigned int i;
uint32_t csum = 0;
+ ssize_t this_read;
mode |= S_IFREG;
@@ -429,9 +430,19 @@ static int cpio_mkfile(const char *name, const char *location,
push_pad(padlen(offset, 4)) < 0)
goto error;
+ if (size) {
+ this_read = copy_file_range(file, NULL, outfd, NULL, size, 0);
+ if (this_read > 0) {
+ if (this_read > size)
+ goto error;
+ offset += this_read;
+ size -= this_read;
+ }
+ /* short or failed copy falls back to read/write... */
+ }
+
while (size) {
unsigned char filebuf[65536];
- ssize_t this_read;
size_t this_size = MIN(size, sizeof(filebuf));
this_read = read(file, filebuf, this_size);