loop

package
v6.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2019 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package loop provides an interface to interacting with Linux loop devices.

A loop device exposes a regular file as if it were a block device.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearFD

func ClearFD(fd int) error

ClearFD clears the loop device associated with file descriptor fd.

func ClearFile

func ClearFile(devicename string) error

ClearFile clears the fd association of the loop device "devicename".

func FindDevice

func FindDevice() (string, error)

FindDevice finds an unused loop device and returns its /dev/loopN path.

func GetFree

func GetFree(fd int) (int, error)

GetFree finds a free loop device /dev/loopN.

fd must be a loop control device.

It returns the number of the free loop device /dev/loopN. The _LOOP_CTL_GET_FREE does not follow the rules. Values of 0 or greater are the number of the device; less than zero is an error. So you can not use unix.IoctlGetInt as it assumes the return value is stored in a pointer in the normal style. Yuck.

func New

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

New initializes a Loop struct and allocates a loop device to it.

source is the file to use as a loop block device. fstype the file system name. data is the data argument to the mount(2) syscall.

func SetFD

func SetFD(lfd, ffd int) error

SetFD associates a loop device lfd with a regular file ffd.

func SetFile

func SetFile(devicename, filename string) error

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

Types

type Loop

type Loop struct {
	// Dev is the loop device path.
	Dev string

	// Source is the regular file to use as a block device.
	Source string

	// FSType is the file system to use when mounting the block device.
	FSType string

	// Data is the data to pass to mount(2).
	Data string

	// Mounted indicates whether the device has been mounted.
	Mounted bool
	// contains filtered or unexported fields
}

Loop represents a regular file exposed as a loop block device.

Loop implements mount.Mounter.

func (*Loop) Mount

func (l *Loop) Mount(path string, flags uintptr) error

Mount mounts the provided source file, with type fstype, and flags and data options (which are usually 0 and ""), using the allocated 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.

Jump to

Keyboard shortcuts

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