]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fdisk: Add support for altering GPT size
authorSassan Panahinejad <sassan@sassan.me.uk>
Fri, 13 May 2016 10:42:14 +0000 (11:42 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 18 May 2016 11:46:35 +0000 (13:46 +0200)
Adds an options (l) to the GPT menu to resize the GPT.

disk-utils/fdisk-menu.c

index b099cc3c29913c184d54f8fb123d60fb7f88eea9..ce3422c6982cb5ff504e091f43ba519840ce2961 100644 (file)
@@ -165,6 +165,7 @@ struct menu menu_gpt = {
                MENU_XENT('i', N_("change disk GUID")),
                MENU_XENT('n', N_("change partition name")),
                MENU_XENT('u', N_("change partition UUID")),
+               MENU_XENT('l', N_("change table length")),
                MENU_XENT('M', N_("enter protective/hybrid MBR")),
 
                MENU_XSEP(""),
@@ -691,6 +692,7 @@ static int gpt_menu_cb(struct fdisk_context **cxt0,
        struct fdisk_partition *pa = NULL;
        size_t n;
        int rc = 0;
+       unsigned long length;
 
        assert(cxt);
        assert(ent);
@@ -702,6 +704,12 @@ static int gpt_menu_cb(struct fdisk_context **cxt0,
                switch (ent->key) {
                case 'i':
                        return fdisk_set_disklabel_id(cxt);
+               case 'l':
+                       rc =  fdisk_ask_number(cxt, 1, fdisk_get_npartitions(cxt),
+                                       ~(uint32_t)0, _("New maximum entries"), &length);
+                       if (rc)
+                               return rc;
+                       return fdisk_gpt_set_npartitions(cxt, length);
                case 'M':
                        mbr = fdisk_new_nested_context(cxt, "dos");
                        if (!mbr)