efijumpstart

package
v0.0.0-...-64da353 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

File: internal/efijumpstart/bootability_checker.go

File: internal/efijumpstart/efi_driver_extractor.go

File: internal/efijumpstart/efi_jumpstart_analyzer.go

File: internal/efijumpstart/efi_jumpstart_locator.go

File: internal/efijumpstart/efi_jumpstart_reader.go

File: internal/partitionmanager/efi_partition_manager.go

File: internal/efijumpstart/test_mocking.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEFIDriverExtractor

func NewEFIDriverExtractor(data types.NxEfiJumpstartT, reader io.ReaderAt, blockSize uint32) (interfaces.EFIDriverExtractor, error)

NewEFIDriverExtractor creates a new extractor instance. It requires the jumpstart data, an io.ReaderAt for the underlying storage, and the container's block size. Returns an error if blockSize is zero.

func NewEFIJumpstartAnalyzer

func NewEFIJumpstartAnalyzer(
	data types.NxEfiJumpstartT,
	blockSize uint32,
	extractor interfaces.EFIDriverExtractor,
) (interfaces.EFIJumpstartAnalyzer, error)

NewEFIJumpstartAnalyzer creates a new analyzer instance. The driverExtractor is optional; if nil, driver content analysis will be skipped.

func NewEFIJumpstartReader

func NewEFIJumpstartReader(data types.NxEfiJumpstartT) interfaces.EFIJumpstartReader

NewEFIJumpstartReader creates a new reader instance from the parsed jumpstart data.

Types

type APFSJumpstartLocator

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

APFSJumpstartLocator provides a complete implementation to find EFI jumpstart structures in APFS containers

func NewAPFSJumpstartLocator

func NewAPFSJumpstartLocator(reader io.ReaderAt, blockSize uint32, partitionOffset int64) (*APFSJumpstartLocator, error)

NewAPFSJumpstartLocator creates a locator that can find EFI jumpstart structures in an APFS container.

Parameters:

  • reader: Interface to read the raw disk/image
  • blockSize: The block size used by the APFS container (usually 4096)
  • partitionOffset: The byte offset to the start of the APFS container partition

func (*APFSJumpstartLocator) FindEFIJumpstart

func (l *APFSJumpstartLocator) FindEFIJumpstart() (types.Paddr, error)

FindEFIJumpstart locates and returns the physical address of the EFI jumpstart structure within the APFS container.

func (*APFSJumpstartLocator) FindEFIJumpstartInPartition

func (l *APFSJumpstartLocator) FindEFIJumpstartInPartition(partitionUUID string) (types.Paddr, error)

FindEFIJumpstartInPartition locates the EFI jumpstart structure in a specific APFS partition. This implementation searches for the partition in a GPT-formatted disk, then locates the jumpstart within that partition.

func (*APFSJumpstartLocator) ReadJumpstartObjectFromPaddr

func (l *APFSJumpstartLocator) ReadJumpstartObjectFromPaddr(paddr types.Paddr) (*types.NxEfiJumpstartT, error)

ReadJumpstartObjectFromPaddr reads and parses the NxEfiJumpstartT structure from the given physical address. This is a helper method to verify that we've found the correct jumpstart structure.

type EFIDriverExtractor

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

EFIDriverExtractor implements the EFIDriverExtractor interface. It holds the parsed EFI jumpstart data, a reader for the underlying storage, and the filesystem block size.

func (*EFIDriverExtractor) ExtractEFIDriver

func (e *EFIDriverExtractor) ExtractEFIDriver(outputPath string) error

ExtractEFIDriver retrieves the EFI driver data and saves it to the specified file path.

func (*EFIDriverExtractor) GetEFIDriverData

func (e *EFIDriverExtractor) GetEFIDriverData() ([]byte, error)

GetEFIDriverData reads the EFI driver content from the underlying storage based on extents.

func (*EFIDriverExtractor) ValidateEFIDriver

func (e *EFIDriverExtractor) ValidateEFIDriver() error

ValidateEFIDriver checks if the EFI driver data can be fully read according to the extents and expected size. It calls GetEFIDriverData internally to perform the checks.

type EFIJumpstartReader

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

EFIJumpstartReader implements the EFIJumpstartReader interface. It holds the parsed EFI jumpstart data structure.

func (*EFIJumpstartReader) EFIFileLength

func (r *EFIJumpstartReader) EFIFileLength() uint32

EFIFileLength returns the size in bytes of the embedded EFI driver.

func (*EFIJumpstartReader) ExtentCount

func (r *EFIJumpstartReader) ExtentCount() uint32

ExtentCount returns the number of extents where the EFI driver is stored.

func (*EFIJumpstartReader) Extents

