Re: [PATCH RFC] gen_init_cpio: Do fsync() only on regular files

From: Dmitry Safonov

Date: Mon Oct 06 2025 - 20:08:06 EST


On Tue, Oct 7, 2025 at 12:55 AM Dmitry Safonov via B4 Relay
<devnull+dima.arista.com@xxxxxxxxxx> wrote:
>
> From: Dmitry Safonov <dima@xxxxxxxxxx>
>
> Here at Arista gen_init_cpio is used in testing in order to create
> an initramfs for specific tests. Most notably, there is a test that does
> essentially a fork-bomb in kdump/panic kernel, replacing build-time
> generated init script: instead of doing makedumpfile, it does call
> shell tests.
>
> In comparison to usr/Makefile, which creates an intermediate .cpio file,
> the Makefile that generates initrd for tests is a one-liner:
> > file lib/kdump ${src_dir}/oom-crashkernel 0644 0 0 | usr/gen_init_cpio /dev/stdin | xz -z -c -e -Ccrc32 > ${target_dir}/oom-crashkernel.initrd
>
> As fsync() on a pipe fd returns -EINVAL, that stopped working.

To clarify: because any sane bash script with pipes should use
set -eo pipefail
which indeed is set in the script that generates initrd.

Thanks,
Dmitry