9
0
Fork 0

copy_file: Add missing O_TRUNC

Without it, when copying a smaller file over a larger file the
resulting file still has the remaining space from the larger file.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2013-09-28 13:12:50 +02:00
parent e2b67d6a6a
commit d4f5bb1e01
1 changed files with 1 additions and 1 deletions

View File

@ -29,7 +29,7 @@ int copy_file(const char *src, const char *dst, int verbose)
goto out;
}
dstfd = open(dst, O_WRONLY | O_CREAT);
dstfd = open(dst, O_WRONLY | O_CREAT | O_TRUNC);
if (dstfd < 0) {
printf("could not open %s: %s\n", dst, errno_str());
goto out;