devmapper

package
v1.32.5 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2021 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(home string, options graphdriver.Options) (graphdriver.Driver, error)

Init creates a driver with the given home and the set of options.

func Mounted

func Mounted(mountpoint string) (bool, error)

Mounted returns true if a mount point exists.

func ProbeFsType

func ProbeFsType(device string) (string, error)

ProbeFsType returns the filesystem name for the given device id.

Types

type DevStatus

type DevStatus struct {
	// DeviceID is the id of the device.
	DeviceID int
	// Size is the size of the filesystem.
	Size uint64
	// TransactionID is a unique integer per device set used to identify an operation on the file system, this number is incremental.
	TransactionID uint64
	// SizeInSectors indicates the size of the sectors allocated.
	SizeInSectors uint64
	// MappedSectors indicates number of mapped sectors.
	MappedSectors uint64
	// HighestMappedSector is the pointer to the highest mapped sector.
	HighestMappedSector uint64
}

DevStatus returns information about device mounted containing its id, size and sector information.

type DeviceSet

type DeviceSet struct {
	sync.Mutex `json:"-"` // Protects all fields of DeviceSet and serializes calls into libdevmapper

	TransactionID uint64 `json:"-"`
	NextDeviceID  int    `json:"next_device_id"`

	BaseDeviceUUID       string // save UUID of base device
	BaseDeviceFilesystem string // save filesystem of base device
	// contains filtered or unexported fields
}

DeviceSet holds information about list of devices

func NewDeviceSet

func NewDeviceSet(root string, doInit bool, options []string, uidMaps, gidMaps []idtools.IDMap) (*DeviceSet, error)

NewDeviceSet creates the device set based on the options provided.

func (*DeviceSet) AddDevice

func (devices *DeviceSet) AddDevice(hash, baseHash string, storageOpt map[string]string) error

AddDevice adds a device and registers in the hash.

func (*DeviceSet) DataDevicePath

func (devices *DeviceSet) DataDevicePath() string

DataDevicePath returns the path to the data storage for this deviceset, regardless of loopback or block device

func (*DeviceSet) DeleteDevice

func (devices *DeviceSet) DeleteDevice(hash string, syncDelete bool) error

DeleteDevice will return success if device has been marked for deferred removal. If one wants to override that and want DeleteDevice() to fail if device was busy and could not be deleted, set syncDelete=true.

func (*DeviceSet) GetDeviceStatus

func (devices *DeviceSet) GetDeviceStatus(hash string) (*DevStatus, error)

GetDeviceStatus provides size, mapped sectors

func (*DeviceSet) HasDevice

func (devices *DeviceSet) HasDevice(hash string) bool

HasDevice returns true if the device metadata exists.

func (*DeviceSet) List

func (devices *DeviceSet) List() []string

List returns a list of device ids.

func (*DeviceSet) MetadataDevicePath

func (devices *DeviceSet) MetadataDevicePath() string

MetadataDevicePath returns the path to the metadata storage for this deviceset, regardless of loopback or block device

func (*DeviceSet) MountDevice

func (devices *DeviceSet) MountDevice(hash, path string, moptions graphdriver.MountOpts) error

MountDevice mounts the device if not already mounted.

func (*DeviceSet) ResizePool

func (devices *DeviceSet) ResizePool(size int64) error

ResizePool increases the size of the pool.

func (*DeviceSet) Shutdown

func (devices *DeviceSet) Shutdown(home string) error

Shutdown shuts down the device by unmounting the root.

func (*DeviceSet) Status

func (devices *DeviceSet) Status() *Status

Status returns the current status of this deviceset

func (*DeviceSet) UnmountDevice

func (devices *DeviceSet) UnmountDevice(hash, mountPath string) error

UnmountDevice unmounts the device and removes it from hash.

type DiskUsage

type DiskUsage struct {
	// Used bytes on the disk.
	Used uint64
	// Total bytes on the disk.
	Total uint64
	// Available bytes on the disk.
	Available uint64
}

DiskUsage contains information about disk usage and is used when reporting Status of a device.

type Driver

type Driver struct {
	*DeviceSet
	// contains filtered or unexported fields
}

Driver contains the device set mounted and the home directory

func (*Driver) AdditionalImageStores

func (d *Driver) AdditionalImageStores() []string

AdditionalImageStores returns additional image stores supported by the driver

func (*Driver) Cleanup

func (d *Driver) Cleanup() error

Cleanup unmounts a device.

func (*Driver) Create

func (d *Driver) Create(id, parent string, opts *graphdriver.CreateOpts) error

Create adds a device with a given id and the parent.

func (*Driver) CreateFromTemplate

func (d *Driver) CreateFromTemplate(id, template string, templateIDMappings *idtools.IDMappings, parent string, parentIDMappings *idtools.IDMappings, opts *graphdriver.CreateOpts, readWrite bool) error

CreateFromTemplate creates a layer with the same contents and parent as another layer.

func (*Driver) CreateReadWrite

func (d *Driver) CreateReadWrite(id, parent string, opts *graphdriver.CreateOpts) error

CreateReadWrite creates a layer that is writable for use as a container file system.

func (*Driver) Exists

func (d *Driver) Exists(id string) bool

Exists checks to see if the device exists.

func (*Driver) Get

func (d *Driver) Get(id string, options graphdriver.MountOpts) (string, error)

Get mounts a device with given id into the root filesystem

func (*Driver) Metadata

func (d *Driver) Metadata(id string) (map[string]string, error)

Metadata returns a map of information about the device.

func (*Driver) Put

func (d *Driver) Put(id string) error

Put unmounts a device and removes it.

func (*Driver) ReadWriteDiskUsage added in v0.46.1

func (d *Driver) ReadWriteDiskUsage(id string) (*directory.DiskUsage, error)

ReadWriteDiskUsage returns the disk usage of the writable directory for the ID. For devmapper, it queries the mnt path for this ID.

func (*Driver) Remove

func (d *Driver) Remove(id string) error

Remove removes a device with a given id, unmounts the filesystem, and removes the mount point.

func (*Driver) Status

func (d *Driver) Status() [][2]string

Status returns the status about the driver in a printable format. Information returned contains Pool Name, Data File, Metadata file, disk usage by the data and metadata, etc.

func (*Driver) String

func (d *Driver) String() string

type Status

type Status struct {
	// PoolName is the name of the data pool.
	PoolName string
	// DataFile is the actual block device for data.
	DataFile string
	// DataLoopback loopback file, if used.
	DataLoopback string
	// MetadataFile is the actual block device for metadata.
	MetadataFile string
	// MetadataLoopback is the loopback file, if used.
	MetadataLoopback string
	// Data is the disk used for data.
	Data DiskUsage
	// Metadata is the disk used for meta data.
	Metadata DiskUsage
	// BaseDeviceSize is base size of container and image
	BaseDeviceSize uint64
	// BaseDeviceFS is backing filesystem.
	BaseDeviceFS string
	// SectorSize size of the vector.
	SectorSize uint64
	// UdevSyncSupported is true if sync is supported.
	UdevSyncSupported bool
	// DeferredRemoveEnabled is true then the device is not unmounted.
	DeferredRemoveEnabled bool
	// True if deferred deletion is enabled. This is different from
	// deferred removal. "removal" means that device mapper device is
	// deactivated. Thin device is still in thin pool and can be activated
	// again. But "deletion" means that thin device will be deleted from
	// thin pool and it can't be activated again.
	DeferredDeleteEnabled      bool
	DeferredDeletedDeviceCount uint
	MinFreeSpace               uint64
}

Status returns the information about the device.

Jump to

Keyboard shortcuts

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