diff options
author | Tom Zhu <ling.zhu@motorola.com> | 2009-09-28 19:53:12 -0500 |
---|---|---|
committer | San Mehat <san@google.com> | 2009-09-30 14:15:49 -0700 |
commit | 4833d9f4986d6dafacff841beb3bf93172c84bdc (patch) | |
tree | df5438a49fdd55c2b9075b8e671ecf42f2062698 | |
parent | 04ea5b974d12753d9ceae280fea0037cae1ba192 (diff) | |
download | core-4833d9f4986d6dafacff841beb3bf93172c84bdc.tar.gz |
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>
-rw-r--r-- | init/builtins.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/init/builtins.c b/init/builtins.c index cc7c9d169..5a1b26378 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))) |