[Toybox] [PATCH] cpio: support reading concatenated cpio files.

Rob Landley rob at landley.net
Wed Apr 14 00:26:39 PDT 2021


On 4/13/21 6:47 PM, enh via Toybox wrote:
> Apparently this is a thing people like to do, and they use shell while
> loops to do it (because cpio only reads one input file at a time from
> stdin).
> 
> To make this work, we need to (a) exit with a failure status rather than
> success if we hit EOF (we should never normally hit EOF because we
> should read a TRAILER!!! first), and (b) skip to the end of the
> TRAILER!!! record rather than just exiting immediately (so that the
> _next_ cpio to run can start reading stdin at the start of a record,
> rather than partway through the TRAILER!!! record that caused this cpio
> to stop).

Sigh, this came up in a discussion with the people trying to extend cpio format
to add xattrs to initramfs a year or so back. Most recently probably circa:

http://lkml.iu.edu/hypermail/linux/kernel/1905.2/01956.html

What the TRAILER!!! entry _actually_ means is "flush hardlink context". Search
for "handling of hardlinks" in:

https://www.kernel.org/doc/Documentation/early-userspace/buffer-format.txt

(I have a todo entry for this, but haven't cycled back around to it...)

> (The error message change in x8u is for the usual "it's harder to debug
> if two different failure cases in the code output the exact same error
> message", in this case "bad header".)

Could you read the linux doc thing and confirm that the behavior you want is
still to stop at TRAILER instead of flushing hardlink context but otherwise
continuing to extract like the kernel guys documented for initramfs? (Or am I
misremembering? It's been a while...)

Rob



More information about the Toybox mailing list