Skip to content

Commit cacb246

Browse files
Albin Tonnerretorvalds
authored andcommitted
Add LZO compression support for initramfs and old-style initrd
Signed-off-by: Albin Tonnerre <albin.tonnerre@free-electrons.com> Tested-by: Wu Zhangjin <wuzhangjin@gmail.com> Acked-by: "H. Peter Anvin" <hpa@zytor.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Thomas Gleixner <tglx@linutronix.de> Tested-by: Russell King <rmk@arm.linux.org.uk> Acked-by: Russell King <rmk@arm.linux.org.uk> Cc: Ralf Baechle <ralf@linux-mips.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 1351099 commit cacb246

4 files changed

Lines changed: 31 additions & 5 deletions

File tree

‎lib/Kconfig‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ config DECOMPRESS_BZIP2
117117
config DECOMPRESS_LZMA
118118
tristate
119119

120+
config DECOMPRESS_LZO
121+
select LZO_DECOMPRESS
122+
tristate
123+
120124
#
121125
# Generic allocator support is selected if needed
122126
#

‎lib/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ obj-$(CONFIG_LZO_DECOMPRESS) += lzo/
6969
lib-$(CONFIG_DECOMPRESS_GZIP) += decompress_inflate.o
7070
lib-$(CONFIG_DECOMPRESS_BZIP2) += decompress_bunzip2.o
7171
lib-$(CONFIG_DECOMPRESS_LZMA) += decompress_unlzma.o
72+
lib-$(CONFIG_DECOMPRESS_LZO) += decompress_unlzo.o
7273

7374
obj-$(CONFIG_TEXTSEARCH) += textsearch.o
7475
obj-$(CONFIG_TEXTSEARCH_KMP) += ts_kmp.o

‎lib/decompress.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <linux/decompress/bunzip2.h>
1010
#include <linux/decompress/unlzma.h>
1111
#include <linux/decompress/inflate.h>
12+
#include <linux/decompress/unlzo.h>
1213

1314
#include <linux/types.h>
1415
#include <linux/string.h>
@@ -22,6 +23,9 @@
2223
#ifndef CONFIG_DECOMPRESS_LZMA
2324
# define unlzma NULL
2425
#endif
26+
#ifndef CONFIG_DECOMPRESS_LZO
27+
# define unlzo NULL
28+
#endif
2529

2630
static const struct compress_format {
2731
unsigned char magic[2];
@@ -32,6 +36,7 @@ static const struct compress_format {
3236
{ {037, 0236}, "gzip", gunzip },
3337
{ {0x42, 0x5a}, "bzip2", bunzip2 },
3438
{ {0x5d, 0x00}, "lzma", unlzma },
39+
{ {0x89, 0x4c}, "lzo", unlzo },
3540
{ {0, 0}, NULL, NULL }
3641
};
3742

‎usr/Kconfig‎

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ config RD_LZMA
7272
Support loading of a LZMA encoded initial ramdisk or cpio buffer
7373
If unsure, say N.
7474

75+
config RD_LZO
76+
bool "Support initial ramdisks compressed using LZO" if EMBEDDED
77+
default !EMBEDDED
78+
depends on BLK_DEV_INITRD
79+
select DECOMPRESS_LZO
80+
help
81+
Support loading of a LZO encoded initial ramdisk or cpio buffer
82+
If unsure, say N.
83+
7584
choice
7685
prompt "Built-in initramfs compression mode" if INITRAMFS_SOURCE!=""
7786
help
@@ -108,16 +117,15 @@ config INITRAMFS_COMPRESSION_GZIP
108117
bool "Gzip"
109118
depends on RD_GZIP
110119
help
111-
The old and tried gzip compression. Its compression ratio is
112-
the poorest among the 3 choices; however its speed (both
113-
compression and decompression) is the fastest.
120+
The old and tried gzip compression. It provides a good balance
121+
between compression ratio and decompression speed.
114122

115123
config INITRAMFS_COMPRESSION_BZIP2
116124
bool "Bzip2"
117125
depends on RD_BZIP2
118126
help
119127
Its compression ratio and speed is intermediate.
120-
Decompression speed is slowest among the three. The initramfs
128+
Decompression speed is slowest among the four. The initramfs
121129
size is about 10% smaller with bzip2, in comparison to gzip.
122130
Bzip2 uses a large amount of memory. For modern kernels you
123131
will need at least 8MB RAM or more for booting.
@@ -128,7 +136,15 @@ config INITRAMFS_COMPRESSION_LZMA
128136
help
129137
The most recent compression algorithm.
130138
Its ratio is best, decompression speed is between the other
131-
two. Compression is slowest. The initramfs size is about 33%
139+
three. Compression is slowest. The initramfs size is about 33%
132140
smaller with LZMA in comparison to gzip.
133141

142+
config INITRAMFS_COMPRESSION_LZO
143+
bool "LZO"
144+
depends on RD_LZO
145+
help
146+
Its compression ratio is the poorest among the four. The kernel
147+
size is about about 10% bigger than gzip; however its speed
148+
(both compression and decompression) is the fastest.
149+
134150
endchoice

0 commit comments

Comments
 (0)