Skip to content

io.systemd.StorageProvider

Storage Provider API, a generic interface for acquiring access to storage volumes

Property Value
Go package github.com/rossedman/sdvarlink/systemd/latest/storageprovider
Available since systemd v262
Methods · types · errors 3 · 2 · 9

Methods

Acquire

Acquires a file descriptor for a storage volume.

func (c *Client) Acquire(ctx context.Context, in AcquireIn) (*AcquireOut, error)

Parameters

Field Type Description
name string The name of the storage volume to acquire
createMode ?CreateMode Determines whether to open or create a storage volume
template ?string The template to use when creating a new storage volume
readOnly ?bool Controls read/write access to the storage volume. If false and the storage volume cannot be opened in writable mode the call will fail. If null, storage volume will be acquired in writable mode if possible, read-only otherwise. If true, storage volume will be opened in read-only mode (and fail if that's not possible).
requestAs ?VolumeType Dictates what kind of storage volume to request. Some storage volumes can be acquired either as regular file or as block device. In all other cases if this value doesn't match the volume type, the request will fail.
createSizeBytes ?int The size of the storage volume, if one is created. Has no effect if no storage volume is created.
allowInteractiveAuthentication ?bool Controls whether interactive authentication (via polkit) shall be allowed. If unspecified defaults to false.

Reply

Field Type Description
fileDescriptorIndex int Returns an index into the array of file descriptors associated with this reply. This may be used to get the file descriptor of the volume. The file descriptor must be properly opened, i.e. not an O_PATH file descriptor.
type VolumeType The storage volume type, i.e. ultimately the inode type of the returned file descriptor
readOnly bool Whether storage volume has been opened in read-only mode
baseUID ?int Base UID for the returned file descriptor (if directory). If not specified shall default to 0.
baseGID ?int Base GID for the returned file descriptor (if directory). If not specified shall default to 0.

ListVolumes

streaming (requires more)

Lists available storage volumes.

func (c *Client) ListVolumes(ctx context.Context, in ListVolumesIn) iter.Seq2[*ListVolumesOut, error]

Parameters

Field Type Description
matchName ?string Specifies a shell glob to filter enumeration by

Reply

Field Type Description
name string The storage volume's primary name
aliases ?[]string Additional names
type VolumeType The type of the storage volume
readOnly ?bool Whether the storage volume is read-only.
sizeBytes ?int Size in bytes, if known
usedBytes ?int Used bytes, if known

ListTemplates

streaming (requires more)

Lists available templates.

func (c *Client) ListTemplates(ctx context.Context, in ListTemplatesIn) iter.Seq2[*ListTemplatesOut, error]

Parameters

Field Type Description
matchName ?string Specifies a shell glob to filter enumeration by

Reply

Field Type Description
name string The template's name
type VolumeType The type of the storage volumes defined by this template

Types

VolumeType

Encodes three classes of storage volumes. This follows the kernel's nomenclature for inode types, i.e. reg, dir, blk.

Value Description
blk Block device storage volumes, block-addressable
reg Regular file storage volumes, byte-addressable
dir POSIX file system storage volumes, path/offset-addressable

CreateMode

Determines whether to open existing or create a new storage volume.

Value Description
any Open if exists already, create if missing
new Create if missing, fail if exists already
open Open if exists already, fail if missing

Errors

Error Go type Description
NoSuchVolume NoSuchVolumeError No storage volume under the specified name exists.
VolumeExists VolumeExistsError A storage volume under the specified name already exists.
NoSuchTemplate NoSuchTemplateError No template under the specified name exists.
TypeNotSupported TypeNotSupportedError The specified volume type is not supported by this backend or system.
WrongType WrongTypeError The volume's type does not match the requested volume type.
CreateNotSupported CreateNotSupportedError This backend does not support storage volume creation of the requested type.
CreateSizeRequired CreateSizeRequiredError This backend or selected volume type requires a storage volume size to be specified if the storage volume does not exist yet and needs to be created.
ReadOnlyVolume ReadOnlyVolumeError A storage volume was to be acquired in writable mode, but only read-only access is permitted.
BadTemplate BadTemplateError Template not suitable for this storage volume type.