]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: (test) check writing to a file was successful
authorSami Kerola <kerolasa@iki.fi>
Sat, 13 Apr 2013 19:54:43 +0000 (20:54 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 26 Apr 2013 11:40:27 +0000 (13:40 +0200)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
libmount/src/lock.c

index e73edf54b471163265f77229af9793d38e2d6410..f381e423e400e7753fd8445296061814164f237d 100644 (file)
@@ -21,6 +21,7 @@
 #include <limits.h>
 #include <sys/file.h>
 
+#include "closestream.h"
 #include "pathnames.h"
 #include "mountP.h"
 
@@ -573,7 +574,9 @@ void increment_data(const char *filename, int verbose, int loopno)
                err(EXIT_FAILURE, "%d: failed to open: %s", getpid(), filename);
 
        fprintf(f, "%ld", num);
-       fclose(f);
+
+       if (close_stream(f) != 0)
+               err(EXIT_FAILURE, "write failed: %s", filename);
 
        if (verbose)
                fprintf(stderr, "%d: %s: %ld --> %ld (loop=%d)\n", getpid(),