Documentation ¶
Index ¶
- Constants
- Variables
- type MBR
- func (this *MBR) Check() error
- func (this *MBR) FixSignature()
- func (this MBR) GetAllPartitions() []*MBRPartition
- func (this MBR) GetPartition(num int) *MBRPartition
- func (this MBR) IsGPT() bool
- func (this *MBR) MakeProtective(sectorSize int, diskSize uint64, pType ProtectiveType) error
- func (this MBR) Write(disk io.Writer) error
- type MBRPartition
- func (this *MBRPartition) GetLBALast() uint32
- func (this *MBRPartition) GetLBALen() uint32
- func (this *MBRPartition) GetLBAStart() uint32
- func (this *MBRPartition) GetType() PartitionType
- func (this *MBRPartition) IsBootable() bool
- func (this *MBRPartition) IsEmpty() bool
- func (this *MBRPartition) SetBootable(bootable bool)
- func (this *MBRPartition) SetLBALen(sectorCount uint32)
- func (this *MBRPartition) SetLBAStart(startSector uint32)
- func (this *MBRPartition) SetType(t PartitionType)
- type PartitionType
- type ProtectiveType
Constants ¶
View Source
const ( PART_EMPTY = PartitionType(0) PART_LINUX_SWAP_SOLARIS = PartitionType(0x82) PART_LVM = PartitionType(0x8E) PART_HYBRID_GPT = PartitionType(0xED) PART_GPT = PartitionType(0xEE) )
View Source
const ( DiskSize = ProtectiveType(1) MaxSize = ProtectiveType(2) DefaultProtective = ProtectiveType(0) )
Variables ¶
View Source
var ErrorBadMbrSign = errors.New("MBR: Bad signature")
View Source
var ErrorDiskSizeNotEvenSectors = errors.New("MBR: Disk size is not evenly divisible by sector size")
View Source
var ErrorInvalidProtectiveType = errors.New("Invalid value for ProtectiveType")
View Source
var ErrorPartitionBootFlag = errors.New("MBR: Bad value in boot flag")
View Source
var ErrorPartitionLastSectorHigh = errors.New("MBR: Last sector have very high number")
View Source
var ErrorPartitionsIntersection = errors.New("MBR: Partitions have intersections")
Functions ¶
This section is empty.
Types ¶
type MBR ¶
type MBR struct {
// contains filtered or unexported fields
}
func Read ¶
Read MBR from disk. Example: f, _ := os.Open("/dev/sda") Mbr, err := mbr.Read(f) if err != nil ... f.Close()
func (*MBR) FixSignature ¶
func (this *MBR) FixSignature()
func (MBR) GetAllPartitions ¶
func (this MBR) GetAllPartitions() []*MBRPartition
func (MBR) GetPartition ¶
func (this MBR) GetPartition(num int) *MBRPartition
func (*MBR) MakeProtective ¶
func (this *MBR) MakeProtective(sectorSize int, diskSize uint64, pType ProtectiveType) error
MakeProtective - Make this MBR a GPT Protective MBR
sectorSize is either 512 or 4096. diskSize is the size of entire disk in bytes. https://en.wikipedia.org/wiki/GUID_Partition_Table#Protective_MBR_(LBA_0) ProtectiveType value determines how the size of the partition is set. DefaultProtective - implementation default value MaxSize - Size of the ProtectiveMBR partition will be set to 0xFFFFFFFF While this is strictly outside the UEFI spec, it is the behavior of linux and windows partitioners. DiskSize - the actual length of the partition size size up to 0xFFFFFFFF - 1
type MBRPartition ¶
type MBRPartition struct { Num int // contains filtered or unexported fields }
func (*MBRPartition) GetLBALast ¶
func (this *MBRPartition) GetLBALast() uint32
Return number of last setor if partition.
If last sector num more then max uint32 - panic. It mean error in metadata.
func (*MBRPartition) GetLBALen ¶
func (this *MBRPartition) GetLBALen() uint32
Return count of sectors in partition.
func (*MBRPartition) GetLBAStart ¶
func (this *MBRPartition) GetLBAStart() uint32
Return number of first sector of partition. Numbers starts from 1.
func (*MBRPartition) GetType ¶
func (this *MBRPartition) GetType() PartitionType
func (*MBRPartition) IsBootable ¶
func (this *MBRPartition) IsBootable() bool
Return true if this partition's bootable flag is set.
func (*MBRPartition) IsEmpty ¶
func (this *MBRPartition) IsEmpty() bool
Return true if partition have empty type
func (*MBRPartition) SetBootable ¶
func (this *MBRPartition) SetBootable(bootable bool)
Set the Bootable flag on this partition.
func (*MBRPartition) SetLBALen ¶
func (this *MBRPartition) SetLBALen(sectorCount uint32)
Set length of partition in sectors.
func (*MBRPartition) SetLBAStart ¶
func (this *MBRPartition) SetLBAStart(startSector uint32)
Set start sector of partition. Number of sector starts from 1. 0 - invalid value.
func (*MBRPartition) SetType ¶
func (this *MBRPartition) SetType(t PartitionType)
type PartitionType ¶
type PartitionType byte
type ProtectiveType ¶
type ProtectiveType int
Click to show internal directories.
Click to hide internal directories.