1 Index: linux-2.6.25.4/scripts/gen_initramfs_list.sh
2 ===================================================================
3 --- linux-2.6.25.4.orig/scripts/gen_initramfs_list.sh
4 +++ linux-2.6.25.4/scripts/gen_initramfs_list.sh
5 @@ -287,7 +287,7 @@ if [ ! -z ${output_file} ]; then
6 if [ "${is_cpio_compressed}" = "compressed" ]; then
7 cat ${cpio_tfile} > ${output_file}
9 - cat ${cpio_tfile} | gzip -f -9 - > ${output_file}
10 + lzma e -lc1 -lp2 -pb2 ${cpio_tfile} ${output_file}
12 [ -z ${cpio_file} ] && rm ${cpio_tfile}
14 Index: linux-2.6.25.4/init/initramfs.c
15 ===================================================================
16 --- linux-2.6.25.4.orig/init/initramfs.c
17 +++ linux-2.6.25.4/init/initramfs.c
18 @@ -441,6 +441,69 @@ static void __init flush_window(void)
22 +#include <linux/LzmaDecode.h>
23 +static int __init lzma_unzip(void)
25 + unsigned int i; /* temp value */
26 + unsigned int lc; /* literal context bits */
27 + unsigned int lp; /* literal pos state bits */
28 + unsigned int pb; /* pos state bits */
29 + unsigned int osize; /* uncompressed size */
30 + unsigned char *workspace;
31 + unsigned char* outputbuffer;
32 + unsigned int outsizeProcessed = 0;
38 + lc = i % 9, i = i / 9;
39 + lp = i % 5, pb = i / 5;
41 + // skip dictionary size
42 + for (i = 0; i < 4; i++)
45 + /* read the lower half of uncompressed size in the header */
46 + osize = ((unsigned int)get_byte()) +
47 + ((unsigned int)get_byte() << 8) +
48 + ((unsigned int)get_byte() << 16) +
49 + ((unsigned int)get_byte() << 24);
51 + /* skip rest of the header (upper half of uncompressed size) */
52 + for (i = 0; i < 4; i++)
55 + workspace_size = ((LZMA_BASE_SIZE + (LZMA_LIT_SIZE << (lc + lp))) * sizeof(CProb)) + 100;
56 + printk( KERN_NOTICE "initramfs: LZMA lc=%d,lp=%d,pb=%d,origSize=%d\n",
58 + outputbuffer = kmalloc(osize, GFP_KERNEL);
59 + if (outputbuffer == 0) {
60 + printk(KERN_ERR "initramfs: Couldn't allocate lzma output buffer\n");
64 + workspace = kmalloc(workspace_size, GFP_KERNEL);
65 + if (workspace == NULL) {
66 + printk(KERN_ERR "initramfs: Couldn't allocate lzma workspace\n");
70 + res = LzmaDecode(workspace, workspace_size, lc, lp, pb, inbuf + inptr, insize - inptr, outputbuffer, osize, &outsizeProcessed);
72 + panic( KERN_ERR "initramfs: Lzma decode failure\n");
76 + flush_buffer(outputbuffer, outsizeProcessed);
79 + kfree(outputbuffer);
85 static char * __init unpack_to_rootfs(char *buf, unsigned len, int check_only)
88 @@ -475,12 +538,28 @@ static char * __init unpack_to_rootfs(ch
90 outcnt = 0; /* bytes in output buffer */
92 - crc = (ulg)0xffffffffL; /* shift register contents */
96 + if( inbuf[0] == 037 && ((inbuf[1] == 0213) || (inbuf[1] == 0236)))
98 + printk( KERN_NOTICE "detected gzip initramfs\n");
99 + crc = (ulg)0xffffffffL; /* shift register contents */
102 + if (state != Reset)
103 error("junk in gzipped archive");
104 - this_header = saved_offset + inptr;
106 + else if(!memcmp(inbuf+1, "\x00\x00\x80\x00", 4)) /* FIXME: hardcoded dictionary size */
108 + printk( KERN_NOTICE "detected lzma initramfs\n");
114 + crc = (ulg)0xffffffffL; /* shift register contents */
118 + this_header = saved_offset + inptr;