summaryrefslogtreecommitdiffstats
path: root/init/initramfs.c
diff options
context:
space:
mode:
authorRandy Robertson <rmrobert@vmware.com>2009-04-13 14:40:04 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2009-04-13 15:04:31 -0700
commitd20d5a7456d57d8affa88f45f27ae96ea49c29e4 (patch)
treebaa9169c23c16b55d46968b5b4964c6e950645e9 /init/initramfs.c
parentf1671f6d783a2385d32e11f456cbe32f0e4b4b49 (diff)
downloadblackbird-op-linux-d20d5a7456d57d8affa88f45f27ae96ea49c29e4.tar.gz
blackbird-op-linux-d20d5a7456d57d8affa88f45f27ae96ea49c29e4.zip
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 <rmrobert@vmware.com> Acked-by: David Howells <dhowells@redhat.com> Acked-by: Paul Mundt <lethal@linux-sh.org> Acked-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'init/initramfs.c')
-rw-r--r--init/initramfs.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/init/initramfs.c b/init/initramfs.c
index e44f2d932cc4..9ee7b7810417 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;
}
OpenPOWER on IntegriCloud