Skip to content

io.systemd.MountFileSystem

APIs for unprivileged mounting.

Property Value
Go package github.com/rossedman/sdvarlink/systemd/latest/mountfilesystem
Socket /run/systemd/io.systemd.MountFileSystem
Available since systemd v257
Methods · types · errors 3 · 3 · 7

Methods

MountImage

passes file descriptors

Takes a disk image file descriptor as input, returns a set of mount file descriptors for it, plus meta information about the image and the partitions selected for mounting.

func (c *Client) MountImage(ctx context.Context, in MountImageIn) (*MountImageOut, error)

Parameters

Field Type Description
imageFileDescriptor int File descriptor of the image file to mount and to assign to the user namespace. Must be a regular, i.e. non-O_PATH file descriptor.
userNamespaceFileDescriptor ?int File descriptor to the user namespace to assign this image to. If not specified uses the host user namespace.
readOnly ?bool Mounts the image read-only.
growFileSystems ?bool Grows the contained file systems if necessary and indicated, before mounting them.
password ?string Takes a literal password in case of an encrypted image
imagePolicy ?string Takes an image policy string (see systemd.image-policy(7) for details) to apply while mounting the image
mountOptions ?[string]string The mount options to be used for the partitions of the image, keyed by the partition designator. Requires elevated privileges via polkit if specified, the polkit request details will list them in the 'mount_options' field.
relaxExtensionReleaseChecks ?bool Whether to relax the extension release checks when mounting the image.
veritySharing ?bool Whether to automatically reuse already set up dm-verity devices that share the same roothash.
verityDataFileDescriptor ?int File descriptor of the file containing the dm-verity data, if the image is a bare filesystem rather than a DDI.
verityRootHash ?string The expected dm-verity root hash as an hex encoded string, if the image is a bare filesystem rather than a DDI.
verityRootHashSignature ?string The expected signature for the dm-verity root hash as a Base64 encoded string, if the image is a bare filesystem rather than a DDI.
allowInteractiveAuthentication ?bool Controls whether interactive authentication (via polkit) shall be allowed. If unspecified defaults to false.

Reply

Field Type Description
partitions []PartitionInfo An array with information about contained partitions that have been prepared for mounting, as well as their mount file descriptors.
singleFileSystem bool Indicates whether the image contains only a single file system, i.e. no partition table.
imagePolicy string The used image policy.
imageSize int The size of the image in bytes.
sectorSize int The sector size of the image in bytes
imageName ?string The name of the image
imageUuid ?string The UUID of the image

MountDirectory

since v258 · passes file descriptors

Takes a directory file descriptor as input, returns a mount file descriptor.

func (c *Client) MountDirectory(ctx context.Context, in MountDirectoryIn) (*MountDirectoryOut, error)

Parameters

Field Type Description
directoryFileDescriptor int Directory file descriptor of the directory to assign to the user namespace. Must be a regular, i.e. non-O_PATH file descriptor.
userNamespaceFileDescriptor ?int File descriptor to the user namespace to assign this directory to. If not specified uses the host user namespace.
readOnly ?bool Whether to mark the resulting mount file descriptor as read-only. If not specified defaults to false.
mode ?MountMapMode Which kind of UID/GID mapping to apply to the resulting mount file descriptor.
allowInteractiveAuthentication ?bool Controls whether interactive authentication (via polkit) shall be allowed. If unspecified defaults to false.

Reply

Field Type Description
mountFileDescriptor int The freshly allocated mount file descriptor for the mount.

MakeDirectory

since v258 · passes file descriptors

Creates an empty directory, owned by the foreign UID/GID range's root user, returns an open file descriptor to the directory. Access mode will be set to 0700.

func (c *Client) MakeDirectory(ctx context.Context, in MakeDirectoryIn) (*MakeDirectoryOut, error)

Parameters

Field Type Description
parentFileDescriptor int File descriptor of the directory to create the new directory in. Must be a regular, i.e. non-O_PATH file descriptor.
name string Name of the directory to create.
mode ?int Access mode of the directory to create. Note that the suid, sgid, sticky, world-writable bit is unconditionally masked off.
allowInteractiveAuthentication ?bool Controls whether interactive authentication (via polkit) shall be allowed. If unspecified defaults to false.

Reply

Field Type Description
directoryFileDescriptor int File descriptor referencing the newly created directory.

Types

PartitionDesignator

Encodes the designated purpose of a partition.

Value Description
root
usr
home
srv
esp
xbootldr
swap
root_verity
usr_verity
root_verity_sig
usr_verity_sig
tmp
var

MountMapMode

Selects the type of UID/GID mapping to apply.

Value Description
root Map the caller's UID to root in the user namespace, do not map anything else.
foreign Map the foreign UID range to the base UID range in the user namespace (i.e. UID zero and above), covering 64K users.
identity Apply an identity (1:1) mapping, but limit it to 64K users.
auto Determine automatically based on provided directory and caller.

PartitionInfo

Information about a specific partition.

Field Type Description
designator PartitionDesignator The designator of this partition.
writable bool Indicates whether this partition is marked for writable (non-read-only) operations.
growFileSystem bool Indicates whether this partition is marked for automatic growing.
partitionNumber ?int Indicates the numeric partition number of this partition, or null if the image does not carry a partition table, and this object covers the whole block device.
architecture ?string Indicates the intended CPU architecture of the partition, in case the partition type encodes such information.
partitionUuid ?string The partition UUID identifying the partition.
fileSystemType string The file system type for the mount
partitionLabel ?string The partition label string of this partition.
size int The size of the partition in bytes.
offset int The start offset of the partition in bytes.
mountFileDescriptor int A mount file descriptor to assign to a location.
mountPoint ?[]string A relative path indicating the intended mount point for this file system, if applicable. May contain multiple paths, for certain partitions that can be mounted to multiple distinct places.

Errors

Error Go type Description
IncompatibleImage IncompatibleImageError Disk image is not compatible with this service.
MultipleRootPartitionsFound MultipleRootPartitionsFoundError Multiple suitable root partitions found.
RootPartitionNotFound RootPartitionNotFoundError No suitable root partition found.
DeniedByImagePolicy DeniedByImagePolicyError The specified image policy disallows mounting this disk image
KeyNotFound KeyNotFoundError The authentication key for this image is not available.
VerityFailure VerityFailureError Verity could not be set up.
BadFileDescriptorFlags BadFileDescriptorFlagsError A passed file descriptor has unexpected/forbidden flags set.