From: Sami Kerola Date: Wed, 4 Apr 2012 17:54:15 +0000 (+0200) Subject: mount: verify writing to streams was successful X-Git-Tag: v2.22-rc1~539^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f65c6d4e8272cacd5cc7b4950b71869623c79da6;p=thirdparty%2Futil-linux.git mount: verify writing to streams was successful Signed-off-by: Sami Kerola --- 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)