Documentation ¶
Index ¶
- Constants
- Variables
- func NewGPT(diskBlocks uint64) (*GPT, *GPT, error)
- func WriteGPTPartitions(writer io.WriterAt, start uint64, size uint32, parts []GPTPartition) (uint32, error)
- type CHSAddr
- type Disk
- func (d *Disk) Close() error
- func (d *Disk) ReadGPT(lba uint64) (*GPT, error)
- func (d *Disk) ReadGPTPartitions(start uint64, size uint32, count uint32) ([]GPTPartition, uint32, error)
- func (d *Disk) ReadMBR() (*MBR, error)
- func (d *Disk) WriteGPT(lba uint64, gpt *GPT) error
- func (d *Disk) WriteGPTPartitions(start uint64, size uint32, parts []GPTPartition) (uint32, error)
- func (d *Disk) WriteMBR(mbr *MBR) error
- type GPT
- type GPTPartition
- type MBR
- type MBRPartType
- type MBRPartition
Constants ¶
View Source
const ( GPTSize = 92 GPTPartitionSize = 128 GPTVersion210 = 0x00010000 GPTSignature = 0x5452415020494645 )
View Source
const ( MBRSize = 512 MBRPartitionSize = 16 MBRSignature = 0xAA55 )
View Source
const ( MBRPartTypeLinux = 0x83 MBRPartTypeFAT32LBA = 0x0C MBRPartTypeGPTProtective = 0xEE )
View Source
const BlockSize = 512
Variables ¶
View Source
var ( GPTTypeMicrosoftBasicData = uuid.MustParse("EBD0A0A2-B9E5-4433-87C0-68B6B72699C7") GPTTypeLinuxFileSystem = uuid.MustParse("0FC63DAF-8483-4772-8E79-3D69D8477DE4") )
View Source
var ( ErrGPTNotPresent = errors.New("GPT signature not detected") ErrGPTUnsupported = errors.New("GPT version unsupported") )
View Source
var CHSInvalid = CHSAddr{
Head: 0xFF,
Sector: 0xFF,
Cylinder: 0xFF,
}
Functions ¶
func WriteGPTPartitions ¶
Types ¶
type Disk ¶
type Disk struct {
// contains filtered or unexported fields
}
func (*Disk) ReadGPTPartitions ¶
func (*Disk) WriteGPTPartitions ¶
type GPT ¶
type GPT struct { Signature uint64 Revision uint32 Size uint32 Checksum uint32 Reserved uint32 ThisLBA uint64 AlternativeLBA uint64 DataFirst uint64 DataLast uint64 GUID uuid.UUID PartitionsLBA uint64 PartitionCount uint32 EntrySize uint32 PartitionsCRC uint32 }
func (*GPT) CalculateChecksum ¶
type GPTPartition ¶
type GPTPartition struct { Type uuid.UUID ID uuid.UUID StartLBA uint64 EndLBA uint64 Attributes uint64 Name string }
func NewGPTPartition ¶
func ParseGPTPartitions ¶
type MBR ¶
type MBR struct { Bootstrap [440]byte DiskID uint32 Reserved uint16 Part1 MBRPartition Part2 MBRPartition Part3 MBRPartition Part4 MBRPartition Signature uint16 }
type MBRPartType ¶
type MBRPartType byte
func (MBRPartType) String ¶
func (t MBRPartType) String() string
type MBRPartition ¶
type MBRPartition struct { Attrs byte CHSStart CHSAddr Type MBRPartType CHSLast CHSAddr LBAStart uint32 LBASize uint32 }
func NewMBRPartition ¶
func NewMBRPartition(ty MBRPartType, start uint32, size uint32) MBRPartition
func ParseMBRPartition ¶
func ParseMBRPartition(data []byte) MBRPartition
func (MBRPartition) FillBytes ¶
func (p MBRPartition) FillBytes(data []byte)
func (MBRPartition) String ¶
func (p MBRPartition) String() string
Click to show internal directories.
Click to hide internal directories.