Skip to content

Commit 38492c5

Browse files
0x7f454c46nathanchance
authored andcommitted
gen_init_cpio: Ignore fsync() returning EINVAL on pipes
The reproducer: echo | ./usr/gen_init_cpio /dev/stdin > /dev/null fsync() on a pipe fd returns -EINVAL, which makes gen_init_cpio fail. Ignore -EINVAL from fsync(). Fixes: ae18b94 ("gen_init_cpio: support -o <output_file> parameter") Cc: David Disseldorp <ddiss@suse.de> Cc: Nicolas Schier <nsc@kernel.org> Signed-off-by: Dmitry Safonov <dima@arista.com> Reviewed-by: David Disseldorp <ddiss@suse.de> Link: https://patch.msgid.link/20251007-gen_init_cpio-pipe-v2-1-b098ab94b58a@arista.com Signed-off-by: Nathan Chancellor <nathan@kernel.org>
1 parent 7ded7d3 commit 38492c5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

usr/gen_init_cpio.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ static int cpio_trailer(void)
112112
push_pad(padlen(offset, 512)) < 0)
113113
return -1;
114114

115-
return fsync(outfd);
115+
if (fsync(outfd) < 0 && errno != EINVAL)
116+
return -1;
117+
118+
return 0;
116119
}
117120

118121
static int cpio_mkslink(const char *name, const char *target,

0 commit comments

Comments
 (0)