diff options
author | Sassan Panahinejad | 2016-05-12 13:54:43 +0200 |
---|---|---|
committer | Karel Zak | 2016-05-18 13:56:25 +0200 |
commit | d96153f8c8735e21d0e150a00bd7899767cd507c (patch) | |
tree | fc0c917378a1de077866bdc35de67a61c26d6306 /libfdisk/src/script.c | |
parent | libfdisk: Add support for altering GPT size (diff) | |
download | kernel-qcow2-util-linux-d96153f8c8735e21d0e150a00bd7899767cd507c.tar.gz kernel-qcow2-util-linux-d96153f8c8735e21d0e150a00bd7899767cd507c.tar.xz kernel-qcow2-util-linux-d96153f8c8735e21d0e150a00bd7899767cd507c.zip |
sfdisk: Add support for altering GPT size
Adds a header option to alter the GPT table length
Diffstat (limited to 'libfdisk/src/script.c')
-rw-r--r-- | libfdisk/src/script.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/libfdisk/src/script.c b/libfdisk/src/script.c index 096f37cf8..fd05bf703 100644 --- a/libfdisk/src/script.c +++ b/libfdisk/src/script.c @@ -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; } /** |