func (r *EFIJumpstartReader) Extents() []types.Prange

Extents returns a copy of the locations where the EFI driver is stored. Returning a copy prevents external modification of the internal slice.

func (*EFIJumpstartReader) IsValid

func (r *EFIJumpstartReader) IsValid() bool

IsValid checks if the EFI jumpstart structure is valid based on magic number and version.

func (*EFIJumpstartReader) Magic

func (r *EFIJumpstartReader) Magic() uint32

Magic returns the magic number for validating the EFI jumpstart structure.

func (*EFIJumpstartReader) Version

func (r *EFIJumpstartReader) Version() uint32

Version returns the version number of the EFI jumpstart structure.

type GPTPartitionManager

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

GPTPartitionManager implements the EFIPartitionManager interface using GPT. It reads GPT data to provide information about EFI-relevant partitions.

func NewGPTPartitionManager

func NewGPTPartitionManager(device io.ReaderAt, logicalBlockSize uint64, associatedAPFSPartitionUUID string) (*GPTPartitionManager, error)

NewGPTPartitionManager creates a new GPT-based partition manager.

func (*GPTPartitionManager) GetPartitionUUID

func (m *GPTPartitionManager) GetPartitionUUID() string

GetPartitionUUID returns the UUID of the APFS partition associated with this manager instance.

func (*GPTPartitionManager) IsAPFSPartition

func (m *GPTPartitionManager) IsAPFSPartition(partitionUUID string) bool

IsAPFSPartition checks if a given UUID string matches the known APFS Partition Type GUID. Comparison is case-insensitive.

func (*GPTPartitionManager) ListEFIPartitions

func (m *GPTPartitionManager) ListEFIPartitions() ([]interfaces.EFIPartitionInfo, error)

ListEFIPartitions scans the primary GPT and returns information about all found EFI System Partitions.

type Jumpstart

type Jumpstart struct {
	*types.NxEfiJumpstartT
}

Jumpstart wraps types.NxEfiJumpstartT to provide helper methods.

func (*Jumpstart) TotalSize

func (j *Jumpstart) TotalSize() int

TotalSize returns the total size in bytes of the NxEfiJumpstartT structure, including the variable-length array of Prange extent entries.

This calculation includes:

  • ObjPhysT: 8 bytes (assumed fixed, double-check if yours is larger)
  • NejMagic: 4 bytes
  • NejVersion: 4 bytes
  • NejEfiFileLen: 4 bytes
  • NejNumExtents: 4 bytes
  • NejReserved: 16 * 8 bytes = 128 bytes
  • NejRecExtents: num_extents * sizeof(Prange)

Note: This is only valid if the structure was read from disk or constructed as a contiguous block. In Go memory, sizes may vary based on alignment.

Reference: APFS Reference, page 24–25.

type JumpstartAnalyzer

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

JumpstartAnalyzer implements the EFIJumpstartAnalyzer interface.

func (*JumpstartAnalyzer) AnalyzeEFIJumpstart

func (a *JumpstartAnalyzer) AnalyzeEFIJumpstart() (interfaces.EFIJumpstartAnalysis, error)

AnalyzeEFIJumpstart performs a detailed analysis and populates the EFIJumpstartAnalysis struct.

func (*JumpstartAnalyzer) VerifyEFIJumpstart

func (a *JumpstartAnalyzer) VerifyEFIJumpstart() error

VerifyEFIJumpstart checks basic validity (magic, version) and readability via the extractor if available.

type PartitionInfo

type PartitionInfo struct {
	UUID   string
	Name   string
	Offset int64
	Size   uint64
}

PartitionInfo represents basic partition information

type SimpleBootabilityChecker

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

SimpleBootabilityChecker implements BootabilityChecker using other interfaces.

func NewSimpleBootabilityChecker

func NewSimpleBootabilityChecker(reader interfaces.EFIJumpstartReader, analyzer interfaces.EFIJumpstartAnalyzer) (*SimpleBootabilityChecker, error)

NewSimpleBootabilityChecker creates a new bootability checker. The reader is required, the analyzer is optional.

func (*SimpleBootabilityChecker) GetBootRequirements

func (bc *SimpleBootabilityChecker) GetBootRequirements() ([]string, error)

GetBootRequirements returns a static list of general requirements.

func (*SimpleBootabilityChecker) IsBootable

func (bc *SimpleBootabilityChecker) IsBootable() bool

IsBootable checks if a valid EFI jumpstart structure exists.

func (*SimpleBootabilityChecker) VerifyBootConfiguration

func (bc *SimpleBootabilityChecker) VerifyBootConfiguration() error

VerifyBootConfiguration performs a more detailed check using the analyzer if available.

Jump to

Keyboard shortcuts

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