mount

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2021 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockDevice

type BlockDevice struct {
	// nbd1
	Name string `json:"name"`
	// 512
	LogSec int `json:"log-sec"`
	// gpt
	Pttype string `json:"pttype"`
	// Child partitions of a device.
	Partitions []Child `json:"children"`
}

BlockDevice a unique device in lsblk output.

type Child

type Child struct {
	// nbd1p1
	Name string `json:"name"`
	// 0fc63daf-8483-4772-8e79-3d69d8477de4
	Parttype string `json:"parttype"`
	// Linux filesystem
	Parttypename string `json:"parttypename"`
	// ext4
	Fstype string `json:"fstype"`
	// cloudimg-rootfs
	Label string `json:"label"`
}

Child details each partition of a device.

type Chroot

type Chroot struct {
	MountPoint string
}

Chroot details about the chroot storing the image.

func (*Chroot) Exec

func (c *Chroot) Exec(args []string) error

Exec a command in the image.

func (*Chroot) Pull

func (c *Chroot) Pull(srcPath string, destPath string) error

Pull takes a file from the image to the users' system.

func (*Chroot) Push

func (c *Chroot) Push(srcPath string, destPath string) error

Push takes a file from the user's system to the image.

func (*Chroot) Run

func (c *Chroot) Run(scriptPath string) error

Run a command on the image.

func (*Chroot) Shell

func (c *Chroot) Shell(shell string) error

Shell into the image.

type Image

type Image struct {
	Filename string `json:"filename"`

	// Settings used during mounting the image.
	PartNum     int  `json:"-"`
	NoSysDNS    bool `json:"-"`
	NoSysMounts bool `json:"-"`
	ReadOnly    bool `json:"-"`

	// Used to manipulate the image.
	MountPoint string `json:"-"`
	NBD        NBD    `json:"-"`

	// Information about the image and its' partitions.
	ImageFormat    string      `json:"image-format"`
	PartitionTable string      `json:"partition-table"`
	Size           string      `json:"size"`
	VirtualSize    string      `json:"virtual-size"`
	SectorSize     int         `json:"sector-size"`
	Partitions     []Partition `json:"partitions"`
}

Image is the user's main control point for manipulating the image.

func (*Image) Info

func (i *Image) Info(jsonOutput bool) (string, error)

Info returns JSON or formatted string with details about the image.

func (*Image) Mount

func (i *Image) Mount() (Chroot, error)

Mount does the heavy lifting to get the image ready and returns a chroot.

func (*Image) Unmount

func (i *Image) Unmount() error

Unmount undos all the options during mounting.

type Lsblk

type Lsblk struct {
	LsblkDevices []BlockDevice `json:"blockdevices"`
}

Lsblk captures the JSON output of lsblk command.

type NBD

type NBD struct {
	// /sys/block/nbd0
	BlockPath string
	// /dev/nbd0
	DevicePath string
	// nbd0
	Name string
	// PID of the nbd device
	PID string
	// /sys/block/nbd0/pid
	PIDFile string
}

NBD collects details about the used NBD device.

func (*NBD) Connect

func (n *NBD) Connect(image string, format string) error

Connect a given image.

func (*NBD) Disconnect

func (n *NBD) Disconnect() error

Disconnect the NBD device from qemu-nbd to free it.

type Partition

type Partition struct {
	Name       string `json:"name"`
	Type       string `json:"type"`
	Label      string `json:"label"`
	Filesystem string `json:"filesystem"`
}

Partition captures info about each partition in an image.

type QEMUImgInfo

type QEMUImgInfo struct {
	// Filename analyzed
	Filename string `json:"filename"`

	// Type of image (e.g. qcow2, raw, etc.)
	Format string `json:"format"`

	// Physical size of the disk (e.g. 550637568)
	ActualSize int64 `json:"actual-size"`

	// Virtual size of the disk (e.g. 2361393152)
	VirtualSize int64 `json:"virtual-size"`
}

QEMUImgInfo captures qemu-img JSON output.

e.g. qemu-img info --output=json focal-server-cloudimg-amd64.img

Jump to

Keyboard shortcuts

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