os

package
v0.0.0-...-937b75d Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const DeviceMapFile = `(hd0) {{.GrubDevice}}
`
View Source
const GrubTemplate = `default=0
fallback=1
timeout=1
hiddenmenu

title Unik
root {{.RootDrive}}
kernel /boot/program.bin {{.CommandLine}}
`
View Source
const ProgramName = "program.bin"
View Source
const SectorSize = 512

Variables

This section is empty.

Functions

func CopyDir

func CopyDir(source string, dest string) (err error)

func CopyFile

func CopyFile(src, dst string) error

CopyFile copies a file from src to dst. If src and dst files exist, and are the same, then return success. Otherise, attempt to create a hard link between the two files. If that fail, copy the file contents from src to dst.

func CopyToImgFile

func CopyToImgFile(folder, volType string, imgfile string) error

func CreateBootImageOnFile

func CreateBootImageOnFile(rootFile string, progPath, staticFilesDir, commandline string) error

func CreateBootImageOnFilePvGrub

func CreateBootImageOnFilePvGrub(rootFile string, progPath, staticFilesDir, commandline string) error

func CreateBootImageWithSize

func CreateBootImageWithSize(rootFile string, size DiskSize, progPath, staticFilesDir, commandline string, usePartitionTables bool) error

func CreateSingleVolume

func CreateSingleVolume(rootFile string, volType string, folder RawVolume) error

func CreateVolumes

func CreateVolumes(imgFile string, volType string, volumes []RawVolume, newPartitioner func(device string) Partitioner) error

func ExtractTar

func ExtractTar(tarArchive io.ReadCloser, localFolder string) error

func GetDirSize

func GetDirSize(dir string) (int64, error)

func IsExists

func IsExists(f string) bool

func Mount

func Mount(device BlockDevice) (mntpoint string, err error)

func MountDevice

func MountDevice(device string) (mntpoint string, err error)

func PrepareGrub

func PrepareGrub(folder, rootDeviceName, kernel, staticFilesDir, commandline string) error

func PreparePVGrub

func PreparePVGrub(folder, rootDeviceName, kernel, staticFilesDir, commandline string) error

func RandStringBytes

func RandStringBytes(n int) string

func RunLogCommand

func RunLogCommand(name string, args ...string) error

func Umount

func Umount(point string) error

Types

type BlockDevice

type BlockDevice string

func (BlockDevice) Name

func (b BlockDevice) Name() string

type Bytes

type Bytes int64

func (Bytes) ToBytes

func (s Bytes) ToBytes() Bytes

func (Bytes) ToMegaBytes

func (s Bytes) ToMegaBytes() MegaBytes

ToMegaBytes returns lowest whole number of size_MB so that size_MB >= (size_B / 1024^2)

func (Bytes) ToPartedFormat

func (s Bytes) ToPartedFormat() string

type DiskLabelPartioner

type DiskLabelPartioner struct {
	Device string
}

func (*DiskLabelPartioner) MakePart

func (m *DiskLabelPartioner) MakePart(partType string, start, size DiskSize) error

func (*DiskLabelPartioner) MakeTable

func (m *DiskLabelPartioner) MakeTable() error

type DiskSize

type DiskSize interface {
	ToPartedFormat() string
	ToBytes() Bytes
}

type GigaBytes

type GigaBytes int64

func (GigaBytes) ToBytes

func (s GigaBytes) ToBytes() Bytes

func (GigaBytes) ToPartedFormat

func (s GigaBytes) ToPartedFormat() string

type LoDevice

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

TODO: change this to api; like in here: https://www.versioneye.com/python/losetup/2.0.7 or here https://github.com/karelzak/util-linux/blob/master/sys-utils/losetup.c

func (*LoDevice) Acquire

func (p *LoDevice) Acquire() (BlockDevice, error)

func (*LoDevice) Get

func (p *LoDevice) Get() BlockDevice

func (*LoDevice) Offset

func (p *LoDevice) Offset() DiskSize

func (*LoDevice) Release

func (p *LoDevice) Release() error

func (*LoDevice) Size

func (p *LoDevice) Size() DiskSize

type MegaBytes

type MegaBytes int64

func ParseSize

func ParseSize(sizeStr string) (MegaBytes, error)

ParseSize parses disk size string (e.g. "10GB" or "150MB") into MegaBytes If no unit string is provided, megabytes are assumed

func (MegaBytes) ToBytes

func (s MegaBytes) ToBytes() Bytes

func (MegaBytes) ToPartedFormat

func (s MegaBytes) ToPartedFormat() string

type MsDosPartioner

type MsDosPartioner struct {
	Device string
}

func (*MsDosPartioner) MakePart

func (m *MsDosPartioner) MakePart(partType string, start, size DiskSize) error

func (*MsDosPartioner) MakePartTillEnd

func (m *MsDosPartioner) MakePartTillEnd(partType string, start DiskSize) error

func (*MsDosPartioner) MakeTable

func (m *MsDosPartioner) MakeTable() error

func (*MsDosPartioner) Makebootable

func (m *MsDosPartioner) Makebootable(partnum int) error

type Part

type Part interface {
	Resource

	Size() DiskSize
	Offset() DiskSize

	Get() BlockDevice
}

func ListParts

func ListParts(device BlockDevice) ([]Part, error)

func NewPartLoDevice

func NewPartLoDevice(device string, offset DiskSize, size DiskSize) Part

type PartedPart

type PartedPart struct {
	Device BlockDevice
	// contains filtered or unexported fields
}

func (*PartedPart) Acquire

func (p *PartedPart) Acquire() (BlockDevice, error)

func (*PartedPart) Get

func (p *PartedPart) Get() BlockDevice

func (*PartedPart) Offset

func (p *PartedPart) Offset() DiskSize

func (*PartedPart) Release

func (p *PartedPart) Release() error

func (*PartedPart) Size

func (p *PartedPart) Size() DiskSize

type Partitioner

type Partitioner interface {
	MakeTable() error
	MakePart(partType string, start, size DiskSize) error
}

type RawVolume

type RawVolume struct {
	Path string `json:"Path"`
	Size int64  `json:"Size"`
}

type Resource

type Resource interface {
	Acquire() (BlockDevice, error)
	Release() error
}

func NewLoDevice

func NewLoDevice(device string) Resource

type Sectors

type Sectors int64

func ToSectors

func ToSectors(b DiskSize) (Sectors, error)

func (Sectors) ToBytes

func (s Sectors) ToBytes() Bytes

func (Sectors) ToPartedFormat

func (s Sectors) ToPartedFormat() string

Jump to

Keyboard shortcuts

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