From 4833d9f4986d6dafacff841beb3bf93172c84bdc Mon Sep 17 00:00:00 2001 From: Tom Zhu Date: Mon, 28 Sep 2009 19:53:12 -0500 Subject: 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 Signed-off-by: San Mehat --- init/builtins.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init/builtins.c b/init/builtins.c index cc7c9d16..5a1b2637 100644 --- a/init/builtins.c +++ b/init/builtins.c @@ -445,7 +445,7 @@ int do_copy(int nargs, char **args) 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))) -- cgit v1.2.3