diff options
author | Francesco Cosoleto | 2011-11-14 14:47:19 +0100 |
---|---|---|
committer | Karel Zak | 2011-11-14 15:07:28 +0100 |
commit | 47104bae8975511383bcef5c96545f03bb4e4cce (patch) | |
tree | fa2c3e3e7600584a356dda42035c14680b25c823 /fdisk/fdisk.c | |
parent | fdisk: avoid segfault validating a sgi label (boot/swap not set) (diff) | |
download | kernel-qcow2-util-linux-47104bae8975511383bcef5c96545f03bb4e4cce.tar.gz kernel-qcow2-util-linux-47104bae8975511383bcef5c96545f03bb4e4cce.tar.xz kernel-qcow2-util-linux-47104bae8975511383bcef5c96545f03bb4e4cce.zip |
fdisk: split delete_partition() off from dos_delete_partition()
This accidentally fixes a mistake printing the "Partition n is deleted"
message as the 'i' variable get decremented or incremented in case of
logical partitions.
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
Diffstat (limited to 'fdisk/fdisk.c')
-rw-r--r-- | fdisk/fdisk.c | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c index 259c46e85..00dd706d1 100644 --- a/fdisk/fdisk.c +++ b/fdisk/fdisk.c @@ -1584,25 +1584,16 @@ toggle_dos_compatibility_flag(void) { update_sector_offset(); } -static void -delete_partition(int i) { +static void dos_delete_partition(int i) +{ struct pte *pe = &ptes[i]; struct partition *p = pe->part_table; struct partition *q = pe->ext_pointer; -/* Note that for the fifth partition (i == 4) we don't actually - * decrement partitions. - */ - - if (warn_geometry()) - return; /* C/H/S not set */ - pe->changed = 1; + /* Note that for the fifth partition (i == 4) we don't actually + decrement partitions. */ - if (disklabel == SUN_LABEL) - sun_delete_partition(i); - else if (disklabel == SGI_LABEL) - sgi_delete_partition(i); - else if (i < 4) { + if (i < 4) { if (IS_EXTENDED (p->sys_ind) && i == ext_index) { partitions = 4; ptes[ext_index].ext_pointer = NULL; @@ -1646,6 +1637,23 @@ delete_partition(int i) { /* the only logical: clear only */ clear_partition(ptes[i].part_table); } +} + +static void +delete_partition(int i) +{ + if (warn_geometry()) + return; /* C/H/S not set */ + + ptes[i].changed = 1; + + if (disklabel == DOS_LABEL) + dos_delete_partition(i); + else if (disklabel == SUN_LABEL) + sun_delete_partition(i); + else if (disklabel == SGI_LABEL) + sgi_delete_partition(i); + printf(_("Partition %d is deleted\n"), i + 1); } |