summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-12-13 12:20:15 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2020-02-14 12:16:20 +0100
commit9552f5150bb2654a0e52aad8c12973896f24f2ee (patch)
tree89c63fa93bec8e7bfe0ccb740e17df9202926a9f
parente488952b9d04fb0fc7dddd31ec639549d71c76b3 (diff)
downloadbarebox-9552f5150bb2654a0e52aad8c12973896f24f2ee.tar.gz
copy_file: call discard_range on destination file
discard the range in the output file we are going to overwrite anyway. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--lib/libfile.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/libfile.c b/lib/libfile.c
index 5a1817e..dbeed12 100644
--- a/lib/libfile.c
+++ b/lib/libfile.c
@@ -367,6 +367,8 @@ int copy_file(const char *src, const char *dst, int verbose)
goto out;
}
+ discard_range(dstfd, srcstat.st_size, 0);
+
if (verbose) {
if (stat(src, &srcstat) < 0)
srcstat.st_size = 0;