gpt

package
v0.0.0-...-6180576 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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

func ToHeader

func ToHeader(start []byte) (Header, error)

func (*Header) BackupLBA

func (h *Header) BackupLBA() int64

BackupLBA returns the LBA of the backup GPT header.

func (*Header) CRC

func (h *Header) CRC() uint32

CRC returns the CRC32 of the GPT header.

func (*Header) CRCOfPartitionEntries

func (h *Header) CRCOfPartitionEntries() uint32

CRCOfPartitionEntries returns the CRC32 of the partition entries in the partition table.

func (*Header) CurrentLBA

func (h *Header) CurrentLBA() int64

CurrentLBA returns the LBA of the current GPT header.

func (*Header) DiskGUID

func (h *Header) DiskGUID() (guid [16]byte)

DiskGUID returns the GUID of the disk.

func (*Header) FirstUsableLBA

func (h *Header) FirstUsableLBA() int64

FirstUsableLBA returns the first LBA that is not used by the GPT header, partition table and partition entries.

func (*Header) LastUsableLBA

func (h *Header) LastUsableLBA() int64

LastUsableLBA returns the last LBA that is not used by the GPT header, partition table and partition entries.

func (*Header) NumberOfPartitionEntries

func (h *Header) NumberOfPartitionEntries() uint32

NumberOfPartitionEntries returns the number of partition entries in the partition table.

func (*Header) PartitionEntryLBA

func (h *Header) PartitionEntryLBA() int64

PartitionEntryLBA returns the LBA of the start of the partition table. This field is usually 2 for compatibility with MBR paritioning. This is because 0 is used for the protective MBR and 1 is used for the GPT header.

func (*Header) Revision

func (h *Header) Revision() uint32

Revision returns the GPT Header revision number. [0,0,1,0] for UEFI 2.10.

func (*Header) SetBackupLBA

func (h *Header) SetBackupLBA(lba int64)

SetBackupLBA sets the LBA of the backup GPT header.

func (*Header) SetCRC

func (h *Header) SetCRC(crc uint32)

SetCRC sets the CRC32 of the GPT header.

func (*Header) SetCRCOfPartitionEntries

func (h *Header) SetCRCOfPartitionEntries(crc uint32)

SetCRCOfPartitionEntries sets the CRC32 of the partition entries in the partition table.

func (*Header) SetCurrentLBA

func (h *Header) SetCurrentLBA(lba int64)

SetCurrentLBA sets the LBA of the current GPT header.

func (*Header) SetDiskGUID

func (h *Header) SetDiskGUID(guid [16]byte)

SetDiskGUID sets the GUID of the disk.

func (*Header) SetFirstUsableLBA

func (h *Header) SetFirstUsableLBA(lba int64)

SetFirstUsableLBA sets the first LBA that is not used by the GPT header, partition table and partition entries.

func (*Header) SetLastUsableLBA

func (h *Header) SetLastUsableLBA(lba int64)

SetLastUsableLBA sets the last LBA that is not used by the GPT header, partition table and partition entries.

func (*Header) SetNumberOfPartitionEntries

func (h *Header) SetNumberOfPartitionEntries(n uint32)

SetNumberOfPartitionEntries sets the number of partition entries in the partition table.

func (*Header) SetPartitionEntryLBA

func (h *Header) SetPartitionEntryLBA(lba int64)

SetPartitionEntryLBA sets the LBA of the start of the partition table.

func (*Header) SetSize

func (h *Header) SetSize(size uint32)

SetSize sets the size of the GPT header in bytes.

func (*Header) SetSizeOfPartitionEntry

func (h *Header) SetSizeOfPartitionEntry(size uint32)

SetSizeOfPartitionEntry sets the size of each partition entry in the partition table.

func (*Header) Signature

func (h *Header) Signature() (sig uint64)

Signature returns the 8-byte signature at the start of the GPT header. Expect it to be 0x5452415020494645, which is "EFI PART" in little-endian.

func (*Header) Size

func (h *Header) Size() uint32

Size returns the size of the GPT header in bytes, usually 92.

func (*Header) SizeOfPartitionEntry

func (h *Header) SizeOfPartitionEntry() uint32

SizeOfPartitionEntry returns the size of each partition entry in the partition table. Is usually 128.

type PartitionAttributes

type PartitionAttributes uint64

type PartitionEntry

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

PartitionEntry represents a single partition entry in the GPT partition table. Usually of size 128 bytes.

func ToPartitionEntry

func ToPartitionEntry(start []byte) (PartitionEntry, error)

func (*PartitionEntry) Attributes

func (p *PartitionEntry) Attributes() PartitionAttributes

Attributes returns the attributes of the partition.

func (*PartitionEntry) ClearName

func (p *PartitionEntry) ClearName()

func (*PartitionEntry) FirstLBA

func (p *PartitionEntry) FirstLBA() int64

FirstLBA returns the first LBA of the partition. To calculate total LBAs: (LastLBA - FirstLBA) + 1

func (*PartitionEntry) LastLBA

func (p *PartitionEntry) LastLBA() int64

LastLBA returns the last LBA of the partition (inclusive). To calculate total LBAs: (LastLBA - FirstLBA) + 1

func (*PartitionEntry) PartitionTypeGUID

func (p *PartitionEntry) PartitionTypeGUID() (guid [16]byte)

PartitionTypeGUID returns the GUID of the partition type.

func (*PartitionEntry) ReadNameAsUTF8

func (p *PartitionEntry) ReadNameAsUTF8(b []byte) (int, error)

ReadNameAsUTF8 reads the partition name from the partition entry and encodes it as utf-8 into the provided slice. The number of bytes read is returned along with any error.

func (*PartitionEntry) SetAttributes

func (p *PartitionEntry) SetAttributes(attr PartitionAttributes)

SetAttributes sets the attributes of the partition.

func (*PartitionEntry) SetFirstLBA

func (p *PartitionEntry) SetFirstLBA(lba int64)

SetFirstLBA sets the first LBA of the partition.

func (*PartitionEntry) SetLastLBA

func (p *PartitionEntry) SetLastLBA(lba int64)

SetLastLBA sets the last LBA of the partition (inclusive).

func (*PartitionEntry) SetNameUTF8

func (p *PartitionEntry) SetNameUTF8(name []byte) error

SetNameUTF8 writes a utf-8 encoded string as the Partition Entry's name.

func (*PartitionEntry) SetPartitionTypeGUID

func (p *PartitionEntry) SetPartitionTypeGUID(guid [16]byte)

SetPartitionTypeGUID sets the GUID of the partition type.

func (*PartitionEntry) SetUniquePartitionGUID

func (p *PartitionEntry) SetUniquePartitionGUID(guid [16]byte)

SetUniquePartitionGUID sets the GUID of the partition.

func (*PartitionEntry) UniquePartitionGUID

func (p *PartitionEntry) UniquePartitionGUID() (guid [16]byte)

UniquePartitionGUID returns the GUID of the partition.

Jump to

Keyboard shortcuts

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