Documentation ¶
Index ¶
- type Header
- func (h *Header) BackupLBA() int64
- func (h *Header) CRC() uint32
- func (h *Header) CRCOfPartitionEntries() uint32
- func (h *Header) CurrentLBA() int64
- func (h *Header) DiskGUID() (guid [16]byte)
- func (h *Header) FirstUsableLBA() int64
- func (h *Header) LastUsableLBA() int64
- func (h *Header) NumberOfPartitionEntries() uint32
- func (h *Header) PartitionEntryLBA() int64
- func (h *Header) Revision() uint32
- func (h *Header) SetBackupLBA(lba int64)
- func (h *Header) SetCRC(crc uint32)
- func (h *Header) SetCRCOfPartitionEntries(crc uint32)
- func (h *Header) SetCurrentLBA(lba int64)
- func (h *Header) SetDiskGUID(guid [16]byte)
- func (h *Header) SetFirstUsableLBA(lba int64)
- func (h *Header) SetLastUsableLBA(lba int64)
- func (h *Header) SetNumberOfPartitionEntries(n uint32)
- func (h *Header) SetPartitionEntryLBA(lba int64)
- func (h *Header) SetSize(size uint32)
- func (h *Header) SetSizeOfPartitionEntry(size uint32)
- func (h *Header) Signature() (sig uint64)
- func (h *Header) Size() uint32
- func (h *Header) SizeOfPartitionEntry() uint32
- type PartitionAttributes
- type PartitionEntry
- func (p *PartitionEntry) Attributes() PartitionAttributes
- func (p *PartitionEntry) ClearName()
- func (p *PartitionEntry) FirstLBA() int64
- func (p *PartitionEntry) LastLBA() int64
- func (p *PartitionEntry) PartitionTypeGUID() (guid [16]byte)
- func (p *PartitionEntry) ReadNameAsUTF8(b []byte) (int, error)
- func (p *PartitionEntry) SetAttributes(attr PartitionAttributes)
- func (p *PartitionEntry) SetFirstLBA(lba int64)
- func (p *PartitionEntry) SetLastLBA(lba int64)
- func (p *PartitionEntry) SetNameUTF8(name []byte) error
- func (p *PartitionEntry) SetPartitionTypeGUID(guid [16]byte)
- func (p *PartitionEntry) SetUniquePartitionGUID(guid [16]byte)
- func (p *PartitionEntry) UniquePartitionGUID() (guid [16]byte)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Header ¶
type Header struct {
// contains filtered or unexported fields
}
func (*Header) CRCOfPartitionEntries ¶
CRCOfPartitionEntries returns the CRC32 of the partition entries in the partition table.
func (*Header) CurrentLBA ¶
CurrentLBA returns the LBA of the current GPT header.
func (*Header) FirstUsableLBA ¶
FirstUsableLBA returns the first LBA that is not used by the GPT header, partition table and partition entries.
func (*Header) LastUsableLBA ¶
LastUsableLBA returns the last LBA that is not used by the GPT header, partition table and partition entries.
func (*Header) NumberOfPartitionEntries ¶
NumberOfPartitionEntries returns the number of partition entries in the partition table.
func (*Header) PartitionEntryLBA ¶
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) SetBackupLBA ¶
SetBackupLBA sets the LBA of the backup GPT header.
func (*Header) SetCRCOfPartitionEntries ¶
SetCRCOfPartitionEntries sets the CRC32 of the partition entries in the partition table.
func (*Header) SetCurrentLBA ¶
SetCurrentLBA sets the LBA of the current GPT header.
func (*Header) SetDiskGUID ¶
SetDiskGUID sets the GUID of the disk.
func (*Header) SetFirstUsableLBA ¶
SetFirstUsableLBA sets the first LBA that is not used by the GPT header, partition table and partition entries.
func (*Header) SetLastUsableLBA ¶
SetLastUsableLBA sets the last LBA that is not used by the GPT header, partition table and partition entries.
func (*Header) SetNumberOfPartitionEntries ¶
SetNumberOfPartitionEntries sets the number of partition entries in the partition table.
func (*Header) SetPartitionEntryLBA ¶
SetPartitionEntryLBA sets the LBA of the start of the partition table.
func (*Header) SetSizeOfPartitionEntry ¶
SetSizeOfPartitionEntry sets the size of each partition entry in the partition table.
func (*Header) Signature ¶
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) SizeOfPartitionEntry ¶
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.