diff options
author | Karel Zak | 2014-10-14 19:46:17 +0200 |
---|---|---|
committer | Karel Zak | 2014-10-14 19:46:17 +0200 |
commit | 150d98ee3f24bfdc5b181b195e865657d8c6245c (patch) | |
tree | dcf903ff5d293c0f03a352c3b2cf42ea0aeff4ca /libfdisk/src/dos.c | |
parent | tests: update fdisk formatting (diff) | |
download | kernel-qcow2-util-linux-150d98ee3f24bfdc5b181b195e865657d8c6245c.tar.gz kernel-qcow2-util-linux-150d98ee3f24bfdc5b181b195e865657d8c6245c.tar.xz kernel-qcow2-util-linux-150d98ee3f24bfdc5b181b195e865657d8c6245c.zip |
libfdisk: (dos) set partition start/size only when requested
Diffstat (limited to 'libfdisk/src/dos.c')
-rw-r--r-- | libfdisk/src/dos.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c index 0ce032867..0ae0615a2 100644 --- a/libfdisk/src/dos.c +++ b/libfdisk/src/dos.c @@ -1808,7 +1808,6 @@ static int dos_set_partition(struct fdisk_context *cxt, size_t n, { struct dos_partition *p; struct pte *pe; - sector_t start, size; assert(cxt); assert(pa); @@ -1827,16 +1826,28 @@ static int dos_set_partition(struct fdisk_context *cxt, size_t n, if (pa->type && !pa->type->code) fdisk_warnx(cxt, _("Type 0 means free space to many systems. " "Having partitions of type 0 is probably unwise.")); - pe = self_pte(cxt, n); + p = self_partition(cxt, n); - start = pa->start ? pa->start : get_abs_partition_start(pe); - size = pa->size ? pa->size : dos_partition_get_size(p); + if (pa->start || pa->size) { + sector_t start, size; + + pe = self_pte(cxt, n); + + start = pa->start ? pa->start : get_abs_partition_start(pe); + size = pa->size ? pa->size : dos_partition_get_size(p); - set_partition(cxt, n, 0, start, start + size - 1, + set_partition(cxt, n, 0, start, start + size - 1, pa->type ? pa->type->code : p->sys_ind, pa->boot); + } else { + if (pa->type) + p->sys_ind = pa->type->code; + if (pa->boot != FDISK_EMPTY_BOOTFLAG) + p->boot_ind = pa->boot == 1 ? ACTIVE_FLAG : 0; + } + partition_set_changed(cxt, n, 1); return 0; } |