diff options
author | Karel Zak | 2016-11-30 10:53:56 +0100 |
---|---|---|
committer | Karel Zak | 2016-11-30 10:57:39 +0100 |
commit | c49b765a6e9031642e2bb846e93dddc6827e4b28 (patch) | |
tree | a07d93c678b3b525235c751e94c0e422e7af9073 /disk-utils/sfdisk.c | |
parent | tests: update lsmem tests (diff) | |
download | kernel-qcow2-util-linux-c49b765a6e9031642e2bb846e93dddc6827e4b28.tar.gz kernel-qcow2-util-linux-c49b765a6e9031642e2bb846e93dddc6827e4b28.tar.xz kernel-qcow2-util-linux-c49b765a6e9031642e2bb846e93dddc6827e4b28.zip |
sfdisk: cleanup --dump error messages
old:
# truncate -s 1G empty && ./sfdisk --dump empty
sfdisk: failed to dump partition table: Success
new:
# truncate -s 1G empty && ./sfdisk --dump empty
sfdisk: empty: does not contain a recognized partition table.
Addresses: https://github.com/karelzak/util-linux/issues/375
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'disk-utils/sfdisk.c')
-rw-r--r-- | disk-utils/sfdisk.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c index 0f69d6575..10307ad14 100644 --- a/disk-utils/sfdisk.c +++ b/disk-utils/sfdisk.c @@ -950,13 +950,16 @@ static int command_dump(struct sfdisk *sf, int argc, char **argv) if (rc) err(EXIT_FAILURE, _("cannot open %s"), devname); + if (!fdisk_has_label(sf->cxt)) + errx(EXIT_FAILURE, _("%s: does not contain a recognized partition table"), devname); + dp = fdisk_new_script(sf->cxt); if (!dp) err(EXIT_FAILURE, _("failed to allocate dump struct")); rc = fdisk_script_read_context(dp, NULL); if (rc) - err(EXIT_FAILURE, _("failed to dump partition table")); + errx(EXIT_FAILURE, _("%s: failed to dump partition table"), devname); if (sf->json) fdisk_script_enable_json(dp, 1); |