From 38492c5743f8b7213ca86f0cd72ea625af35d5ef Mon Sep 17 00:00:00 2001 From: Dmitry Safonov Date: Tue, 7 Oct 2025 04:46:47 +0100 Subject: [PATCH] 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: ae18b94099b0 ("gen_init_cpio: support -o parameter") Cc: David Disseldorp Cc: Nicolas Schier Signed-off-by: Dmitry Safonov Reviewed-by: David Disseldorp Link: https://patch.msgid.link/20251007-gen_init_cpio-pipe-v2-1-b098ab94b58a@arista.com Signed-off-by: Nathan Chancellor --- usr/gen_init_cpio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/usr/gen_init_cpio.c b/usr/gen_init_cpio.c index 75e9561ba313..b7296edc6626 100644 --- a/usr/gen_init_cpio.c +++ b/usr/gen_init_cpio.c @@ -112,7 +112,10 @@ static int cpio_trailer(void) push_pad(padlen(offset, 512)) < 0) return -1; - return fsync(outfd); + if (fsync(outfd) < 0 && errno != EINVAL) + return -1; + + return 0; } static int cpio_mkslink(const char *name, const char *target, -- 2.47.3