crosdisks

package
v0.0.0-...-683b059 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package crosdisks provides an interface to talk to cros_disks service via D-Bus.

Package crosdisks provides an interface to talk to cros_disks service via D-Bus and utilities.

Index

Constants

View Source
const (
	MountErrorNone               uint32 = 0
	MountErrorPathNotMounted     uint32 = 6
	MountErrorMountProgramFailed uint32 = 12
	MountErrorNeedPassword       uint32 = 13
	MountErrorInvalidDevicePath  uint32 = 100
)

See MountErrorType defined in system_api/dbus/cros-disks/dbus-constants.h

Variables

This section is empty.

Functions

This section is empty.

Types

type CrosDisks

type CrosDisks struct {
	// contains filtered or unexported fields
}

CrosDisks is used to interact with the CrosDisks process over D-Bus. For detailed spec of each D-Bus method, please find src/platform2/cros-disks/dbus_bindings/org.chromium.CrosDisks.xml.

func New

func New(ctx context.Context) (*CrosDisks, error)

New connects to CrosDisks via D-Bus and returns a crosDisks object.

func (*CrosDisks) AddDeviceToAllowlist

func (c *CrosDisks) AddDeviceToAllowlist(ctx context.Context, devicePath string) error

AddDeviceToAllowlist calls CrosDisks.AddDeviceToAllowlist D-Bus method.

func (*CrosDisks) Close

func (c *CrosDisks) Close() error

Close connection to CrosDisks D-Bus service.

func (*CrosDisks) EnumerateDevices

func (c *CrosDisks) EnumerateDevices(ctx context.Context) ([]string, error)

EnumerateDevices calls CrosDisks.EnumerateDevices D-Bus method.

func (*CrosDisks) Format

func (c *CrosDisks) Format(ctx context.Context, path, fsType string, options []string) error

Format calls CrosDisks.Format D-Bus method.

func (*CrosDisks) FormatAndWaitForCompletion

func (c *CrosDisks) FormatAndWaitForCompletion(ctx context.Context, path, fsType string, options []string) (DeviceOperationCompleted, error)

FormatAndWaitForCompletion formats volume and waits for the response signal.

func (*CrosDisks) GetDeviceProperties

func (c *CrosDisks) GetDeviceProperties(ctx context.Context, devicePath string) (map[string]dbus.Variant, error)

GetDeviceProperties calls CrosDisks.GetDeviceProperties D-Bus method.

func (*CrosDisks) Mount

func (c *CrosDisks) Mount(ctx context.Context, devicePath, fsType string, options []string) error

Mount calls CrosDisks.Mount D-Bus method.

func (*CrosDisks) MountAndWaitForCompletion

func (c *CrosDisks) MountAndWaitForCompletion(ctx context.Context, devicePath, fsType string, options []string) (MountCompleted, error)

MountAndWaitForCompletion mounts and waits for the response signal. This is a convenience method for the odd CrosDisks' mounting API.

func (*CrosDisks) RemoveDeviceFromAllowlist

func (c *CrosDisks) RemoveDeviceFromAllowlist(ctx context.Context, devicePath string) error

RemoveDeviceFromAllowlist calls CrosDisks.RemoveDeviceFromAllowlist D-Bus method.

func (*CrosDisks) Rename

func (c *CrosDisks) Rename(ctx context.Context, path, volumeName string) error

Rename calls CrosDisks.Rename D-Bus method.

func (*CrosDisks) RenameAndWaitForCompletion

func (c *CrosDisks) RenameAndWaitForCompletion(ctx context.Context, path, volumeName string) (DeviceOperationCompleted, error)

RenameAndWaitForCompletion renames volume and waits for the response signal.

func (*CrosDisks) Unmount

func (c *CrosDisks) Unmount(ctx context.Context, devicePath string, options []string) (uint32, error)

Unmount calls CrosDisks.Unmount D-Bus method.

func (*CrosDisks) WatchMountCompleted

func (c *CrosDisks) WatchMountCompleted(ctx context.Context) (*MountCompletedWatcher, error)

WatchMountCompleted registers the signal watching and returns its watcher instance.

type DeviceOperationCompleted

type DeviceOperationCompleted struct {
	Status uint32
	Device string
}

DeviceOperationCompleted holds status of the operation done.

type DeviceOperationCompletionWatcher

type DeviceOperationCompletionWatcher struct {
	dbusutil.SignalWatcher
}

DeviceOperationCompletionWatcher is a thin wrapper of dbusutil.SignalWatcher to return signal content as DeviceOperationCompleted.

func (*DeviceOperationCompletionWatcher) Wait

Wait waits for the DeviceOperationCompleted signal, and returns the body data of the received signal.

type LoopbackDevice

type LoopbackDevice struct {
	// contains filtered or unexported fields
}

LoopbackDevice holds info about a created loopback device.

func CreateLoopbackDevice

func CreateLoopbackDevice(ctx context.Context, sizeBytes int64) (*LoopbackDevice, error)

CreateLoopbackDevice creates a loopback device backed by a file of the specified size.

func (*LoopbackDevice) Close

func (l *LoopbackDevice) Close(ctx context.Context) (err error)

Close detaches the loopback device and removes the file backing it.

func (*LoopbackDevice) DevicePath

func (l *LoopbackDevice) DevicePath() string

DevicePath returns the device path in /dev.

func (*LoopbackDevice) SysDevicePath

func (l *LoopbackDevice) SysDevicePath() string

SysDevicePath returns the device path in /sys.

type MountCompleted

type MountCompleted struct {
	Status     uint32
	SourcePath string
	SourceType uint32
	MountPath  string
}

MountCompleted holds the body data of MountCompleted signal.

type MountCompletedWatcher

type MountCompletedWatcher struct {
	dbusutil.SignalWatcher
}

MountCompletedWatcher is a thin wrapper of dbusutil.SignalWatcher to return signal content as MountCompleted.

func (*MountCompletedWatcher) Wait

Wait waits for the MountCompleted signal, and returns the body data of the received signal.

Jump to

Keyboard shortcuts

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