]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: (gpt) allow to specify attr bit by API
authorKarel Zak <kzak@redhat.com>
Thu, 14 Aug 2014 09:33:46 +0000 (11:33 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 14 Aug 2014 09:33:46 +0000 (11:33 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libfdisk/src/gpt.c
libfdisk/src/libfdisk.h

index c1aa1e774b2ab38124eb9663902b9bbb6f31cef7..2df5d8e47982a425fcf73e674401adf39b4733f4 100644 (file)
@@ -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);
index 3d9d58efd473e3807533ec90a5d7c9e7073039ef..8febbdf55e91e6a1acaaca945367bd96f926037d 100644 (file)
@@ -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
 };