disk: implement Sizeable interface for PartitionTable and Partition
In our model a partition table has a size to represent the disk size. Also each individual partition has a size, so they both implement the Sizeable interface. Co-Authored-By: Achilleas Koutsou <achilleas@koutsou.net>
This commit is contained in:
parent
0e1c769598
commit
4c34b5e2a8
2 changed files with 26 additions and 10 deletions
|
|
@ -22,16 +22,6 @@ func (p *Partition) IsContainer() bool {
|
|||
return true
|
||||
}
|
||||
|
||||
// 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
|
||||
|
|
@ -62,3 +52,17 @@ func (p *Partition) GetChild(n uint) Entity {
|
|||
}
|
||||
return p.Filesystem
|
||||
}
|
||||
|
||||
func (p *Partition) GetSize() uint64 {
|
||||
return p.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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue