init: builtins: trancate target file in do_copy
add O_TRUNC flag in open(), which will truncate the target file,
otherwise, copy will keep the old content of the target file.
Signed-off-by: Tom Zhu <ling.zhu@motorola.com>
Signed-off-by: San Mehat <san@google.com>
diff --git a/init/builtins.c b/init/builtins.c
index cc7c9d1..5a1b263 100644
--- a/init/builtins.c
+++ b/init/builtins.c
@@ -445,7 +445,7 @@
if ((fd1 = open(args[1], O_RDONLY)) < 0)
goto out_err;
- if ((fd2 = open(args[2], O_WRONLY|O_CREAT, 0660)) < 0)
+ if ((fd2 = open(args[2], O_WRONLY|O_CREAT|O_TRUNC, 0660)) < 0)
goto out_err;
if (!(buffer = malloc(info.st_size)))