The copyfile() implementation has strange behaviour if the destination
file already exists. Update it to ensure that any existing data in the
destination file is dropped.
Signed-off-by: Simon Glass <sjg@chromium.org>
goto out;
}
- fd_dst = open(dst, O_WRONLY | O_CREAT, 0666);
+ fd_dst = open(dst, O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (fd_dst < 0) {
printf("Can't open file %s (%s)\n", dst, strerror(errno));
goto out;
*
* This uses read()/write() to copy file @src to file @dst
*
+ * If @dst exists, it is overwritten and truncated to the correct size.
+ *
* @src: Filename to read from
* @dst: Filename to write to
* @return 0 if OK, -1 on error