mbr

package module
v0.0.0-...-d19b4be Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2019 License: MIT Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Library for work with MBR (Master boot record) record of disk.

Main purpose when create library - usage for direct resize partitions as https://github.com/amarao/ptmax
from golang without external dependency.

GoDoc: https://godoc.org/github.com/rekby/mbr

Documentation

Index

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)
)

Variables

View Source
var ErrorBadMbrSign = errors.New("MBR: Bad signature")
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

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

func (this *MBR) Check() error

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) IsGPT

func (this MBR) IsGPT() bool

func (MBR) Write

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

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) 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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL