disk: add bytes ↔ sectors conversion helper
Add simple helper methods that convert between bytes and sectors. This is a method of `PartitionTable`, since the sector size can in theory be per partition table and this prepares for that case.
This commit is contained in:
parent
115c864f93
commit
f5592bd14a
1 changed files with 10 additions and 0 deletions
|
|
@ -53,6 +53,16 @@ type Filesystem struct {
|
|||
FSTabPassNo uint64
|
||||
}
|
||||
|
||||
// Convert the given bytes to the number of sectors.
|
||||
func (pt *PartitionTable) BytesToSectors(size uint64) uint64 {
|
||||
return size / DefaultSectorSize
|
||||
}
|
||||
|
||||
// Convert the given number of sectors to bytes.
|
||||
func (pt *PartitionTable) SectorsToBytes(size uint64) uint64 {
|
||||
return size * DefaultSectorSize
|
||||
}
|
||||
|
||||
// Clone the partition table (deep copy).
|
||||
func (pt *PartitionTable) Clone() *PartitionTable {
|
||||
if pt == nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue