loop

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CmdCtlAdd     = 0x4C80
	CmdCtlRemove  = 0x4C81
	CmdCtlGetFree = 0x4C82
)

Loop control device IOCTL commands

Variables

This section is empty.

Functions

func GetMaxLoopDevices

func GetMaxLoopDevices() int

GetMaxLoopDevices Return the maximum number of loop devices allowed

func GetStatusFromFd

func GetStatusFromFd(fd uintptr) (*unix.LoopInfo64, error)

GetStatusFromFd gets info status about an opened loop device

func GetStatusFromPath

func GetStatusFromPath(path string) (*unix.LoopInfo64, error)

GetStatusFromPath gets info status about a loop device from path

Types

type Device

type Device struct {
	MaxLoopDevices int
	Shared         bool
	Info           *unix.LoopInfo64
	// contains filtered or unexported fields
}

Device describes a loop device

func (*Device) AttachFromFile

func (loop *Device) AttachFromFile(image *os.File, mode int, number *int) error

AttachFromFile attempts to find a suitable loop device to use for the specified image. It runs through /dev/loopXX, up to MaxLoopDevices to find a free loop device, or to share a loop device already associated to file (if shared loop devices are enabled). If a usable loop device is found, then loop.Fd is set and no error is returned. If a usable loop device is not found, and this is due to a transient EAGAIN / EBUSY error, then it will retry up to maxRetries times, retryInterval apart, before returning an error.

func (*Device) AttachFromPath

func (loop *Device) AttachFromPath(image string, mode int, number *int) error

AttachFromPath finds a free loop device, opens it, and stores file descriptor of opened image path

func (*Device) Close

func (loop *Device) Close() error

Close closes the loop device.

Jump to

Keyboard shortcuts

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