round displayed hd sizes down to the nearest MiB

do not know if this makes a real difference but no real cost to being defensive
This commit is contained in:
Michael Hudson-Doyle 2018-03-22 14:15:36 +13:00
parent af67c7074c
commit d1c431af01
1 changed files with 4 additions and 1 deletions

View File

@ -169,7 +169,7 @@ class Disk:
@property
def size(self):
return self._info.size - (2<<20) # The first and last megabyte of the disk are not usable.
return align_down(self._info.size) - (2<<20) # The first and last megabyte of the disk are not usable.
def desc(self):
return "local disk"
@ -256,6 +256,9 @@ class Mount:
def align_up(size, block_size=1 << 20):
return (size + block_size - 1) & ~(block_size - 1)
def align_down(size, block_size=1 << 20):
return size & ~(block_size - 1)
class FilesystemModel(object):