summaryrefslogtreecommitdiffstats
path: root/disk-utils
diff options
context:
space:
mode:
authorKarel Zak2017-11-02 13:19:22 +0100
committerKarel Zak2017-11-02 13:19:22 +0100
commit5d5ca9deafe2dc356f459c5104bae62c87f56e66 (patch)
tree68c20e70bcbccdecf18fdbe166265cdd3ea8bccc /disk-utils
parentfdisk: (gpt) make PMBR accessible from main menu (diff)
downloadkernel-qcow2-util-linux-5d5ca9deafe2dc356f459c5104bae62c87f56e66.tar.gz
kernel-qcow2-util-linux-5d5ca9deafe2dc356f459c5104bae62c87f56e66.tar.xz
kernel-qcow2-util-linux-5d5ca9deafe2dc356f459c5104bae62c87f56e66.zip
sfdisk: allow to use --activate for PMBR
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'disk-utils')
-rw-r--r--disk-utils/sfdisk.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c
index 0cca4ebe0..46b7e54db 100644
--- a/disk-utils/sfdisk.c
+++ b/disk-utils/sfdisk.c
@@ -816,8 +816,13 @@ static int command_activate(struct sfdisk *sf, int argc, char **argv)
if (rc)
err(EXIT_FAILURE, _("cannot open %s"), devname);
- if (!fdisk_is_label(sf->cxt, DOS))
- errx(EXIT_FAILURE, _("toggle boot flags is supported for MBR only"));
+ if (fdisk_is_label(sf->cxt, GPT)) {
+ /* Switch from GPT to PMBR */
+ sf->cxt = fdisk_new_nested_context(sf->cxt, "dos");
+ if (!sf->cxt)
+ err(EXIT_FAILURE, _("cannot switch to PMBR"));
+ } else if (!fdisk_is_label(sf->cxt, DOS))
+ errx(EXIT_FAILURE, _("toggle boot flags is supported for MBR or PMBR only"));
if (!listonly && sf->backup)
backup_partition_table(sf, devname);
@@ -858,6 +863,7 @@ static int command_activate(struct sfdisk *sf, int argc, char **argv)
}
fdisk_unref_partition(pa);
+
if (listonly)
rc = fdisk_deassign_device(sf->cxt, 1);
else
@@ -1826,7 +1832,7 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_("Display or manipulate a disk partition table.\n"), out);
fputs(USAGE_COMMANDS, out);
- fputs(_(" -A, --activate <dev> [<part> ...] list or set bootable MBR partitions\n"), out);
+ fputs(_(" -A, --activate <dev> [<part> ...] list or set bootable (P)MBR partitions\n"), out);
fputs(_(" -d, --dump <dev> dump partition table (usable for later input)\n"), out);
fputs(_(" -J, --json <dev> dump partition table in JSON format\n"), out);
fputs(_(" -g, --show-geometry [<dev> ...] list geometry of all or specified devices\n"), out);