]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
sfdisk: Add support for altering GPT size
authorSassan Panahinejad <sassan@sassan.me.uk>
Thu, 12 May 2016 11:54:43 +0000 (12:54 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 18 May 2016 11:56:25 +0000 (13:56 +0200)
Adds a header option to alter the GPT table length

libfdisk/src/script.c

index 096f37cf8f1240df7a688ee5f81dced9f4ee5e0f..fd05bf703d3ed2b39232aaa767b84fa40bcf348c 100644 (file)
@@ -705,7 +705,8 @@ static int parse_line_header(struct fdisk_script *dp, char *s)
        } else if (strcmp(name, "label-id") == 0
                   || strcmp(name, "device") == 0
                   || strcmp(name, "first-lba") == 0
-                  || strcmp(name, "last-lba") == 0) {
+                  || strcmp(name, "last-lba") == 0
+                  || strcmp(name, "table-length") == 0) {
                ;                                       /* whatever is posssible */
        } else
                goto done;                              /* unknown header */
@@ -1326,6 +1327,8 @@ struct fdisk_script *fdisk_get_script(struct fdisk_context *cxt)
 int fdisk_apply_script_headers(struct fdisk_context *cxt, struct fdisk_script *dp)
 {
        const char *name;
+       const char *str;
+       int rc;
 
        assert(cxt);
        assert(dp);
@@ -1338,7 +1341,15 @@ int fdisk_apply_script_headers(struct fdisk_context *cxt, struct fdisk_script *d
        if (!name)
                return -EINVAL;
 
-       return fdisk_create_disklabel(cxt, name);
+       rc = fdisk_create_disklabel(cxt, name);
+       if (rc)
+               return rc;
+
+       str = fdisk_script_get_header(dp, "table-length");
+       if (str)
+               return fdisk_gpt_set_npartitions(cxt, strtoul(str, NULL, 0));
+
+       return 0;
 }
 
 /**