Skip to content

Commit

Permalink
initramfs: debug detected compression method
Browse files Browse the repository at this point in the history
This can greatly aid in narrowing down the real source of initramfs
problems such as failures related to the compression of the in-kernel
initramfs when an external initramfs is in use as well.  Existing errors
are ambiguous as to which initramfs is a problem and why.

[[email protected]: use pr_debug()]
Signed-off-by: Daniel M. Weeks <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
doctaweeks authored and torvalds committed Apr 7, 2014
1 parent 16caed3 commit 6aa7a29
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions init/initramfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ static char * __init unpack_to_rootfs(char *buf, unsigned len)
}
this_header = 0;
decompress = decompress_method(buf, len, &compress_name);
pr_debug("Detected %s compressed data\n", compress_name);
if (decompress) {
res = decompress(buf, len, NULL, flush_buffer, NULL,
&my_inptr, error);
Expand Down
3 changes: 3 additions & 0 deletions lib/decompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <linux/types.h>
#include <linux/string.h>
#include <linux/init.h>
#include <linux/printk.h>

#ifndef CONFIG_DECOMPRESS_GZIP
# define gunzip NULL
Expand Down Expand Up @@ -61,6 +62,8 @@ decompress_fn __init decompress_method(const unsigned char *inbuf, int len,
if (len < 2)
return NULL; /* Need at least this much... */

pr_debug("Compressed data magic: %#.2x %#.2x\n", inbuf[0], inbuf[1]);

for (cf = compressed_formats; cf->name; cf++) {
if (!memcmp(inbuf, cf->magic, 2))
break;
Expand Down

0 comments on commit 6aa7a29

Please sign in to comment.