[klibc] initramfs gunzip problems.

Martin Hicks
Fri, 14 Nov 2003 07:58:24 -0000

I've been having an exchange of e-mails with Bryan O'Sullivan regarding
this problem.  I thought it time to bring it to the list.

I've run into a problem where my initramfs archives get this during
bootup:

checking if image is initramfs...it isn't (ungzip failed); looks like an
initrd

The same .cpio archive works if I don't gzip it.  I stuck a bunch of
debug statements into the gunzip function to see what was happening.
The core of the problem is in the init/initramfs.c, the populate_rootfs
and unpack_to_rootfs functions.

I see a 512byte image at &__initramfs_start being uncompressed.  Then I
see my image during the dry-run inside the "if (initrd_start)" block,
which gets checked correctly with gunzip().  The problem is that the
same call to unpack_to_rootfs() finds another header, which is broken.

I solved the problem with the following patch.  I realize this isn't a
really good patch (it doesn't even wait to check the status of the state
machine), but it fixes my problems.

Any ideas why I'm seeing the second header in the same initramfs image?

mh

--
Martin Hicks                Wild Open Source Inc.
mort@wildopensource.com     613-266-2296


===== initramfs.c 1.12 vs edited ====--- 1.12/init/initramfs.c	Sat Oct 18
11:25:50 2003
+++ edited/initramfs.c	Fri Nov 14 10:32:47 2003
@@ -459,6 +459,8 @@
 		makecrc();
 		if (gunzip())
 			message = "ungzip failed";
+		else
+			break;
 		if (state != Reset)
 			error("junk in gzipped archive");
 		this_header = saved_offset + inptr;