summaryrefslogtreecommitdiff
path: root/libblkid
diff options
context:
space:
mode:
authorSami Kerola <kerolasa@iki.fi>2013-04-13 20:54:42 +0100
committerKarel Zak <kzak@redhat.com>2013-04-26 13:26:06 +0200
commit8d21d9ab8ff65decfd03499a29627b6c9ecb21f2 (patch)
tree97e7585e7e71f774665d8be51810c06a1fc1bc3f /libblkid
parent944ab4b9316597d4a5616ff2c8d3f90cb1f3e9ad (diff)
downloadutil-linux-8d21d9ab8ff65decfd03499a29627b6c9ecb21f2.tar.gz
libblkid: check writing to a file was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'libblkid')
-rw-r--r--libblkid/src/evaluate.c4
-rw-r--r--libblkid/src/save.c7
2 files changed, 9 insertions, 2 deletions
diff --git a/libblkid/src/evaluate.c b/libblkid/src/evaluate.c
index 8853009c..8ef92775 100644
--- a/libblkid/src/evaluate.c
+++ b/libblkid/src/evaluate.c
@@ -24,6 +24,7 @@
#include "pathnames.h"
#include "canonicalize.h"
+#include "closestream.h"
#include "blkidP.h"
@@ -123,7 +124,8 @@ int blkid_send_uevent(const char *devname, const char *action)
rc = 0;
if (fputs(action, f) >= 0)
rc = 0;
- fclose(f);
+ if (close_stream(f) != 0)
+ DBG(EVALUATE, blkid_debug("write failed: %s", uevent));
}
DBG(EVALUATE, blkid_debug("%s: send uevent %s",
uevent, rc == 0 ? "SUCCES" : "FAILED"));
diff --git a/libblkid/src/save.c b/libblkid/src/save.c
index 86eda6cb..424017a3 100644
--- a/libblkid/src/save.c
+++ b/libblkid/src/save.c
@@ -21,6 +21,9 @@
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
+
+#include "closestream.h"
+
#include "blkidP.h"
static int save_dev(blkid_dev dev, FILE *file)
@@ -148,7 +151,9 @@ int blkid_flush_cache(blkid_cache cache)
ret = 1;
}
- fclose(file);
+ if (close_stream(file) != 0)
+ DBG(SAVE, blkid_debug("write failed: %s", filename));
+
if (opened != filename) {
if (ret < 0) {
unlink(opened);