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>
This commit is contained in:
Tom Zhu 2009-09-28 19:53:12 -05:00 committed by San Mehat
parent 04ea5b974d
commit 4833d9f498
1 changed files with 1 additions and 1 deletions

View File

@ -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)))