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

index 8853009c9fb35a8be7abb1c94734f9b412a249a7..8ef927756f060a39cf100ccd554fcc01555645ac 100644 (file)
@@ -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"));
index 86eda6cbcf57b18998d39730a029ba0edc64c6ee..424017a32e932559df7e3176a688ff55c541f9b4 100644 (file)
@@ -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);