diff options
Diffstat (limited to 'usr')
-rw-r--r-- | usr/Kconfig | 20 | ||||
-rw-r--r-- | usr/Makefile | 14 | ||||
-rw-r--r-- | usr/gen_init_cpio.c | 20 | ||||
-rw-r--r-- | usr/initramfs_data.S | 22 | ||||
-rw-r--r-- | usr/initramfs_data.bz2.S | 29 | ||||
-rw-r--r-- | usr/initramfs_data.gz.S | 29 | ||||
-rw-r--r-- | usr/initramfs_data.lzma.S | 29 |
7 files changed, 59 insertions, 104 deletions
diff --git a/usr/Kconfig b/usr/Kconfig index e2721f5a3504..4780deac5974 100644 --- a/usr/Kconfig +++ b/usr/Kconfig | |||
@@ -72,6 +72,15 @@ config RD_LZMA | |||
72 | Support loading of a LZMA encoded initial ramdisk or cpio buffer | 72 | Support loading of a LZMA encoded initial ramdisk or cpio buffer |
73 | If unsure, say N. | 73 | If unsure, say N. |
74 | 74 | ||
75 | config RD_XZ | ||
76 | bool "Support initial ramdisks compressed using XZ" if EMBEDDED | ||
77 | default !EMBEDDED | ||
78 | depends on BLK_DEV_INITRD | ||
79 | select DECOMPRESS_XZ | ||
80 | help | ||
81 | Support loading of a XZ encoded initial ramdisk or cpio buffer. | ||
82 | If unsure, say N. | ||
83 | |||
75 | config RD_LZO | 84 | config RD_LZO |
76 | bool "Support initial ramdisks compressed using LZO" if EMBEDDED | 85 | bool "Support initial ramdisks compressed using LZO" if EMBEDDED |
77 | default !EMBEDDED | 86 | default !EMBEDDED |
@@ -139,12 +148,21 @@ config INITRAMFS_COMPRESSION_LZMA | |||
139 | three. Compression is slowest. The initramfs size is about 33% | 148 | three. Compression is slowest. The initramfs size is about 33% |
140 | smaller with LZMA in comparison to gzip. | 149 | smaller with LZMA in comparison to gzip. |
141 | 150 | ||
151 | config INITRAMFS_COMPRESSION_XZ | ||
152 | bool "XZ" | ||
153 | depends on RD_XZ | ||
154 | help | ||
155 | XZ uses the LZMA2 algorithm. The initramfs size is about 30% | ||
156 | smaller with XZ in comparison to gzip. Decompression speed | ||
157 | is better than that of bzip2 but worse than gzip and LZO. | ||
158 | Compression is slow. | ||
159 | |||
142 | config INITRAMFS_COMPRESSION_LZO | 160 | config INITRAMFS_COMPRESSION_LZO |
143 | bool "LZO" | 161 | bool "LZO" |
144 | depends on RD_LZO | 162 | depends on RD_LZO |
145 | help | 163 | help |
146 | Its compression ratio is the poorest among the four. The kernel | 164 | Its compression ratio is the poorest among the four. The kernel |
147 | size is about about 10% bigger than gzip; however its speed | 165 | size is about 10% bigger than gzip; however its speed |
148 | (both compression and decompression) is the fastest. | 166 | (both compression and decompression) is the fastest. |
149 | 167 | ||
150 | endchoice | 168 | endchoice |
diff --git a/usr/Makefile b/usr/Makefile index 1e6a9e4a72cc..029ffe6cd0d8 100644 --- a/usr/Makefile +++ b/usr/Makefile | |||
@@ -15,13 +15,21 @@ suffix_$(CONFIG_INITRAMFS_COMPRESSION_BZIP2) = .bz2 | |||
15 | # Lzma | 15 | # Lzma |
16 | suffix_$(CONFIG_INITRAMFS_COMPRESSION_LZMA) = .lzma | 16 | suffix_$(CONFIG_INITRAMFS_COMPRESSION_LZMA) = .lzma |
17 | 17 | ||
18 | # XZ | ||
19 | suffix_$(CONFIG_INITRAMFS_COMPRESSION_XZ) = .xz | ||
20 | |||
21 | # Lzo | ||
22 | suffix_$(CONFIG_INITRAMFS_COMPRESSION_LZO) = .lzo | ||
23 | |||
24 | AFLAGS_initramfs_data.o += -DINITRAMFS_IMAGE="usr/initramfs_data.cpio$(suffix_y)" | ||
25 | |||
18 | # Generate builtin.o based on initramfs_data.o | 26 | # Generate builtin.o based on initramfs_data.o |
19 | obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data$(suffix_y).o | 27 | obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o |
20 | 28 | ||
21 | # initramfs_data.o contains the compressed initramfs_data.cpio image. | 29 | # initramfs_data.o contains the compressed initramfs_data.cpio image. |
22 | # The image is included using .incbin, a dependency which is not | 30 | # The image is included using .incbin, a dependency which is not |
23 | # tracked automatically. | 31 | # tracked automatically. |
24 | $(obj)/initramfs_data$(suffix_y).o: $(obj)/initramfs_data.cpio$(suffix_y) FORCE | 32 | $(obj)/initramfs_data.o: $(obj)/initramfs_data.cpio$(suffix_y) FORCE |
25 | 33 | ||
26 | ##### | 34 | ##### |
27 | # Generate the initramfs cpio archive | 35 | # Generate the initramfs cpio archive |
@@ -45,7 +53,7 @@ endif | |||
45 | quiet_cmd_initfs = GEN $@ | 53 | quiet_cmd_initfs = GEN $@ |
46 | cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input) | 54 | cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input) |
47 | 55 | ||
48 | targets := initramfs_data.cpio.gz initramfs_data.cpio.bz2 initramfs_data.cpio.lzma initramfs_data.cpio | 56 | targets := initramfs_data.cpio.gz initramfs_data.cpio.bz2 initramfs_data.cpio.lzma initramfs_data.cpio.xz initramfs_data.cpio.lzo initramfs_data.cpio |
49 | # do not try to update files included in initramfs | 57 | # do not try to update files included in initramfs |
50 | $(deps_initramfs): ; | 58 | $(deps_initramfs): ; |
51 | 59 | ||
diff --git a/usr/gen_init_cpio.c b/usr/gen_init_cpio.c index b2b3c2d1cf8b..7f06884ecd41 100644 --- a/usr/gen_init_cpio.c +++ b/usr/gen_init_cpio.c | |||
@@ -104,6 +104,8 @@ static int cpio_mkslink(const char *name, const char *target, | |||
104 | char s[256]; | 104 | char s[256]; |
105 | time_t mtime = time(NULL); | 105 | time_t mtime = time(NULL); |
106 | 106 | ||
107 | if (name[0] == '/') | ||
108 | name++; | ||
107 | sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX" | 109 | sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX" |
108 | "%08X%08X%08X%08X%08X%08X%08X", | 110 | "%08X%08X%08X%08X%08X%08X%08X", |
109 | "070701", /* magic */ | 111 | "070701", /* magic */ |
@@ -152,6 +154,8 @@ static int cpio_mkgeneric(const char *name, unsigned int mode, | |||
152 | char s[256]; | 154 | char s[256]; |
153 | time_t mtime = time(NULL); | 155 | time_t mtime = time(NULL); |
154 | 156 | ||
157 | if (name[0] == '/') | ||
158 | name++; | ||
155 | sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX" | 159 | sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX" |
156 | "%08X%08X%08X%08X%08X%08X%08X", | 160 | "%08X%08X%08X%08X%08X%08X%08X", |
157 | "070701", /* magic */ | 161 | "070701", /* magic */ |
@@ -245,6 +249,8 @@ static int cpio_mknod(const char *name, unsigned int mode, | |||
245 | else | 249 | else |
246 | mode |= S_IFCHR; | 250 | mode |= S_IFCHR; |
247 | 251 | ||
252 | if (name[0] == '/') | ||
253 | name++; | ||
248 | sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX" | 254 | sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX" |
249 | "%08X%08X%08X%08X%08X%08X%08X", | 255 | "%08X%08X%08X%08X%08X%08X%08X", |
250 | "070701", /* magic */ | 256 | "070701", /* magic */ |
@@ -303,18 +309,18 @@ static int cpio_mkfile(const char *name, const char *location, | |||
303 | 309 | ||
304 | mode |= S_IFREG; | 310 | mode |= S_IFREG; |
305 | 311 | ||
306 | retval = stat (location, &buf); | ||
307 | if (retval) { | ||
308 | fprintf (stderr, "File %s could not be located\n", location); | ||
309 | goto error; | ||
310 | } | ||
311 | |||
312 | file = open (location, O_RDONLY); | 312 | file = open (location, O_RDONLY); |
313 | if (file < 0) { | 313 | if (file < 0) { |
314 | fprintf (stderr, "File %s could not be opened for reading\n", location); | 314 | fprintf (stderr, "File %s could not be opened for reading\n", location); |
315 | goto error; | 315 | goto error; |
316 | } | 316 | } |
317 | 317 | ||
318 | retval = fstat(file, &buf); | ||
319 | if (retval) { | ||
320 | fprintf(stderr, "File %s could not be stat()'ed\n", location); | ||
321 | goto error; | ||
322 | } | ||
323 | |||
318 | filebuf = malloc(buf.st_size); | 324 | filebuf = malloc(buf.st_size); |
319 | if (!filebuf) { | 325 | if (!filebuf) { |
320 | fprintf (stderr, "out of memory\n"); | 326 | fprintf (stderr, "out of memory\n"); |
@@ -332,6 +338,8 @@ static int cpio_mkfile(const char *name, const char *location, | |||
332 | /* data goes on last link */ | 338 | /* data goes on last link */ |
333 | if (i == nlinks) size = buf.st_size; | 339 | if (i == nlinks) size = buf.st_size; |
334 | 340 | ||
341 | if (name[0] == '/') | ||
342 | name++; | ||
335 | namesize = strlen(name) + 1; | 343 | namesize = strlen(name) + 1; |
336 | sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX" | 344 | sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX" |
337 | "%08lX%08X%08X%08X%08X%08X%08X", | 345 | "%08lX%08X%08X%08X%08X%08X%08X", |
diff --git a/usr/initramfs_data.S b/usr/initramfs_data.S index 7c6973d8d829..c14322d1c0cf 100644 --- a/usr/initramfs_data.S +++ b/usr/initramfs_data.S | |||
@@ -11,11 +11,7 @@ | |||
11 | -T initramfs_data.scr initramfs_data.cpio.gz -o initramfs_data.o | 11 | -T initramfs_data.scr initramfs_data.cpio.gz -o initramfs_data.o |
12 | ld -m elf_i386 -r -o built-in.o initramfs_data.o | 12 | ld -m elf_i386 -r -o built-in.o initramfs_data.o |
13 | 13 | ||
14 | initramfs_data.scr looks like this: | 14 | For including the .init.ramfs sections, see include/asm-generic/vmlinux.lds. |
15 | SECTIONS | ||
16 | { | ||
17 | .init.ramfs : { *(.data) } | ||
18 | } | ||
19 | 15 | ||
20 | The above example is for i386 - the parameters vary from architectures. | 16 | The above example is for i386 - the parameters vary from architectures. |
21 | Eventually look up LDFLAGS_BLOB in an older version of the | 17 | Eventually look up LDFLAGS_BLOB in an older version of the |
@@ -25,6 +21,18 @@ SECTIONS | |||
25 | in the ELF header, as required by certain architectures. | 21 | in the ELF header, as required by certain architectures. |
26 | */ | 22 | */ |
27 | 23 | ||
28 | .section .init.ramfs,"a" | 24 | #include <linux/stringify.h> |
29 | .incbin "usr/initramfs_data.cpio" | 25 | #include <asm-generic/vmlinux.lds.h> |
30 | 26 | ||
27 | .section .init.ramfs,"a" | ||
28 | __irf_start: | ||
29 | .incbin __stringify(INITRAMFS_IMAGE) | ||
30 | __irf_end: | ||
31 | .section .init.ramfs.info,"a" | ||
32 | .globl VMLINUX_SYMBOL(__initramfs_size) | ||
33 | VMLINUX_SYMBOL(__initramfs_size): | ||
34 | #ifdef CONFIG_64BIT | ||
35 | .quad __irf_end - __irf_start | ||
36 | #else | ||
37 | .long __irf_end - __irf_start | ||
38 | #endif | ||
diff --git a/usr/initramfs_data.bz2.S b/usr/initramfs_data.bz2.S deleted file mode 100644 index bc54d090365c..000000000000 --- a/usr/initramfs_data.bz2.S +++ /dev/null | |||
@@ -1,29 +0,0 @@ | |||
1 | /* | ||
2 | initramfs_data includes the compressed binary that is the | ||
3 | filesystem used for early user space. | ||
4 | Note: Older versions of "as" (prior to binutils 2.11.90.0.23 | ||
5 | released on 2001-07-14) dit not support .incbin. | ||
6 | If you are forced to use older binutils than that then the | ||
7 | following trick can be applied to create the resulting binary: | ||
8 | |||
9 | |||
10 | ld -m elf_i386 --format binary --oformat elf32-i386 -r \ | ||
11 | -T initramfs_data.scr initramfs_data.cpio.gz -o initramfs_data.o | ||
12 | ld -m elf_i386 -r -o built-in.o initramfs_data.o | ||
13 | |||
14 | initramfs_data.scr looks like this: | ||
15 | SECTIONS | ||
16 | { | ||
17 | .init.ramfs : { *(.data) } | ||
18 | } | ||
19 | |||
20 | The above example is for i386 - the parameters vary from architectures. | ||
21 | Eventually look up LDFLAGS_BLOB in an older version of the | ||
22 | arch/$(ARCH)/Makefile to see the flags used before .incbin was introduced. | ||
23 | |||
24 | Using .incbin has the advantage over ld that the correct flags are set | ||
25 | in the ELF header, as required by certain architectures. | ||
26 | */ | ||
27 | |||
28 | .section .init.ramfs,"a" | ||
29 | .incbin "usr/initramfs_data.cpio.bz2" | ||
diff --git a/usr/initramfs_data.gz.S b/usr/initramfs_data.gz.S deleted file mode 100644 index 890c8dd1d6bd..000000000000 --- a/usr/initramfs_data.gz.S +++ /dev/null | |||
@@ -1,29 +0,0 @@ | |||
1 | /* | ||
2 | initramfs_data includes the compressed binary that is the | ||
3 | filesystem used for early user space. | ||
4 | Note: Older versions of "as" (prior to binutils 2.11.90.0.23 | ||
5 | released on 2001-07-14) dit not support .incbin. | ||
6 | If you are forced to use older binutils than that then the | ||
7 | following trick can be applied to create the resulting binary: | ||
8 | |||
9 | |||
10 | ld -m elf_i386 --format binary --oformat elf32-i386 -r \ | ||
11 | -T initramfs_data.scr initramfs_data.cpio.gz -o initramfs_data.o | ||
12 | ld -m elf_i386 -r -o built-in.o initramfs_data.o | ||
13 | |||
14 | initramfs_data.scr looks like this: | ||
15 | SECTIONS | ||
16 | { | ||
17 | .init.ramfs : { *(.data) } | ||
18 | } | ||
19 | |||
20 | The above example is for i386 - the parameters vary from architectures. | ||
21 | Eventually look up LDFLAGS_BLOB in an older version of the | ||
22 | arch/$(ARCH)/Makefile to see the flags used before .incbin was introduced. | ||
23 | |||
24 | Using .incbin has the advantage over ld that the correct flags are set | ||
25 | in the ELF header, as required by certain architectures. | ||
26 | */ | ||
27 | |||
28 | .section .init.ramfs,"a" | ||
29 | .incbin "usr/initramfs_data.cpio.gz" | ||
diff --git a/usr/initramfs_data.lzma.S b/usr/initramfs_data.lzma.S deleted file mode 100644 index e11469e48562..000000000000 --- a/usr/initramfs_data.lzma.S +++ /dev/null | |||
@@ -1,29 +0,0 @@ | |||
1 | /* | ||
2 | initramfs_data includes the compressed binary that is the | ||
3 | filesystem used for early user space. | ||
4 | Note: Older versions of "as" (prior to binutils 2.11.90.0.23 | ||
5 | released on 2001-07-14) dit not support .incbin. | ||
6 | If you are forced to use older binutils than that then the | ||
7 | following trick can be applied to create the resulting binary: | ||
8 | |||
9 | |||
10 | ld -m elf_i386 --format binary --oformat elf32-i386 -r \ | ||
11 | -T initramfs_data.scr initramfs_data.cpio.gz -o initramfs_data.o | ||
12 | ld -m elf_i386 -r -o built-in.o initramfs_data.o | ||
13 | |||
14 | initramfs_data.scr looks like this: | ||
15 | SECTIONS | ||
16 | { | ||
17 | .init.ramfs : { *(.data) } | ||
18 | } | ||
19 | |||
20 | The above example is for i386 - the parameters vary from architectures. | ||
21 | Eventually look up LDFLAGS_BLOB in an older version of the | ||
22 | arch/$(ARCH)/Makefile to see the flags used before .incbin was introduced. | ||
23 | |||
24 | Using .incbin has the advantage over ld that the correct flags are set | ||
25 | in the ELF header, as required by certain architectures. | ||
26 | */ | ||
27 | |||
28 | .section .init.ramfs,"a" | ||
29 | .incbin "usr/initramfs_data.cpio.lzma" | ||