[PATCH] Chained CPIOs writing to the same file bug

From: Michael Neuling
Date: Thu Feb 16 2006 - 02:35:56 EST


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 <mikey@xxxxxxxxxxx>
---
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);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/