os

package
v0.0.0-...-57ca673 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2016 License: Apache-2.0 Imports: 16 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 BuildEmptyDataVolume

func BuildEmptyDataVolume(size MegaBytes) (string, error)

func BuildRawDataImage

func BuildRawDataImage(dataTar io.ReadCloser, size MegaBytes, usePartitionTables bool) (string, error)

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, imgfile string) error

func CreateBootImageOnFile

func CreateBootImageOnFile(rootFile string, sizeOfFile DiskSize, progPath, commandline string) error

func CreateBootImageWithSize

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

func CreateSingleVolume

func CreateSingleVolume(rootFile string, folder unikutil.RawVolume) error

func CreateVolumes

func CreateVolumes(imgFile string, volumes []unikutil.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 PrepareGrub

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

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) ToPartedFormat

func (s Bytes) ToPartedFormat() string

type DeviceMapperDevice

type DeviceMapperDevice struct {
	DeviceName string
	// contains filtered or unexported fields
}

func (*DeviceMapperDevice) Acquire

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

func (*DeviceMapperDevice) Get

func (*DeviceMapperDevice) Offset

func (p *DeviceMapperDevice) Offset() DiskSize

func (*DeviceMapperDevice) Release

func (p *DeviceMapperDevice) Release() error

func (*DeviceMapperDevice) Size

func (p *DeviceMapperDevice) Size() DiskSize

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) Release

func (p *LoDevice) Release() error

type MegaBytes

type MegaBytes int64

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

type Part

type Part interface {
	Resource

	Size() DiskSize
	Offset() DiskSize

	Get() BlockDevice
}

func ListParts

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

func NewDMPartedPart

func NewDMPartedPart(start, size Sectors, device BlockDevice, partNum int64) Part

Device device name is generated, user can chagne it..

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 Resource

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

func NewDevice

func NewDevice(start, size Sectors, origDevice BlockDevice, deivceName string) Resource

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