summaryrefslogtreecommitdiffstats
path: root/fdisk/sfdisk.c
diff options
context:
space:
mode:
authorKarel Zak2010-12-09 23:13:58 +0100
committerKarel Zak2010-12-09 23:13:58 +0100
commitf30f2bbc81ad37cdd8f50485e41550dbbd82275d (patch)
tree97304a577f5b0d2dc93040c5777ac05b6f1a5fd3 /fdisk/sfdisk.c
parentrenice: improve messages specifying what ID is referring to (diff)
downloadkernel-qcow2-util-linux-f30f2bbc81ad37cdd8f50485e41550dbbd82275d.tar.gz
kernel-qcow2-util-linux-f30f2bbc81ad37cdd8f50485e41550dbbd82275d.tar.xz
kernel-qcow2-util-linux-f30f2bbc81ad37cdd8f50485e41550dbbd82275d.zip
sfdisk: add option to use maximum partition size
Based on patch from Alex Bligh <alex@alex.org.uk>, Alex wrote: By default, omitting a size parameter means that the maximum sized partition is used. However, this option is not available in conjunction with the -N flag, as under such circumstances the default is the current size of the partition. This patch allows a size to be specified as "+" in which case the maximum sized partition is used, irrespective of the setting of the -N flag. This allows partitions to be programatically resized to their maximum size, by (for instance): echo ",+," | sfdisk -N1 /dev/sda This is non-trivial to do without the patch, as -N makes the default size the existing size. As there is (without this patch) no way of reading the maximum size, the only option is to delete the partition and recreate it. This is undesirable for a number of reasons (e.g. errors between delete and recreate). Addresses: https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/686124 Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'fdisk/sfdisk.c')
-rw-r--r--fdisk/sfdisk.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fdisk/sfdisk.c b/fdisk/sfdisk.c
index fd2f27eb1..958faaebf 100644
--- a/fdisk/sfdisk.c
+++ b/fdisk/sfdisk.c
@@ -2100,6 +2100,8 @@ read_line(int pno, struct part_desc *ep, char *dev, int interactive,
def = orig ? orig->size : (pno > 4 && pct > 1) ? 0 : ml1;
if (fno < 2 || !*(fields[1]))
p.size = def;
+ else if (!strcmp(fields[1], "+"))
+ p.size = ml1;
else {
if (get_ul(fields[1], &ul, def / unitsize(0), 0))
return 0;