loop

package
v0.0.0-...-d005ad2 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2018 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	/*
	 * IOCTL commands --- we will commandeer 0x4C ('L')
	 */
	LOOP_SET_CAPACITY = 0x4C07
	LOOP_CHANGE_FD    = 0x4C06
	LOOP_GET_STATUS64 = 0x4C05
	LOOP_SET_STATUS64 = 0x4C04
	LOOP_GET_STATUS   = 0x4C03
	LOOP_SET_STATUS   = 0x4C02
	LOOP_CLR_FD       = 0x4C01
	LOOP_SET_FD       = 0x4C00
	LO_NAME_SIZE      = 64
	LO_KEY_SIZE       = 32
	/* /dev/loop-control interface */
	LOOP_CTL_ADD      = 0x4C80
	LOOP_CTL_REMOVE   = 0x4C81
	LOOP_CTL_GET_FREE = 0x4C82
)

Variables

This section is empty.

Functions

func ClearFd

func ClearFd(fd uintptr) error

ClearFd clears the loop device associated with filedescriptor fd.

func ClearFdFile

func ClearFdFile(devicename string) error

ClearFdFile clears the loop device "devicename"

func CtlGetFree

func CtlGetFree(fd uintptr) (uintptr, error)

CtlGetFree finds a free loop device querying the loop control device pointed by fd. It returns the number of the free loop device /dev/loopX

func FindDevice

func FindDevice() (name string, err error)

FindDevice finds an unused loop device.

func New

func New(source, target, fstype string, flags uintptr, data string) (mount.Mounter, error)

New initializes a Loop struct and allocates a loodevice to it.

func SetFd

func SetFd(lfd, ffd uintptr) error

SetFd associates a loop device pointed by lfd with a regular file pointed by ffd.

func SetFdFiles

func SetFdFiles(devicename, filename string) error

SetFdFiles associates loop device "devicename" with regular file "filename"

Types

type Loop

type Loop struct {
	Dev     string
	Source  string
	Dir     string
	FStype  string
	Flags   uintptr
	Data    string
	Mounted bool
}

Loop implements mount.Mount

func (*Loop) Mount

func (l *Loop) Mount() error

Mount mounts the provided source file, with type fstype, and flags and data options (which are usually 0 and ""), using any available loop device.

func (*Loop) Unmount

func (l *Loop) Unmount(flags int) error

Unmount unmounts and frees a loop. If it is mounted, it will try to unmount it. If the unmount fails, we try to free it anyway, after trying a more forceful unmount. We don't log errors, but we do return a concatentation of whatever errors occur.

Jump to

Keyboard shortcuts

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