aboutsummaryrefslogtreecommitdiffstats
path: root/init
diff options
context:
space:
mode:
authorMilton D. Miller II <miltonm@bga.com>2005-01-07 21:42:41 -0800
committerLinus Torvalds <torvalds@evo.osdl.org>2005-01-07 21:42:41 -0800
commitfd604180c07f26beaaa7efc84ca74bf87a152b9e (patch)
tree2f701db3b7f0ce948b3f768b60b1d290ebc542d0 /init
parent7a2398ccd5341e56172e23489ebaffde61273e38 (diff)
downloadhistory-fd604180c07f26beaaa7efc84ca74bf87a152b9e.tar.gz
[PATCH] INITRAMFS: allow no trailer
According to "initramfs buffer format -- third draft" http://lwn.net/2002/0117/a/initramfs-buffer-format.php3 "the cpio "TRAILER!!!" entry (cpio end-of-archive) is optional, but is not ignored" The kernel handling does not follow this spec. If you add null padding after an uncompressed cpio without TRAILER!!! the kernel complains "no cpio magic". In a gzipped archive one gets "junk in gzipped archive" without the TRAILER!!! This patch changes the state transitions so the kernel will follow the spec. Tested: padded uncompressed, padded compressed, unpadded compressed (error) and trailing junk in compressed (error) === I have a boot loader that knows how to load files, determine their size, and advance to the next 4-byte boundary and reports the total size of the files loaded. It doesn't understand about converting this number to some ASCII representation. With this patch I can embed the contents of a file padded with NULs with out knowing the exact size of the file with the following files: 1) file containing cpio header & file name, padded to 4 bytes 2) contents of file 3) pad file of zeros, the size at least as large as the that specified for the file. hpa points out that you should be careful with the headers, use unique inode numbers and/or add a cpio header with just TRAILER!!! to reset the inode hash table to avoid unwanted hard links. I just put this sequence as the last files loaded. Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'init')
-rw-r--r--init/initramfs.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/init/initramfs.c b/init/initramfs.c
index 722bb17241f230..33b4983841235a 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -241,10 +241,9 @@ static __initdata int wfd;
static int __init do_name(void)
{
state = SkipIt;
- next_state = Start;
+ next_state = Reset;
if (strcmp(collected, "TRAILER!!!") == 0) {
free_hash();
- next_state = Reset;
return 0;
}
if (dry_run)
@@ -295,7 +294,7 @@ static int __init do_symlink(void)
sys_symlink(collected + N_ALIGN(name_len), collected);
sys_lchown(collected, uid, gid);
state = SkipIt;
- next_state = Start;
+ next_state = Reset;
return 0;
}
@@ -331,6 +330,10 @@ static void __init flush_buffer(char *buf, unsigned len)
buf += written;
len -= written;
state = Start;
+ } else if (c == 0) {
+ buf += written;
+ len -= written;
+ state = Reset;
} else
error("junk in compressed archive");
}