Documentation ¶
Overview ¶
Package loop implements an interface to configure Linux loop devices.
This package requires Linux 5.8 or higher because it uses the newer LOOP_CONFIGURE ioctl, which is better-behaved and twice as fast as the old approach. It doesn't support all of the cryptloop functionality as it has been superseded by dm-crypt and has known vulnerabilities. It also doesn't support on-the-fly reconfiguration of loop devices as this is rather unusual, works only under very specific circumstances and would make the API less clean.
Index ¶
Constants ¶
const ( // Makes the loop device read-only even if the backing file is read-write. FlagReadOnly = 1 // Unbinds the backing file as soon as the last user is gone. Useful for // unbinding after unmount. FlagAutoclear = 4 // Enables kernel-side partition scanning on the loop device. Needed if you // want to access specific partitions on a loop device. FlagPartscan = 8 // Enables direct IO for the loop device, bypassing caches and buffer // copying. FlagDirectIO = 16 )
All from @linux//include/uapi/linux:loop.h
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Block size of the loop device in bytes. Power of 2 between 512 and page // size. Zero defaults to an reasonable block size. BlockSize uint32 // Combination of flags from the Flag constants in this package. Flags uint32 // Offset in bytes from the start of the file to the first byte of the // device. Usually zero. Offset uint64 // Maximum size of the loop device in bytes. Zero defaults to the whole // file. SizeLimit uint64 }
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
Device represents a loop device.
func Open ¶
Open opens a loop device at the given path. It returns an error if the path is not a loop device.
func (*Device) BackingFilePath ¶
BackingFilePath returns the path of the backing file
func (*Device) Close ¶
Close closes all file descriptors open to the device. Does not remove the device itself or alter its configuration.
func (*Device) RefreshSize ¶
RefreshSize recalculates the size of the loop device based on the config and the size of the backing file.