gen_init_cpio: Ignore fsync() returning EINVAL on pipes
PATCH v2 1/1 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().
---
Changes in v2:
- Instead of isfdtype() just ignore -EINVAL from fsync() (Suggested by David)
- Add minimal reproducer and shrink the patch description (David)
- Link to v1: https://lore.kernel.org/r/[email protected]
--- usr/gen_init_cpio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
usr/gen_init_cpio.c +4 -1
@@ -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,
---
base-commit: c746c3b5169831d7fb032a1051d8b45592ae8d78
change-id: 20251007-gen_init_cpio-pipe-5ad87f616a40
Best regards,
Signature · 1 line
Dmitry Safonov <[email protected]>
Quoted 8 lines · Dmitry Safonov
The reproducer:
echo |./usr/gen_init_cpio/dev/stdin>/dev/null
fsync()on a pipe fd returns-EINVAL, which makesgen_init_cpiofail. Ignore-EINVALfromfsync().[...]
Applied, thanks!
[1/1] gen_init_cpio: Ignore fsync() returning EINVAL on pipes
https://git.kernel.org/kbuild/c/38492c5743f8b
Best regards,
Signature · 1 line
Nathan Chancellor <[email protected]>