diff options
author | 2015-11-21 16:45:41 +0000 | |
---|---|---|
committer | 2015-11-21 16:45:41 +0000 | |
commit | 684c15929ab3ac3abbbcdba77d2d06b5fd9f917c (patch) | |
tree | 620ff0920a7a6eff58d018de27eae7ec3eccfd51 /sbin/fdisk/cmd.c | |
parent | sync (diff) | |
download | wireguard-openbsd-684c15929ab3ac3abbbcdba77d2d06b5fd9f917c.tar.xz wireguard-openbsd-684c15929ab3ac3abbbcdba77d2d06b5fd9f917c.zip |
Bring GPT partition editing into line with MBR partition editing
by presenting the existing offset and size as the defaults. Enhance
getuint64() to take a minimum value as ask_num() does. Use this to
ensure that GPT partitions are constrained to the valid area of the
disk. Leave MBR partition constraints alone for the moment.
Original problem(s) noted by tim@
Diffstat (limited to 'sbin/fdisk/cmd.c')
-rw-r--r-- | sbin/fdisk/cmd.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/sbin/fdisk/cmd.c b/sbin/fdisk/cmd.c index 103432b9f87..5481966566b 100644 --- a/sbin/fdisk/cmd.c +++ b/sbin/fdisk/cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.89 2015/11/21 02:12:09 krw Exp $ */ +/* $OpenBSD: cmd.c,v 1.90 2015/11/21 16:45:41 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -187,10 +187,10 @@ Xgedit(char *args) goto done; } - bs = getuint64("Partition offset", letoh64(gh.gh_lba_start), - letoh64(gh.gh_lba_end)); - ns = getuint64("Partition size", letoh64(gh.gh_lba_end) - bs + 1, - letoh64(gh.gh_lba_end) - bs + 1); + bs = getuint64("Partition offset", letoh64(gg->gp_lba_start), + letoh64(gh.gh_lba_start), letoh64(gh.gh_lba_end)); + ns = getuint64("Partition size", letoh64(gg->gp_lba_end) - bs + 1, + 0, letoh64(gh.gh_lba_end) - bs + 1); gg->gp_lba_start = htole64(bs); gg->gp_lba_end = htole64(bs + ns - 1); @@ -267,9 +267,8 @@ Xedit(char *args, struct mbr *mbr) /* Fix up CHS values for LBA */ PRT_fix_CHS(pp); } else { - pp->bs = getuint64("Partition offset", pp->bs, - disk.size); - pp->ns = getuint64("Partition size", pp->ns, + pp->bs = getuint64("Partition offset", pp->bs, 0, disk.size); + pp->ns = getuint64("Partition size", pp->ns, 0, disk.size - pp->bs); /* Fix up CHS values */ |