loop

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FlagsReadOnly  = 1
	FlagsAutoClear = 4
	FlagsPartScan  = 8
	FlagsDirectIO  = 16
)

Loop device flags values

View Source
const (
	CryptNone      = 0
	CryptXor       = 1
	CryptDes       = 2
	CryptFish2     = 3
	CryptBlow      = 4
	CryptCast128   = 5
	CryptIdea      = 6
	CryptDummy     = 9
	CryptSkipJack  = 10
	CryptCryptoAPI = 18
	CryptMax       = 20
)

Loop device encryption types

View Source
const (
	CmdSetFd       = 0x4C00
	CmdClrFd       = 0x4C01
	CmdSetStatus   = 0x4C02
	CmdGetStatus   = 0x4C03
	CmdSetStatus64 = 0x4C04
	CmdGetStatus64 = 0x4C05
	CmdChangeFd    = 0x4C06
	CmdSetCapacity = 0x4C07
	CmdSetDirectIO = 0x4C08
)

Loop device IOCTL commands

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

Types

type Device

type Device struct {
	MaxLoopDevices int
	Shared         bool
	Info           *Info64
	// 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.

type Info64

type Info64 struct {
	Device         uint64
	Inode          uint64
	Rdevice        uint64
	Offset         uint64
	SizeLimit      uint64
	Number         uint32
	EncryptType    uint32
	EncryptKeySize uint32
	Flags          uint32
	FileName       [64]byte
	CryptName      [64]byte
	EncryptKey     [32]byte
	Init           [2]uint64
}

Info64 contains information about a loop device.

func GetStatusFromFd

func GetStatusFromFd(fd uintptr) (*Info64, error)

GetStatusFromFd gets info status about an opened loop device

func GetStatusFromPath

func GetStatusFromPath(path string) (*Info64, error)

GetStatusFromPath gets info status about a loop device from path

Jump to

Keyboard shortcuts

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