diff options
| author | Sassan Panahinejad <sassan@sassan.me.uk> | 2016-05-12 12:54:43 +0100 |
|---|---|---|
| committer | Karel Zak <kzak@redhat.com> | 2016-05-18 13:56:25 +0200 |
| commit | d96153f8c8735e21d0e150a00bd7899767cd507c (patch) | |
| tree | fc0c917378a1de077866bdc35de67a61c26d6306 /libfdisk/src/script.c | |
| parent | a18e726c6676914d4488cc8ace5d253a35dac4e5 (diff) | |
| download | util-linux-d96153f8c8735e21d0e150a00bd7899767cd507c.tar.gz | |
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 096f37cf8f..fd05bf703d 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; } /** |
