From 7e0a98dc55739e7b85037140a4709b810e93ab0c Mon Sep 17 00:00:00 2001 From: Kenneth R Westerback Date: Fri, 11 Nov 2011 18:21:07 +0000 Subject: A zero-length partition is a non-partition, so reject a partition length of 0. And anyway PRT_fix_CHS() writes garbage when length is zero. Refresh the in-memory copy to reflect any data that was written out, so you can see that your changes have taken effect. Surprise behaviours noted by matthew@ at c2k11. --- sbin/fdisk/cmd.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'sbin') diff --git a/sbin/fdisk/cmd.c b/sbin/fdisk/cmd.c index 2708b13759c..d7cf3498cd9 100644 --- a/sbin/fdisk/cmd.c +++ b/sbin/fdisk/cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.45 2010/07/02 02:54:09 halex Exp $ */ +/* $OpenBSD: cmd.c,v 1.46 2011/11/11 18:21:06 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -224,9 +224,9 @@ Xedit(cmd_t *cmd, disk_t *disk, mbr_t *mbr, mbr_t *tt, int offset) d, m, pp->bs , DO_CONVERSIONS | ((pp->id == FS_BSDFFS || pp->id == FS_SWAP) ? DO_ROUNDING : 0)); - if (pp->ns == UINT_MAX) + if (pp->ns == UINT_MAX || pp->ns == 0) printf("Invalid size.\n"); - } while (pp->ns == UINT_MAX); + } while (pp->ns == UINT_MAX || pp->ns == 0); /* Fix up CHS values */ PRT_fix_CHS(disk, pp); @@ -343,6 +343,9 @@ Xwrite(cmd_t *cmd, disk_t *disk, mbr_t *mbr, mbr_t *tt, int offset) } close(fd); + /* Refresh in memory copy to reflect what was just written. */ + MBR_parse(disk, mbr_buf, mbr->offset, mbr->reloffset, mbr); + return (CMD_CLEAN); } -- cgit v1.2.3