]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
resizepart: check writing to a file descriptor was successful
authorSami Kerola <kerolasa@iki.fi>
Sat, 13 Apr 2013 19:54:47 +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>
disk-utils/resizepart.c

index 5517c4ff2a51768fbff6dd329032147317a1cbee..765e3a40679570ff91ea1f7efc86a1d83babc400 100644 (file)
@@ -11,6 +11,7 @@
 #include "partx.h"
 #include "sysfs.h"
 #include "strutils.h"
+#include "closestream.h"
 
 static void __attribute__ ((__noreturn__)) usage(FILE * out)
 {
@@ -73,6 +74,7 @@ int main(int argc, char **argv)
        setlocale(LC_ALL, "");
        bindtextdomain(PACKAGE, LOCALEDIR);
        textdomain(PACKAGE);
+       atexit(close_stdout);
 
        while ((c = getopt_long(argc, argv, "Vh", longopts, NULL)) != -1)
                switch (c) {
@@ -102,5 +104,8 @@ int main(int argc, char **argv)
                        strtou64_or_err(argv[3], _("invalid length argument"))))
                err(EXIT_FAILURE, _("failed to resize partition"));
 
+       if (close_fd(fd) != 0)
+               err(EXIT_FAILURE, _("write failed"));
+
        return 0;
 }