* [PATCH] initramfs: Fix initramfs to work with hardlinked init.
@ 2009-04-06 3:44 Randy Robertson
0 siblings, 0 replies; 3+ messages in thread
From: Randy Robertson @ 2009-04-06 3:44 UTC (permalink / raw)
To: linux-kernel; +Cc: David Howells
Change cb6ff208076b5f434db1b8c983429269d719cef5 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>
---
diff --git a/init/initramfs.c b/init/initramfs.c
index d9c941c..4675f62 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -317,7 +317,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;
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] initramfs: Fix initramfs to work with hardlinked init
@ 2009-04-06 19:22 Randy Robertson
2009-04-07 0:02 ` H. Peter Anvin
0 siblings, 1 reply; 3+ messages in thread
From: Randy Robertson @ 2009-04-06 19:22 UTC (permalink / raw)
To: linux-kernel; +Cc: David Howells
Change cb6ff208076b5f434db1b8c983429269d719cef5 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.
This update adds David's ack and fixes whitespace.
Signed-off-by: Randy Robertson <rmrobert@vmware.com>
Acked-by: David Howells <dhowells@redhat.com>
---
init/initramfs.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/init/initramfs.c b/init/initramfs.c
index 80cd713..ddf30d1 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;
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] initramfs: Fix initramfs to work with hardlinked init
2009-04-06 19:22 [PATCH] initramfs: Fix initramfs to work with hardlinked init Randy Robertson
@ 2009-04-07 0:02 ` H. Peter Anvin
0 siblings, 0 replies; 3+ messages in thread
From: H. Peter Anvin @ 2009-04-07 0:02 UTC (permalink / raw)
To: Randy Robertson; +Cc: linux-kernel, David Howells
Randy Robertson wrote:
> Change cb6ff208076b5f434db1b8c983429269d719cef5 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.
>
> This update adds David's ack and fixes whitespace.
>
> Signed-off-by: Randy Robertson <rmrobert@vmware.com>
> Acked-by: David Howells <dhowells@redhat.com>
Looks right to me.
Acked-by: H. Peter Anvin <hpa@zytor.com>
-hpa
--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-04-07 0:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-06 19:22 [PATCH] initramfs: Fix initramfs to work with hardlinked init Randy Robertson
2009-04-07 0:02 ` H. Peter Anvin
-- strict thread matches above, loose matches on Subject: below --
2009-04-06 3:44 Randy Robertson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox