From f65c6d4e8272cacd5cc7b4950b71869623c79da6 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Wed, 4 Apr 2012 19:54:15 +0200 Subject: [PATCH] mount: verify writing to streams was successful Signed-off-by: Sami Kerola --- mount/mount.c | 2 ++ mount/mount_mntent.c | 6 ++++-- mount/umount.c | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/mount/mount.c b/mount/mount.c index 396f357d91..19fe42e7f2 100644 --- a/mount/mount.c +++ b/mount/mount.c @@ -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) diff --git a/mount/mount_mntent.c b/mount/mount_mntent.c index f42c0adff2..88dab1025c 100644 --- a/mount/mount_mntent.c +++ b/mount/mount_mntent.c @@ -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); } diff --git a/mount/umount.c b/mount/umount.c index 71cc0ee58c..d3375df83f 100644 --- a/mount/umount.c +++ b/mount/umount.c @@ -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) -- 2.47.3