summaryrefslogtreecommitdiffstats
path: root/disk-utils/sfdisk.c
diff options
context:
space:
mode:
authorKarel Zak2014-10-10 12:52:24 +0200
committerKarel Zak2014-10-10 12:52:24 +0200
commit90dc69e40a6777185f0d7185f697e33ba7afe647 (patch)
tree630eb5b46b88eb1beb9c1eaa1460b290961ba8f3 /disk-utils/sfdisk.c
parentlibfdisk: make script header parser more pedantic (diff)
downloadkernel-qcow2-util-linux-90dc69e40a6777185f0d7185f697e33ba7afe647.tar.gz
kernel-qcow2-util-linux-90dc69e40a6777185f0d7185f697e33ba7afe647.tar.xz
kernel-qcow2-util-linux-90dc69e40a6777185f0d7185f697e33ba7afe647.zip
sfdisk: leave on error
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'disk-utils/sfdisk.c')
-rw-r--r--disk-utils/sfdisk.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c
index 83b9cf57f..1be40caad 100644
--- a/disk-utils/sfdisk.c
+++ b/disk-utils/sfdisk.c
@@ -1238,6 +1238,10 @@ static int command_fdisk(struct sfdisk *sf, int argc, char **argv)
if (!created) { /* create a new disklabel */
rc = fdisk_apply_script_headers(sf->cxt, dp);
created = !rc;
+ if (rc)
+ fdisk_warnx(sf->cxt, _(
+ "Failed to apply script headers, "
+ "disk label not created."));
}
if (!rc && partno >= 0) { /* -N <partno>, modify partition */
rc = fdisk_set_partition(sf->cxt, partno, pa);
@@ -1248,7 +1252,7 @@ static int command_fdisk(struct sfdisk *sf, int argc, char **argv)
rc = fdisk_add_partition(sf->cxt, pa, &cur_partno);
if (rc) {
errno = -rc;
- fdisk_warn(sf->cxt, _("failed to add partition"));
+ fdisk_warn(sf->cxt, _("Failed to add partition"));
}
}
@@ -1256,16 +1260,15 @@ static int command_fdisk(struct sfdisk *sf, int argc, char **argv)
if (sf->interactive)
sfdisk_print_partition(sf, cur_partno);
next_partno = cur_partno + 1;
- } else if (pa) { /* error, drop partition from script */
+ } else if (pa) /* error, drop partition from script */
fdisk_table_remove_partition(tb, pa);
- if (rc == -ENOSPC) {
- rc = SFDISK_DONE_ASK;
- break;
- }
- }
} else
fdisk_info(sf->cxt, _("Script header accepted."));
+ if (rc && !sf->interactive) {
+ rc = SFDISK_DONE_ABORT;
+ break;
+ }
} while (1);
if (!sf->quiet && rc != SFDISK_DONE_ABORT) {