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

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

 



Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux