From: Karel Zak Date: Thu, 14 Aug 2014 09:33:46 +0000 (+0200) Subject: libfdisk: (gpt) allow to specify attr bit by API X-Git-Tag: v2.26-rc1~514 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=773aae5c51e9573be5c66e14b4a33e4dde5f5f95;p=thirdparty%2Futil-linux.git libfdisk: (gpt) allow to specify attr bit by API Signed-off-by: Karel Zak --- diff --git a/libfdisk/src/gpt.c b/libfdisk/src/gpt.c index c1aa1e774b..2df5d8e479 100644 --- a/libfdisk/src/gpt.c +++ b/libfdisk/src/gpt.c @@ -2248,10 +2248,19 @@ static int gpt_toggle_partition_flag( return rc; bit = tmp; break; + default: + /* already specified PT_FLAG_GUIDSPECIFIC bit */ + if (flag >= 48 && flag <= 63) { + bit = flag; + flag = GPT_FLAG_GUIDSPECIFIC; + } + break; } - if (bit < 0) + if (bit < 0) { + fdisk_warnx(cxt, _("failed to toggle unsupported bit %lu"), flag); return -EINVAL; + } if (!isset(bits, bit)) setbit(bits, bit); diff --git a/libfdisk/src/libfdisk.h b/libfdisk/src/libfdisk.h index 3d9d58efd4..8febbdf55e 100644 --- a/libfdisk/src/libfdisk.h +++ b/libfdisk/src/libfdisk.h @@ -339,10 +339,32 @@ extern int fdisk_sgi_set_bootfile(struct fdisk_context *cxt); extern int fdisk_sgi_create_info(struct fdisk_context *cxt); /* gpt */ + +/* GPT partition attributes */ enum { + /* System partition (disk partitioning utilities must preserve the + * partition as is) */ GPT_FLAG_REQUIRED = 1, + + /* EFI firmware should ignore the content of the partition and not try + * to read from it */ GPT_FLAG_NOBLOCK, + + /* Legacy BIOS bootable */ GPT_FLAG_LEGACYBOOT, + + /* bites 48-63, Defined and used by the individual partition type. + * + * The flag GPT_FLAG_GUIDSPECIFIC forces libfdisk to ask (by ask API) + * for a bit number. If you want to toggle specific bit and avoid any + * dialog, then use the bit number (in range 48..63). For example: + * + * // start dialog to ask for bit number + * fdisk_partition_toggle_flag(cxt, n, GPT_FLAG_GUIDSPECIFIC); + * + * // toggle bit 60 + * fdisk_partition_toggle_flag(cxt, n, 60); + */ GPT_FLAG_GUIDSPECIFIC };