From 0d413fc69e25f82ccb874cb928ef45b93c6e5d4e Mon Sep 17 00:00:00 2001 From: Nikos Skalkotos Date: Thu, 30 Jan 2014 13:53:10 +0200 Subject: [PATCH] Fix a bug in disklabel enlarge code If the disk size is greater that 8G then the CHS value of the MBR will overflow. We should assign a fixed CHS value for this case. --- snf-image-helper/disklabel.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/snf-image-helper/disklabel.py b/snf-image-helper/disklabel.py index f119192..527d01c 100755 --- a/snf-image-helper/disklabel.py +++ b/snf-image-helper/disklabel.py @@ -94,8 +94,15 @@ class MBR(object): """Packs a CHS tuple to an address string.""" assert 1 <= sector <= 63 - assert 0 <= cylinder <= 1023 assert 0 <= head <= 255 + assert 0 <= cylinder + + # If the cylinders overflow then put the value (1023, 254, 63) to + # the tuple. At least this is what OpenBSD does. + if cylinder > 1023: + cylinder = 1023 + head = 254 + sector = 63 byte0 = head byte1 = (cylinder >> 2) & 0xC0 | sector -- 1.7.10.4