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

index 136ff9d2f66b19960bbab7bf6b8878453d01cf7c..a68f855a4ec95abb9b75f125881ee9d8769140e5 100644 (file)
@@ -1849,7 +1849,11 @@ print_raw_table(void) {
 
     if (to_file) {
        if (!print_only)
-           fclose(fp);
+           if (close_stream(fp) != 0) {
+               char errstr[LINE_LENGTH];
+               snprintf(errstr, sizeof(errstr), _("write failed: %s"), fname);
+               print_warning(errstr);
+           }
     } else {
         menuContinue();
     }
@@ -1966,7 +1970,11 @@ print_p_info(void) {
 
     if (to_file) {
        if (!print_only)
-           fclose(fp);
+           if (close_stream(fp) != 0) {
+               char errstr[LINE_LENGTH];
+               snprintf(errstr, sizeof(errstr), _("write failed: %s"), fname);
+               print_warning(errstr);
+           }
     } else {
         menuContinue();
     }
@@ -2060,7 +2068,11 @@ print_part_table(void) {
 
     if (to_file) {
        if (!print_only)
-           fclose(fp);
+           if (close_stream(fp) != 0) {
+               char errstr[LINE_LENGTH];
+               snprintf(errstr, sizeof(errstr), _("write failed: %s"), fname);
+               print_warning(errstr);
+           }
     } else {
         menuContinue();
     }