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

Yi-yo Chiang yochiang at google.com
Fri Apr 16 11:44:27 PDT 2021


I'm not sure what Elliot's goal is? I assume he's trying to extract a
concatenated ramdisk, and I still see a problem in the current solution.

The buffer-format (
https://www.kernel.org/doc/Documentation/early-userspace/buffer-format.txt)
says:

  initramfs  := ("\0" | cpio_archive | cpio_gzip_archive)*

In other words, both `cat a.cpio b.cpio >merged.cpio` and `(cat a.cpio &&
echo -n -e '\0\0\0' && cat b.cpio) >merged.cpio` are valid initramfs.

btw gen_init_cpio.c also pads initramfs to 512-byte boundary (
https://github.com/torvalds/linux/blob/6fbd6cf85a3be127454a1ad58525a3adcf8612ab/usr/gen_init_cpio.c#L97
)

If we're viewing buffer-format.txt as the "right" cpio spec, then I think
we should implement this too. We should skip arbitrary extra NUL-bytes
padded between cpio file frames


On Fri, Apr 16, 2021 at 2:27 PM Rob Landley <rob at landley.net> wrote:

> On 4/16/21 12:18 AM, Rob Landley wrote:
> > On 4/15/21 6:57 PM, Rob Landley wrote:
> >> On 4/15/21 12:06 PM, enh wrote:
> >>> do you already have the "do the right thing" patch ready, or should i
> send that
> >>> today?
> >>
> >> I'm good, I'll try to get it in tonight. The hard part is the test
> suite, not
> >> the implementation.
> >
> > Correction: the hard part is I don't seem to have actually implemented
> hardlink
> > support yet. It just records/extracts them as separate files.
> >
> > Right. I need to test this against the kernel initramfs plumbing, in both
> > directions...
>
>      if (!strcmp("TRAILER!!!", name)) {
> +      readall(afd, toybuf, 348);
>
> Where did you get 348 from? (What is this change doing?)
>
> I did what seems like a minimal change to continue past TRAILER!!! but
> error on
> an empty archive, but I apparently don't understand what your change did?
> (I'm
> assuming it fixed the use case you were seeing...?)
>
> Rob
> _______________________________________________
> Toybox mailing list
> Toybox at lists.landley.net
> http://lists.landley.net/listinfo.cgi/toybox-landley.net
>


-- 

Yi-yo Chiang
Software Engineer
yochiang at google.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20210417/a349435b/attachment.htm>


More information about the Toybox mailing list