Documentation ¶
Index ¶
- Constants
- Variables
- type BootloaderConfig
- type Builder
- func (b *Builder) Build(ctx context.Context, w io.WriteSeeker) error
- func (b *Builder) Close() error
- func (b *Builder) KernelUsed() vkern.CalVer
- func (b *Builder) MinimumSize() int64
- func (b *Builder) Prebuild(ctx context.Context, size int64) error
- func (b *Builder) RegionIsHole(begin, size int64) bool
- func (b *Builder) SetDefaultMTU(mtu uint)
- func (b *Builder) Size() int64
- type BuilderArgs
- type FSCompiler
- type GPTEntry
- type GPTHeader
- type KernelOptions
- type ProtectiveMBR
Constants ¶
const ( SemverMajor = 3 SemverMinor = 0 SemverRevision = 0 )
Compiler version constants.
const ( OSReservedSectors = 32 KernelConfigSpaceSectors = 32 )
Various build constants.
const ( SectorSize = 512 GPTSignature = 0x5452415020494645 // "EFI PART" (little-endian) GPTHeaderSize = 92 MaximumGPTEntries = 128 GPTEntrySize = 128 GPTEntriesSectors = MaximumGPTEntries * GPTEntrySize / SectorSize PrimaryGPTHeaderLBA = 1 PrimaryGPTHeaderOffset = SectorSize * PrimaryGPTHeaderLBA PrimaryGPTEntriesLBA = PrimaryGPTHeaderLBA + 1 PrimaryGPTEntriesOffset = SectorSize * PrimaryGPTEntriesLBA P0FirstLBA = PrimaryGPTEntriesLBA + GPTEntriesSectors P0Offset = P0FirstLBA * SectorSize )
Various build constants.
Variables ¶
var ( // OSPartitionName is the hardcoded name for the Vorteil OS partition in the GPT. OSPartitionName = []byte{0x76, 0x0, 0x6f, 0x0, 0x72, 0x0, 0x74, 0x0, 0x65, 0x0, 0x69, 0x0, 0x6c, 0x0, 0x2d, 0x0, 0x6f, 0x0, 0x73, 0x0} // "vorteil-os" in utf16 // RootPartitionName is the hardcoded name for the Vorteil root file-system partition in the GPT. RootPartitionName = []byte{0x76, 0x0, 0x6f, 0x0, 0x72, 0x0, 0x74, 0x0, 0x65, 0x0, 0x69, 0x0, 0x6c, 0x0, 0x2d, 0x0, 0x72, 0x0, 0x6f, 0x0, 0x6f, 0x0, 0x74, 0x0} // "vorteil-root" in utf16 // Part2UUID for second partition. used to define rooot partition in kernel args Part2UUID = []byte{ 0x7d, 0x44, 0x48, 0x40, 0x9d, 0xc0, 0x11, 0xd1, 0xb2, 0x45, 0x5f, 0xfd, 0xce, 0x74, 0xfa, 0xd2, } // Part2UUIDString string value of Part2UUID Part2UUIDString = "4048447D-C09D-D111-B245-5FFDCE74FAD2" )
var ( // Bootloader contains all of the bytes that will be written as the image's bootloader. Bootloader = []byte{}/* 410 elements not displayed */ )
var GetKernel func(ctx context.Context, version vkern.CalVer) (*vkern.ManagedBundle, error)
GetKernel is the function a Builder will use to load a kernel bundle. It must be set externally.
GetLatestKernel is the function a Builder will use to determine what kernel to use if none is specified. It must be set externally.
Functions ¶
This section is empty.
Types ¶
type BootloaderConfig ¶
type BootloaderConfig struct { Version [16]byte // 0 LinuxArgsLen uint16 // 32 ConfigOffset uint64 // 40 ConfigLen uint64 // 48 ConfigCapacity uint64 // 56 LinuxArgs [0x2000]byte // 256 // contains filtered or unexported fields }
BootloaderConfig is the structure of the bootloader config as it appears on the disk.
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder is used for building a raw Vorteil image. Building happens in several stages to make the logic play nicely with potential external logic that needs some back-and-forth control over the build process.
func NewBuilder ¶
func NewBuilder(ctx context.Context, args *BuilderArgs) (*Builder, error)
NewBuilder returns a new Builder object configured according to the provided args. In this state it can calculate the minimum possible image size and accept some minor further configuration. Once this configuration is complete you should call Prebuild on it to proceed.
func (*Builder) Build ¶
Build is the final operation performed by the Builder, and should only be called after a successful call to the Prebuild function. It writes the file-system to the provided io.WriteSeeker, w. Despite using io.Seeker functionality to improve performance, the Builder has been written in a way such that it never needs to seek "backwards", which means you can wrap any io.Writer with a vio.WriteSeeker and it will work.
func (*Builder) KernelUsed ¶
KernelUsed returns the calver the disk was built with
func (*Builder) MinimumSize ¶
MinimumSize returns the minimum number of bytes that are needed to build the image.
func (*Builder) Prebuild ¶
Prebuild locks in a final raw image size (in bytes) and performs some preflight calculations to determine the final disk layout and to make the RegionIsHole function usable by external logic that wants to wrap the image in some sort of sparse virtual disk image format. Prebuild must be called before calling Build.
func (*Builder) RegionIsHole ¶
RegionIsHole can be called after a successful Prebuild. Its purpose is to provide advance notice to sparse disk image formatting logic on regions within the image that will be completely empty. The two args are measured in bytes, and the function returns true if every byte starting at begin and continuing for the full size is zeroed.
func (*Builder) SetDefaultMTU ¶
SetDefaultMTU can be called before calling Prebuild in order to change the default MTU that will be applied to each NIC configuration (if not explicitly set in the VCFG).
type BuilderArgs ¶
type BuilderArgs struct { Seed int64 Kernel KernelOptions FSCompiler FSCompiler VCFG *vcfg.VCFG Logger elog.View }
BuilderArgs collects all of the arguments needed to call NewBuilder into one place.
type FSCompiler ¶
type FSCompiler interface { Mkdir(path string) error AddFile(path string, r io.ReadCloser, size int64, force bool) error IncreaseMinimumFreeSpace(space int64) SetMinimumInodes(inodes int64) SetMinimumInodesPer64MiB(inodes int64) IncreaseMinimumInodes(inodes int64) Commit(ctx context.Context) error MinimumSize() int64 Precompile(ctx context.Context, size int64) error Compile(ctx context.Context, w io.WriteSeeker) error RegionIsHole(begin, size int64) bool }
FSCompiler is an interface that must be satisfied for a file-system compipler to be usable in this logic.
type GPTEntry ¶
type GPTEntry struct { TypeGUID [16]byte PartitionGUID [16]byte FirstLBA uint64 LastLBA uint64 Name [72]byte // contains filtered or unexported fields }
GPTEntry is the structure of a GUID Partition Table entry as it appears on disk.
type GPTHeader ¶
type GPTHeader struct { Signature uint64 Revision [4]byte HeaderSize uint32 CRC uint32 CurrentLBA uint64 BackupLBA uint64 FirstUsableLBA uint64 LastUsableLBA uint64 GUID [16]byte StartLBAParts uint64 NoOfParts uint32 SizePartEntry uint32 CRCParts uint32 // contains filtered or unexported fields }
GPTHeader is the structure of a GUID Partition Table Header as it appears on disk.
type KernelOptions ¶
KernelOptions for settings that change kernel behaviour.