]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
sfdisk: cleanup --dump error messages
authorKarel Zak <kzak@redhat.com>
Wed, 30 Nov 2016 09:53:56 +0000 (10:53 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 30 Nov 2016 09:57:39 +0000 (10:57 +0100)
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>
disk-utils/sfdisk.c

index 0f69d65756ce0ae8c8b11357f1c9f1317a933be6..10307ad14f200b94ca78b1c9e66b49d2ecb9c164 100644 (file)
@@ -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);