mbr: github.com/rekby/mbr Index | Files

package mbr

import "github.com/rekby/mbr"

Index

Package Files

mbr.go

Constants

const (
    PART_EMPTY              = PartitionType(0)
    PART_LINUX_SWAP_SOLARIS = PartitionType(0x82)
    PART_LVM                = PartitionType(0x8E)
    PART_HYBRID_GPT         = PartitionType(0xED)
    PART_GPT                = PartitionType(0xEE)
)

Variables

var ErrorBadMbrSign = errors.New("MBR: Bad signature")
var ErrorPartitionBootFlag = errors.New("MBR: Bad value in boot flag")
var ErrorPartitionLastSectorHigh = errors.New("MBR: Last sector have very high number")
var ErrorPartitionsIntersection = errors.New("MBR: Partitions have intersections")

type MBR Uses

type MBR struct {
    // contains filtered or unexported fields
}

func Read Uses

func Read(disk io.Reader) (*MBR, error)

Read MBR from disk. Example: f, _ := os.Open("/dev/sda") Mbr, err := mbr.Read(f) if err != nil ... f.Close()

func (*MBR) Check Uses

func (this *MBR) Check() error

func (*MBR) FixSignature Uses

func (this *MBR) FixSignature()

func (MBR) GetAllPartitions Uses

func (this MBR) GetAllPartitions() []*MBRPartition

func (MBR) GetPartition Uses

func (this MBR) GetPartition(num int) *MBRPartition

func (MBR) IsGPT Uses

func (this MBR) IsGPT() bool

func (MBR) Write Uses

func (this MBR) Write(disk io.Writer) error

Write MBR to disk Example: f, _ := os.OpenFile("/dev/sda", os.O_RDWR | os.O_SYNC, 0600) err := Mbr.Write(f) if err != nil ... f.Close()

type MBRPartition Uses

type MBRPartition struct {
    Num int
    // contains filtered or unexported fields
}

func (*MBRPartition) GetLBALast Uses

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 Uses

func (this *MBRPartition) GetLBALen() uint32

Return count of sectors in partition.

func (*MBRPartition) GetLBAStart Uses

func (this *MBRPartition) GetLBAStart() uint32

Return number of first sector of partition. Numbers starts from 1.

func (*MBRPartition) GetType Uses

func (this *MBRPartition) GetType() PartitionType

func (*MBRPartition) IsEmpty Uses

func (this *MBRPartition) IsEmpty() bool

Return true if partition have empty type

func (*MBRPartition) SetLBALen Uses

func (this *MBRPartition) SetLBALen(sectorCount uint32)

Set length of partition in sectors.

func (*MBRPartition) SetLBAStart Uses

func (this *MBRPartition) SetLBAStart(startSector uint32)

Set start sector of partition. Number of sector starts from 1. 0 - invalid value.

func (*MBRPartition) SetType Uses

func (this *MBRPartition) SetType(t PartitionType)

type PartitionType Uses

type PartitionType byte

Package mbr imports 2 packages (graph) and is imported by 2 packages. Updated 2017-06-07. Refresh now. Tools for package owners.