loop

package
v0.0.0-...-d691e2b Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package device

Index

Constants

View Source
const (
	// general constants
	NameSize = 64
	KeySize  = 32
	Major    = 7

	// paths
	LoopControlPath = "/dev/loop-control"

	// DeviceFormatString holds the format of loopback devices
	DeviceFormatString = "/dev/loop%d"

	// ioctl commands
	SetFd = 0x4C00
	ClrFd = 0x4C01

	SetStatus64 = 0x4C04

	CtlAdd     = 0x4C80
	CtlRemove  = 0x4C81
	CtlGetFree = 0x4C82
)

Variables

This section is empty.

Functions

func GetLoopDeviceMap

func GetLoopDeviceMap() (map[string][]*Device, error)

Types

type Device

type Device struct {
	Rdev uint64

	IsDeleted bool
	// contains filtered or unexported fields
}

Device represents a loop device /dev/loop#

func Attach

func Attach(backingFile string, offset uint64, ro bool) (Device, error)

Attach attaches backingFile to the loopback device starting at offset. If ro is true, then the file is attached read only.

func GetFree

func GetFree() (Device, error)

GetFree searches for the first free loopback device. If it cannot find one, it will attempt to create one. If anything fails, GetFree will return an error.

func NewDevice

func NewDevice(number uint64, flags int) Device

func (Device) Detach

func (device Device) Detach() error

Detach removes the file backing the device.

func (Device) Path

func (device Device) Path() string

Path returns the path to the loopback device

func (Device) String

func (device Device) String() string

String implements the Stringer interface for Device

type Info

type Info struct {
	Device         uint64
	INode          uint64
	RDevice        uint64
	Offset         uint64
	SizeLimit      uint64
	Number         uint32
	EncryptType    uint32
	EncryptKeySize uint32
	Flags          uint32
	FileName       [NameSize]byte
	CryptName      [NameSize]byte
	EncryptKey     [KeySize]byte
	Init           [2]uint64
}

Info is a datastructure that holds relevant information about a file backed loopback device.

Jump to

Keyboard shortcuts

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