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:
parent
04ea5b974d
commit
4833d9f498
|
@ -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)))
|
||||
|
|
Loading…
Reference in New Issue