aboutsummaryrefslogtreecommitdiffstats
path: root/usr
diff options
context:
space:
mode:
Diffstat (limited to 'usr')
-rw-r--r--usr/Kconfig32
-rw-r--r--usr/Makefile5
-rw-r--r--usr/gen_init_cpio.c20
3 files changed, 43 insertions, 14 deletions
diff --git a/usr/Kconfig b/usr/Kconfig
index c2c7fe2f717d..65b845bd4e3e 100644
--- a/usr/Kconfig
+++ b/usr/Kconfig
@@ -46,7 +46,7 @@ config INITRAMFS_ROOT_GID
46 If you are not sure, leave it set to "0". 46 If you are not sure, leave it set to "0".
47 47
48config RD_GZIP 48config RD_GZIP
49 bool "Support initial ramdisks compressed using gzip" if EMBEDDED 49 bool "Support initial ramdisks compressed using gzip" if EXPERT
50 default y 50 default y
51 depends on BLK_DEV_INITRD 51 depends on BLK_DEV_INITRD
52 select DECOMPRESS_GZIP 52 select DECOMPRESS_GZIP
@@ -55,8 +55,8 @@ config RD_GZIP
55 If unsure, say Y. 55 If unsure, say Y.
56 56
57config RD_BZIP2 57config RD_BZIP2
58 bool "Support initial ramdisks compressed using bzip2" if EMBEDDED 58 bool "Support initial ramdisks compressed using bzip2" if EXPERT
59 default !EMBEDDED 59 default !EXPERT
60 depends on BLK_DEV_INITRD 60 depends on BLK_DEV_INITRD
61 select DECOMPRESS_BZIP2 61 select DECOMPRESS_BZIP2
62 help 62 help
@@ -64,17 +64,26 @@ config RD_BZIP2
64 If unsure, say N. 64 If unsure, say N.
65 65
66config RD_LZMA 66config RD_LZMA
67 bool "Support initial ramdisks compressed using LZMA" if EMBEDDED 67 bool "Support initial ramdisks compressed using LZMA" if EXPERT
68 default !EMBEDDED 68 default !EXPERT
69 depends on BLK_DEV_INITRD 69 depends on BLK_DEV_INITRD
70 select DECOMPRESS_LZMA 70 select DECOMPRESS_LZMA
71 help 71 help
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
75config RD_XZ
76 bool "Support initial ramdisks compressed using XZ" if EXPERT
77 default !EXPERT
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
75config RD_LZO 84config RD_LZO
76 bool "Support initial ramdisks compressed using LZO" if EMBEDDED 85 bool "Support initial ramdisks compressed using LZO" if EXPERT
77 default !EMBEDDED 86 default !EXPERT
78 depends on BLK_DEV_INITRD 87 depends on BLK_DEV_INITRD
79 select DECOMPRESS_LZO 88 select DECOMPRESS_LZO
80 help 89 help
@@ -139,6 +148,15 @@ 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
151config 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
142config INITRAMFS_COMPRESSION_LZO 160config INITRAMFS_COMPRESSION_LZO
143 bool "LZO" 161 bool "LZO"
144 depends on RD_LZO 162 depends on RD_LZO
diff --git a/usr/Makefile b/usr/Makefile
index 6faa444b7087..029ffe6cd0d8 100644
--- a/usr/Makefile
+++ b/usr/Makefile
@@ -15,6 +15,9 @@ suffix_$(CONFIG_INITRAMFS_COMPRESSION_BZIP2) = .bz2
15# Lzma 15# Lzma
16suffix_$(CONFIG_INITRAMFS_COMPRESSION_LZMA) = .lzma 16suffix_$(CONFIG_INITRAMFS_COMPRESSION_LZMA) = .lzma
17 17
18# XZ
19suffix_$(CONFIG_INITRAMFS_COMPRESSION_XZ) = .xz
20
18# Lzo 21# Lzo
19suffix_$(CONFIG_INITRAMFS_COMPRESSION_LZO) = .lzo 22suffix_$(CONFIG_INITRAMFS_COMPRESSION_LZO) = .lzo
20 23
@@ -50,7 +53,7 @@ endif
50quiet_cmd_initfs = GEN $@ 53quiet_cmd_initfs = GEN $@
51 cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input) 54 cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input)
52 55
53targets := initramfs_data.cpio.gz initramfs_data.cpio.bz2 initramfs_data.cpio.lzma initramfs_data.cpio.lzo initramfs_data.cpio 56targets := initramfs_data.cpio.gz initramfs_data.cpio.bz2 initramfs_data.cpio.lzma initramfs_data.cpio.xz initramfs_data.cpio.lzo initramfs_data.cpio
54# do not try to update files included in initramfs 57# do not try to update files included in initramfs
55$(deps_initramfs): ; 58$(deps_initramfs): ;
56 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",