filesystem: fix implem of available_for_partitions
The available_for_partitions function wrongly assumed that the underlying disk had a GPT partition table. Updated the implementation to use the alignment data as expected. Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
parent
dd2553723f
commit
06f5e24904
|
@ -552,7 +552,7 @@ class _Device(_Formattable, ABC):
|
|||
|
||||
@property
|
||||
def available_for_partitions(self):
|
||||
return align_down(self.size, 1 << 20) - GPT_OVERHEAD
|
||||
raise NotImplementedError
|
||||
|
||||
def available(self):
|
||||
# A _Device is available if:
|
||||
|
@ -605,6 +605,12 @@ class Disk(_Device):
|
|||
|
||||
_info = attr.ib(default=None)
|
||||
|
||||
@property
|
||||
def available_for_partitions(self):
|
||||
margin_before = self.alignment_data().min_start_offset
|
||||
margin_after = self.alignment_data().min_end_offset
|
||||
return align_down(self.size, 1 << 20) - margin_before - margin_after
|
||||
|
||||
def alignment_data(self):
|
||||
ptable = self.ptable_for_new_partition()
|
||||
return self._m._partition_alignment_data[ptable]
|
||||
|
|
Loading…
Reference in New Issue