setup: flush file to disk, before updating its timestamps
authorLennart Poettering <lennart@poettering.net>
Tue, 12 Feb 2013 18:04:47 +0000 (19:04 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 12 Feb 2013 18:11:41 +0000 (19:11 +0100)
setup.c

diff --git a/setup.c b/setup.c
index 3808653..fd01d33 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -564,6 +564,13 @@ static int copy_file(const char *from, const char *to) {
                 }
         } while (!feof(f));
 
+        fflush(g);
+        if (ferror(g)) {
+                fprintf(stderr, "Failed to write %s: %m\n", to);
+                r = -errno;
+                goto finish;
+        }
+
         r = fstat(fileno(f), &st);
         if (r < 0) {
                 fprintf(stderr, "Failed to get file timestamps of %s: %m", from);