Re: [update3] [PATCH] init: bzip2 or lzma -compressed kernels andinitrds

From: H. Peter Anvin
Date: Thu Sep 11 2008 - 18:45:00 EST

Alain Knaff wrote:
From: Alain Knaff <alain@xxxxxxxx>

This is an updated version of my bzip2/lzma patch

It is based on an idea by Christian Ludwig, includes support for
compressing the kernel with bzip2 or lzma rather than gzip. Both
compressors give smaller sizes than gzip. Lzma's decompresses faster
than bzip2.

It also supports ramdisks and initramfs' compressed using these two

The functionality has been successfully used for a couple of years by
the udpcast project

This version applies to "tip" kernel 2.6.27-rc5

Changes since last version (update2):

- Removed NEW_CODE #ifdef : non-Intel architectures will be patched
eventually anyways
- Replaced IN_MEMORY #ifdefs by (less efficient) runtime checks

Signed-off-by: Alain Knaff <alain@xxxxxxxx>

Looks a lot better now. See the following, though:

-#define OF(args) args
#define STATIC static
+#define NEW_CODE

Should be deleted, right?

- phdrs = malloc(sizeof(*phdrs) * ehdr.e_phnum);
+ phdrs = (void *) malloc(sizeof(*phdrs) * ehdr.e_phnum);
if (!phdrs)

malloc() returns a void pointer already...

+ /*
+ * If it matches the bzip magic numbers, return -1
+ */
+ if (buf[0] == 0x42 && (buf[1] == 0x5a)) {
+ printk(KERN_NOTICE
+ "RAMDISK: Bzipped image found at block %d\n",
+ start_block);
+ *uncompressor = bunzip2;
nblocks = 0;
goto done;
+ /*
+ * If it matches the bzip magic numbers, return -1
+ */
+ if (buf[0] == 0x5d && (buf[1] == 0x00)) {
+ printk(KERN_NOTICE
+ "RAMDISK: Lzma image found at block %d\n",
+ start_block);

-#define OF(args) args
+#include <linux/decompress_bunzip2.h>
+#include <linux/decompress_unlzma.h>

There is no reason to include header files conditionally.

It might be worthwhile to create a proper subdirectory rather than using an underscored namespace (also, in general, dashes are preferred in filenames.)

+#ifndef always_inline
+# if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
+# define always_inline __attribute__((always_inline)) inline
+# else
+# define always_inline inline
+# endif

Any reason to not just use <linux/compiler.h> here?

+# define speed_inline always_inline
+# define speed_inline

Should this be always_inline or just plain inline?

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at