[PATCH 1/9] copy_file: Add missing O_TRUNC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 lib/copy_file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/copy_file.c b/lib/copy_file.c
index 55dee38..778cc00 100644
--- a/lib/copy_file.c
+++ b/lib/copy_file.c
@@ -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;
-- 
1.8.4.rc3


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux