diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2011-11-11 18:21:07 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2011-11-11 18:21:07 +0000 |
commit | 7e0a98dc55739e7b85037140a4709b810e93ab0c (patch) | |
tree | f204ffce739c4def6285bc1199710122d05a29fe /sbin | |
parent | 69c9e6746fe4e31945c9d2f735ea904a7db0e20e (diff) |
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.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/fdisk/cmd.c | 9 |
1 files changed, 6 insertions, 3 deletions
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); } |