udisks

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT, MIT Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package udisks lists the system's volumes through UDisks2 over the system D-Bus, mounted or not, and mounts, unlocks and ejects them as the user, as GVfs's udisks2 volume monitor does for GTK's places sidebar. Polkit lets an active local session do all of it.

Index

Constants

View Source
const (
	BusName         = "org.freedesktop.UDisks2"
	ManagerPath     = dbus.ObjectPath("/org/freedesktop/UDisks2")
	BlockIface      = BusName + ".Block"
	FilesystemIface = BusName + ".Filesystem"
	EncryptedIface  = BusName + ".Encrypted"
	DriveIface      = BusName + ".Drive"
	// ErrDeviceBusy is UDisks2's error for a filesystem in use.
	ErrDeviceBusy = BusName + ".Error.DeviceBusy"
)

The UDisks2 names a client talks to.

Variables

View Source
var ErrBusy = errors.New("udisks: the volume is in use")

ErrBusy is an unmount UDisks2 refused because the filesystem is in use.

Functions

func Message

func Message(err error) string

Message is what UDisks2 said went wrong in err, for the user; err's own text when it was not UDisks2's answer.

Types

type Client

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

Client is a UDisks2 client on a system bus connection the caller owns.

func New

func New(conn *dbus.Conn) *Client

New is a client on conn.

func (*Client) Eject

func (c *Client) Eject(ctx context.Context, v Volume) error

Eject unmounts the volume everywhere, locks the container it was unlocked from, and powers its drive off or ejects its media. A filesystem in use is ErrBusy and leaves the drive as it is.

func (*Client) Mount

func (c *Client) Mount(ctx context.Context, object dbus.ObjectPath) (string, error)

Mount mounts the filesystem on object as the user and reports where.

func (*Client) Unlock

func (c *Client) Unlock(ctx context.Context, object dbus.ObjectPath, passphrase []byte) (dbus.ObjectPath, error)

Unlock unlocks the encrypted container on object with passphrase and reports its cleartext device. The passphrase goes to the bus straight from the slice, which is zeroed once the call is answered.

func (*Client) Volumes

func (c *Client) Volumes(ctx context.Context) ([]Volume, error)

Volumes lists the volumes UDisks2 has, by object path.

func (*Client) Watch

func (c *Client) Watch(changed func()) (stop func(), err error)

Watch calls changed, from one goroutine, whenever UDisks2's objects may have changed: one added or removed (a hotplug, an unlock), or a property changing (a mount), until stop, which returns once the last call has. Only UDisks2 is heard.

type Volume

type Volume struct {
	Object      dbus.ObjectPath
	Label       string
	Size        uint64
	Icon        string
	MountPoints []string
	Locked      bool
	Removable   bool
	// contains filtered or unexported fields
}

Volume is one volume the user may see: a filesystem, or an encrypted container still locked. Object is the block device to mount, the cleartext device of an unlocked container; MountPoints are where it is mounted now; Icon is the icon UDisks2 hints, "" for none. Removable volumes can be ejected.

func (Volume) Mounted

func (v Volume) Mounted() bool

Mounted reports a volume mounted somewhere.

Directories

Path Synopsis
Package udiskstest is a fake UDisks2 on a private bus: drives and their volumes a test adds and removes, mounted into directories the test owns, so nothing on the host is ever mounted.
Package udiskstest is a fake UDisks2 on a private bus: drives and their volumes a test adds and removes, mounted into directories the test owns, so nothing on the host is ever mounted.

Jump to

Keyboard shortcuts

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