]> git.ipfire.org Git - thirdparty/ipxe.git/commit
[cpio] Allow for construction of parent directories as needed
authorMichael Brown <mcb30@ipxe.org>
Mon, 24 Feb 2025 14:04:06 +0000 (14:04 +0000)
committerMichael Brown <mcb30@ipxe.org>
Mon, 24 Feb 2025 14:37:26 +0000 (14:37 +0000)
commit12ea8c40741786ea33c866d131d510ae70897728
treef522313fdbdcb36c3fb4e21179812cd0798f8d07
parente7595fe88d8c32354cd61055cbc9f2e7b3f91ff8
[cpio] Allow for construction of parent directories as needed

iPXE allows individual raw files to be automatically wrapped with
suitable CPIO headers and injected into the magic initrd image as
exposed to a booted Linux kernel.  This feature is currently limited
to placing files within directories that already exist in the initrd
filesystem.

Remove this limitation by adding the ability for iPXE to construct
CPIO headers for parent directories as needed, under control of the
"mkdir=<n>" command-line argument.  For example:

  initrd config.ign /usr/share/oem/config.ign mkdir=1

will create CPIO headers for the "/usr/share/oem" directory as well as
for the "/usr/share/oem/config.ign" file itself.

This simplifies the process of booting operating systems such as
Flatcar Linux, which otherwise require the single "config.ign" file to
be manually wrapped up as a CPIO archive solely in order to create the
relevant parent directory entries.

The value <n> may be used to control the number of parent directory
entries that are created.  For example, "mkdir=2" would cause up to
two parent directories to be created (i.e. "/usr/share" and
"/usr/share/oem" in the above example).  A negative value such as
"mkdir=-1" may be used to create all parent directories up to the root
of the tree.

Do not create any parent directory entries by default, since doing so
would potentially cause the modes and ownership information for
existing directories to be overwritten.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/x86/image/bzimage.c
src/core/cpio.c
src/include/ipxe/cpio.h
src/interface/efi/efi_file.c