]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
mount: verify writing to streams was successful
authorSami Kerola <kerolasa@iki.fi>
Wed, 4 Apr 2012 17:54:15 +0000 (19:54 +0200)
committerSami Kerola <kerolasa@iki.fi>
Wed, 4 Apr 2012 17:54:15 +0000 (19:54 +0200)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
mount/mount.c
mount/mount_mntent.c
mount/umount.c

index 396f357d91e61ba38489c044bd5abae1c4a9f19d..19fe42e7f2a719a81e5e5b32a08c2d1c9e17311c 100644 (file)
@@ -41,6 +41,7 @@
 #include "nls.h"
 #include "blkdev.h"
 #include "strutils.h"
+#include "closestream.h"
 
 #define DO_PS_FIDDLING
 
@@ -2519,6 +2520,7 @@ main(int argc, char *argv[]) {
        setlocale(LC_ALL, "");
        bindtextdomain(PACKAGE, LOCALEDIR);
        textdomain(PACKAGE);
+       atexit(close_stdout);
 
        progname = argv[0];
        if ((p = strrchr(progname, '/')) != NULL)
index f42c0adff220a6e7516cbe22dbc815668ce01ae7..88dab1025ce3b407ca6bdbd680364e777ea3f954 100644 (file)
@@ -14,6 +14,7 @@
 #include "sundries.h"          /* for xmalloc */
 #include "nls.h"
 #include "mangle.h"
+#include "closestream.h"
 
 static int
 is_space_or_tab (char c) {
@@ -50,10 +51,11 @@ my_setmntent (const char *file, char *mode) {
 }
 
 void
-my_endmntent (mntFILE *mfp) {
+my_endmntent(mntFILE * mfp) {
        if (mfp) {
                if (mfp->mntent_fp)
-                       fclose(mfp->mntent_fp);
+                       if (close_stream(mfp->mntent_fp))
+                               fprintf(stderr, _("write error"));
                free(mfp->mntent_file);
                free(mfp);
        }
index 71cc0ee58c1887ed491c0f4a996b282badcf684e..d3375df83fda7b0d374577bbbdb442090fb3ba9c 100644 (file)
@@ -21,6 +21,7 @@
 #include "env.h"
 #include "nls.h"
 #include "strutils.h"
+#include "closestream.h"
 
 #if defined(MNT_FORCE)
 /* Interesting ... it seems libc knows about MNT_FORCE and presumably
@@ -778,6 +779,7 @@ main (int argc, char *argv[]) {
        setlocale(LC_ALL, "");
        bindtextdomain(PACKAGE, LOCALEDIR);
        textdomain(PACKAGE);
+       atexit(close_stdout);
 
        progname = argv[0];
        if ((p = strrchr(progname, '/')) != NULL)