From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: util-linux-owner@vger.kernel.org Received: from mail-wm0-f68.google.com ([74.125.82.68]:35237 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752109AbcELLyy (ORCPT ); Thu, 12 May 2016 07:54:54 -0400 Received: by mail-wm0-f68.google.com with SMTP id e201so15611002wme.2 for ; Thu, 12 May 2016 04:54:53 -0700 (PDT) From: Sassan Panahinejad To: util-linux@vger.kernel.org Cc: Sassan Panahinejad Subject: [PATCH v2 3/3] sfdisk: Add support for altering GPT size Date: Thu, 12 May 2016 12:54:43 +0100 Message-Id: <1463054083-2485-4-git-send-email-sassan@sassan.me.uk> In-Reply-To: <1463054083-2485-1-git-send-email-sassan@sassan.me.uk> References: <1463054083-2485-1-git-send-email-sassan@sassan.me.uk> Sender: util-linux-owner@vger.kernel.org List-ID: Adds a header option to alter the GPT table length --- libfdisk/src/script.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/libfdisk/src/script.c b/libfdisk/src/script.c index 096f37c..fd05bf7 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; } /** -- 2.1.0