loopback

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2022 License: MIT Imports: 4 Imported by: 0

README

go-loopback

GoDoc

Go Report Card

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Loop

func Loop(loopbackDevice, image *os.File) error

Loop will, when given a handle to a Loopback device (such as /dev/loop0), and a handle to the fs image to loop mount (such as a squashfs or ext4fs image), preform the required call to loop the image to the provided block device.

The first argument (loopbackDevice) can be obtained using loopback.NextLoopDevice, if one is not known in advance.

func NextLoopDevice

func NextLoopDevice() (*os.File, error)

NextLoopDevice will return the next loopback device that isn't used. Under the hood this will ask loop-control for the LOOP_CTL_GET_FREE value, and interpolate that into the conventional GNU/Linux naming scheme for loopback devices, and os.Open that path.

func Unloop

func Unloop(loopbackDevice *os.File) error

Unloop will, given a handle to the Loopback device (such as /dev/loop0), preform the required call to the image to unloop the image mounted at that location.

Types

type UnmounterFunc added in v0.1.3

type UnmounterFunc func()

UnmounterFunc will unmount the filesystem, unloop the file, and close the held file descriptor. Be sure this is defer'ed in a sensible location!

func MountImage

func MountImage(
	image *os.File,

	target string,
	fstype string,
	flags uintptr,
	data string,
) (*os.File, UnmounterFunc, error)

MountImage will get the next loopback device that isn't used, loopback the provided image, and mount the loopback device to the target.

Jump to

Keyboard shortcuts

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