[PATCH 15/33] libmount: check writing to a file was successful

Sami Kerola
2013-04-13T19:55:51Z

libmount/src/lock.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libmount/src/lock.c b/libmount/src/lock.c
index e73edf5..f381e42 100644
--- a/libmount/src/lock.c
+++ b/libmount/src/lock.c
@@ -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(),
--
1.8.2.1