Documentation ¶
Index ¶
- Constants
- func Compress(source, destination string) error
- func CopyDir(source string, dest string) (err error)
- func CopyFile(src, dst string) error
- func CopyToImgFile(folder, volType string, imgfile string) error
- func CreateBootImageOnFile(rootFile string, progPath, staticFilesDir, commandline string) error
- func CreateBootImageOnFilePvGrub(rootFile string, progPath, staticFilesDir, commandline string) error
- func CreateBootImageWithSize(rootFile string, size DiskSize, progPath, staticFilesDir, commandline string, ...) error
- func CreateSingleVolume(rootFile string, volType string, folder RawVolume) error
- func CreateVolumes(imgFile string, volType string, volumes []RawVolume, ...) error
- func DirSize(path string) (int64, error)
- func ExtractTar(tarArchive io.ReadCloser, localFolder string) error
- func GetDirSize(dir string) (int64, error)
- func IsExists(f string) bool
- func Mount(device BlockDevice) (mntpoint string, err error)
- func MountDevice(device string) (mntpoint string, err error)
- func PrepareGrub(folder, rootDeviceName, kernel, staticFilesDir, commandline string) error
- func PreparePVGrub(folder, rootDeviceName, kernel, staticFilesDir, commandline string) error
- func RandStringBytes(n int) string
- func RunLogCommand(name string, args ...string) error
- func Umount(point string) error
- type BlockDevice
- type Bytes
- type DiskLabelPartioner
- type DiskSize
- type GigaBytes
- type LoDevice
- type MegaBytes
- type MsDosPartioner
- type Part
- type PartedPart
- type Partitioner
- type RawVolume
- type Resource
- type Sectors
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 CopyFile ¶
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 CreateBootImageOnFile ¶
func CreateBootImageWithSize ¶
func CreateSingleVolume ¶
func CreateVolumes ¶
func ExtractTar ¶
func ExtractTar(tarArchive io.ReadCloser, localFolder string) error
func GetDirSize ¶
func Mount ¶
func Mount(device BlockDevice) (mntpoint string, err error)
func MountDevice ¶
func PrepareGrub ¶
func PreparePVGrub ¶
func RandStringBytes ¶
func RunLogCommand ¶
Types ¶
type BlockDevice ¶
type BlockDevice string
func (BlockDevice) Name ¶
func (b BlockDevice) Name() string
type Bytes ¶
type Bytes int64
func (Bytes) ToMegaBytes ¶
ToMegaBytes returns lowest whole number of size_MB so that size_MB >= (size_B / 1024^2)
func (Bytes) ToPartedFormat ¶
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 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
type MegaBytes ¶
type MegaBytes int64
func ParseSize ¶
ParseSize parses disk size string (e.g. "10GB" or "150MB") into MegaBytes If no unit string is provided, megabytes are assumed
func (MegaBytes) ToPartedFormat ¶
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)
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 Resource ¶
type Resource interface { Acquire() (BlockDevice, error) Release() error }
func NewLoDevice ¶
Click to show internal directories.
Click to hide internal directories.