Commit 0d413fc6 authored by Nikos Skalkotos's avatar Nikos Skalkotos
Browse files

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.
parent 922c1513
...@@ -94,8 +94,15 @@ class MBR(object): ...@@ -94,8 +94,15 @@ class MBR(object):
"""Packs a CHS tuple to an address string.""" """Packs a CHS tuple to an address string."""
assert 1 <= sector <= 63 assert 1 <= sector <= 63
assert 0 <= cylinder <= 1023
assert 0 <= head <= 255 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 byte0 = head
byte1 = (cylinder >> 2) & 0xC0 | sector byte1 = (cylinder >> 2) & 0xC0 | sector
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment