mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-27 20:48:11 +00:00
Also fix cdrom provider use of the new diskfs Signed-off-by: Itxaka <itxaka@spectrocloud.com> Signed-off-by: Itxaka <itxaka@spectrocloud.com> Co-authored-by: Itxaka <itxaka@spectrocloud.com>
27 lines
778 B
Go
Vendored
27 lines
778 B
Go
Vendored
// Package partition provides ability to work with individual partitions.
|
|
// All useful implementations are subpackages of this package, e.g. github.com/diskfs/go-diskfs/gpt
|
|
package partition
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/diskfs/go-diskfs/partition/gpt"
|
|
"github.com/diskfs/go-diskfs/partition/mbr"
|
|
"github.com/diskfs/go-diskfs/util"
|
|
)
|
|
|
|
// Read read a partition table from a disk
|
|
func Read(f util.File, logicalBlocksize, physicalBlocksize int) (Table, error) {
|
|
// just try each type
|
|
gptTable, err := gpt.Read(f, logicalBlocksize, physicalBlocksize)
|
|
if err == nil {
|
|
return gptTable, nil
|
|
}
|
|
mbrTable, err := mbr.Read(f, logicalBlocksize, physicalBlocksize)
|
|
if err == nil {
|
|
return mbrTable, nil
|
|
}
|
|
// we are out
|
|
return nil, fmt.Errorf("unknown disk partition type")
|
|
}
|