disk: add EnsureSize helper

Ensure the partition has at least the given size. Will do nothing
if the partition is already larger. Returns if the size changed.
This commit is contained in:
Christian Kellner 2022-02-18 19:00:25 +01:00 committed by Tom Gundersen
parent e7dbe60622
commit 97754a2c99

View file

@ -339,6 +339,16 @@ func (pt *PartitionTable) getPartitionTableSize() uint64 {
return size
}
// Ensure the partition has at least the given size. Will do nothing
// if the partition is already larger. Returns if the size changed.
func (p *Partition) EnsureSize(s uint64) bool {
if s > p.Size {
p.Size = s
return true
}
return false
}
// Converts Partition to osbuild.QEMUPartition that encodes the same partition.
func (p *Partition) QEMUPartition() osbuild.QEMUPartition {
var fs *osbuild.QEMUFilesystem