From b52bb3712a64c404846f30300b339cfd01e316be Mon Sep 17 00:00:00 2001 From: Nikanth Karthikesan Date: Mon, 13 Apr 2009 14:39:38 -0700 Subject: init/initramfs: fix warning with CONFIG_BLK_DEV_RAM=n init/initramfs.c:520: warning: 'clean_rootfs' defined but not used Signed-off-by: Nikanth Karthikesan Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- init/initramfs.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'init/initramfs.c') diff --git a/init/initramfs.c b/init/initramfs.c index 80cd713f6cc..e44f2d932cc 100644 --- a/init/initramfs.c +++ b/init/initramfs.c @@ -515,6 +515,7 @@ skip: initrd_end = 0; } +#ifdef CONFIG_BLK_DEV_RAM #define BUF_SIZE 1024 static void __init clean_rootfs(void) { @@ -561,6 +562,7 @@ static void __init clean_rootfs(void) sys_close(fd); kfree(buf); } +#endif static int __init populate_rootfs(void) { -- cgit v1.2.3 From d20d5a7456d57d8affa88f45f27ae96ea49c29e4 Mon Sep 17 00:00:00 2001 From: Randy Robertson Date: Mon, 13 Apr 2009 14:40:04 -0700 Subject: initramfs: fix initramfs to work with hardlinked init Change cb6ff208076b5f434db1b8c983429269d719cef5 ("NOMMU: Support XIP on initramfs") seems to have broken booting from initramfs with /sbin/init being a hardlink. It seems like the logic required for XIP on nommu, i.e. ftruncate to reported cpio header file size (body_len) is broken for hardlinks, which have a reported size of 0, and the truncate thus nukes the contents of the file (in my case busybox), making boot impossible and ending with runaway loop modprobe binfmt-0000 - and of course 0000 is not a valid binary format. My fix is to only call ftruncate if size is non-zero which fixes things for me, but I'm not certain whether this will break XIP for those files on nommu systems, although I would guess not. Signed-off-by: Randy Robertson Acked-by: David Howells Acked-by: Paul Mundt Acked-by: H. Peter Anvin Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- init/initramfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'init/initramfs.c') diff --git a/init/initramfs.c b/init/initramfs.c index e44f2d932cc..9ee7b781041 100644 --- a/init/initramfs.c +++ b/init/initramfs.c @@ -310,7 +310,8 @@ static int __init do_name(void) if (wfd >= 0) { sys_fchown(wfd, uid, gid); sys_fchmod(wfd, mode); - sys_ftruncate(wfd, body_len); + if (body_len) + sys_ftruncate(wfd, body_len); vcollected = kstrdup(collected, GFP_KERNEL); state = CopyFile; } -- cgit v1.2.3 From a1e6b6c1a676d25acdf079ee8ab5cdfeb5e5b835 Mon Sep 17 00:00:00 2001 From: Eric Piel Date: Wed, 6 May 2009 16:03:06 -0700 Subject: initramfs: clean up messages related to initramfs unpacking With the removal of duplicate unpack_to_rootfs() (commit df52092f3c97788592ef72501a43fb7ac6a3cfe0) the messages displayed do not actually correspond to what the kernel is doing. In addition, depending if ramdisks are supported or not, the messages are not at all the same. So keep the messages more in sync with what is really doing the kernel, and only display a second message in case of failure. This also ensure that the printk message cannot be split by other printk's. Signed-off-by: Eric Piel Acked-by: H. Peter Anvin Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- init/initramfs.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'init/initramfs.c') diff --git a/init/initramfs.c b/init/initramfs.c index 9ee7b781041..4c00edc5968 100644 --- a/init/initramfs.c +++ b/init/initramfs.c @@ -574,11 +574,10 @@ static int __init populate_rootfs(void) if (initrd_start) { #ifdef CONFIG_BLK_DEV_RAM int fd; - printk(KERN_INFO "checking if image is initramfs...\n"); + printk(KERN_INFO "Trying to unpack rootfs image as initramfs...\n"); err = unpack_to_rootfs((char *)initrd_start, initrd_end - initrd_start); if (!err) { - printk(KERN_INFO "rootfs image is initramfs; unpacking...\n"); free_initrd(); return 0; } else { @@ -596,15 +595,11 @@ static int __init populate_rootfs(void) free_initrd(); } #else - printk(KERN_INFO "Unpacking initramfs..."); + printk(KERN_INFO "Unpacking initramfs...\n"); err = unpack_to_rootfs((char *)initrd_start, initrd_end - initrd_start); - if (err) { - printk(" failed!\n"); - printk(KERN_EMERG "%s\n", err); - } else { - printk(" done\n"); - } + if (err) + printk(KERN_EMERG "Initramfs unpacking failed: %s\n", err); free_initrd(); #endif } -- cgit v1.2.3