You can chain CPIOs together for the initramfs, but if two CPIOs write
to the same file, we don't clear the first before writing the second.
If the first is larger than the second, we end up with a mash of the
two. Trivial patch below to fix this.
Signed-off-by: Michael Neuling <[email protected]>
---
init/initramfs.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletion(-)
Index: linux-2.6-linus/init/initramfs.c
===================================================================
--- linux-2.6-linus.orig/init/initramfs.c
+++ linux-2.6-linus/init/initramfs.c
@@ -250,7 +250,8 @@ static int __init do_name(void)
return 0;
if (S_ISREG(mode)) {
if (maybe_link() >= 0) {
- wfd = sys_open(collected, O_WRONLY|O_CREAT, mode);
+ wfd = sys_open(collected, O_WRONLY|O_CREAT|O_TRUNC,
+ mode);
if (wfd >= 0) {
sys_fchown(wfd, uid, gid);
sys_fchmod(wfd, mode);