StoragedClient

StoragedClient — Utility routines for accessing the Storaged service

Functions

#define STORAGED_CHECK_VERSION()
void storaged_client_new ()
StoragedClient * storaged_client_new_finish ()
StoragedClient * storaged_client_new_sync ()
StoragedObject * storaged_client_get_object ()
StoragedObject * storaged_client_peek_object ()
GDBusObjectManager * storaged_client_get_object_manager ()
StoragedManager * storaged_client_get_manager ()
void storaged_client_settle ()
void storaged_client_queue_changed ()
GList * storaged_client_get_jobs_for_object ()
gchar * storaged_client_get_job_description ()
StoragedBlock * storaged_client_get_block_for_dev ()
GList * storaged_client_get_block_for_label ()
GList * storaged_client_get_block_for_uuid ()
StoragedBlock * storaged_client_get_block_for_drive ()
StoragedDrive * storaged_client_get_drive_for_block ()
StoragedBlock * storaged_client_get_cleartext_block ()
StoragedPartitionTable * storaged_client_get_partition_table ()
StoragedLoop * storaged_client_get_loop_for_block ()
GList * storaged_client_get_partitions ()
GList * storaged_client_get_drive_siblings ()
StoragedBlock * storaged_client_get_block_for_mdraid ()
GList * storaged_client_get_all_blocks_for_mdraid ()
GList * storaged_client_get_members_for_mdraid ()
StoragedMDRaid * storaged_client_get_mdraid_for_block ()
StoragedObjectInfo * storaged_client_get_object_info ()
void storaged_client_get_drive_info ()
gchar * storaged_client_get_partition_info ()
gchar * storaged_client_get_size_for_display ()
gchar * storaged_client_get_id_for_display ()
gchar * storaged_client_get_media_compat_for_display ()
void storaged_partition_type_info_free ()
GList * storaged_client_get_partition_type_infos ()
const gchar ** storaged_client_get_partition_table_subtypes ()
const gchar * storaged_client_get_partition_type_for_display ()
const gchar * storaged_client_get_partition_type_and_subtype_for_display ()
const gchar * storaged_client_get_partition_table_type_for_display ()
const gchar * storaged_client_get_partition_table_subtype_for_display ()

Properties

StoragedManager * manager Read
GDBusObjectManager * object-manager Read

Signals

void changed Run Last

Types and Values

Object Hierarchy

    GBoxed
    ╰── StoragedPartitionTypeInfo
    GFlags
    ╰── StoragedPartitionTypeInfoFlags
    GObject
    ╰── StoragedClient

Implemented Interfaces

StoragedClient implements GInitable and GAsyncInitable.

Description

StoragedClient is used for accessing the Storaged service from a client program.

Functions

STORAGED_CHECK_VERSION()

#define             STORAGED_CHECK_VERSION(major,minor,micro)

Macro to check against the version of the libstoraged library that is being compiled against.

Parameters

major

The major version to check for.

 

minor

the minor version to check for.

 

micro

The micro version to check for.

 

Returns

TRUE if the version of the libstoraged header files is the same as or newer than the passed in version.


storaged_client_new ()

void
storaged_client_new (GCancellable *cancellable,
                     GAsyncReadyCallback callback,
                     gpointer user_data);

Asynchronously gets a StoragedClient. When the operation is finished, callback will be invoked in the thread-default main loop of the thread you are calling this method from.

Parameters

cancellable

A GCancellable or NULL.

 

callback

Function that will be called when the result is ready.

 

user_data

Data to pass to callback .

 

storaged_client_new_finish ()

StoragedClient *
storaged_client_new_finish (GAsyncResult *res,
                            GError **error);

Finishes an operation started with storaged_client_new().

Parameters

res

A GAsyncResult.

 

error

Return location for error or NULL.

 

Returns

A StoragedClient or NULL if error is set. Free with g_object_unref() when done with it.


storaged_client_new_sync ()

StoragedClient *
storaged_client_new_sync (GCancellable *cancellable,
                          GError **error);

Synchronously gets a StoragedClient for the local system.

Parameters

cancellable

A GCancellable or NULL.

[allow-none]

error

Return location for error or NULL.

[allow-none]

Returns

A StoragedClient or NULL if error is set. Free with g_object_unref() when done with it.


storaged_client_get_object ()

StoragedObject *
storaged_client_get_object (StoragedClient *client,
                            const gchar *object_path);

Convenience function for looking up an StoragedObject for object_path .

Parameters

client

A StoragedClient.

 

object_path

Object path.

 

Returns

A StoragedObject corresponding to object_path or NULL if not found. The returned object must be freed with g_object_unref().

[transfer full]


storaged_client_peek_object ()

StoragedObject *
storaged_client_peek_object (StoragedClient *client,
                             const gchar *object_path);

Like storaged_client_get_object() but doesn't increase the reference count on the returned StoragedObject.

The returned object is only valid until removed so it is only safe to use this function on the thread where client was constructed. Use storaged_client_get_object() if on another thread.

Parameters

client

A StoragedClient.

 

object_path

Object path.

 

Returns

A StoragedObject corresponding to object_path or NULL if not found.

[transfer none]


storaged_client_get_object_manager ()

GDBusObjectManager *
storaged_client_get_object_manager (StoragedClient *client);

Gets the GDBusObjectManager used by client .

Parameters

client

A StoragedClient.

 

Returns

A GDBusObjectManager. Do not free, the instance is owned by client .

[transfer none]


storaged_client_get_manager ()

StoragedManager *
storaged_client_get_manager (StoragedClient *client);

Gets the StoragedManager interface on the well-known /org/storaged/Storaged/Manager object.

Parameters

client

A StoragedClient.

 

Returns

A StoragedManager or NULL if the storaged daemon is not currently running. Do not free, the instance is owned by client .

[transfer none]


storaged_client_settle ()

void
storaged_client_settle (StoragedClient *client);

Blocks until all pending D-Bus messages have been delivered. Also emits the (rate-limited) “changed” signal if changes are currently pending.

This is useful in two situations: 1. when using synchronous method calls since e.g. D-Bus signals received while waiting for the reply are queued up and dispatched after the synchronous call ends; and

  1. when using asynchronous calls where the return value references a newly created object (such as the Manager.LoopSetup() method).

Parameters

client

A StoragedClient.

 

storaged_client_queue_changed ()

void
storaged_client_queue_changed (StoragedClient *client);

Queues up a “changed” signal and rate-limit it. See the documentation for the “changed” property for more information.

Parameters

client

A StoragedClient.

 

Since: 2.1


storaged_client_get_jobs_for_object ()

GList *
storaged_client_get_jobs_for_object (StoragedClient *client,
                                     StoragedObject *object);

Gets all the StoragedJob instances that reference object , if any.

Parameters

client

A StoragedClient.

 

object

A StoragedObject.

 

Returns

A list of StoragedJob instances. The returned list should be freed with g_list_free() after each element has been freed with g_object_unref().

[transfer full][element-type StoragedJob]


storaged_client_get_job_description ()

gchar *
storaged_client_get_job_description (StoragedClient *client,
                                     StoragedJob *job);

Gets a human-readable and localized text string describing the operation of job .

For known job types, see the documentation for the

Job:Operation

D-Bus property.

Parameters

client

A StoragedClient.

 

job

A StoragedJob.

 

Returns

A string that should be freed with g_free().


storaged_client_get_block_for_dev ()

StoragedBlock *
storaged_client_get_block_for_dev (StoragedClient *client,
                                   dev_t block_device_number);

Gets the StoragedBlock corresponding to block_device_number , if any.

Parameters

client

A StoragedClient.

 

block_device_number

A dev_t to get a StoragedBlock for.

[type guint64]

Returns

A StoragedBlock or NULL if not found.

[transfer full]


storaged_client_get_block_for_label ()

GList *
storaged_client_get_block_for_label (StoragedClient *client,
                                     const gchar *label);

Gets all the StoragedBlock instances with the given label, if any.

Parameters

client

A StoragedClient.

 

label

The label.

 

Returns

A list of StoragedBlock instances. The returned list should be freed with g_list_free() after each element has been freed with g_object_unref().

[transfer full][element-type StoragedBlock]


storaged_client_get_block_for_uuid ()

GList *
storaged_client_get_block_for_uuid (StoragedClient *client,
                                    const gchar *uuid);

Gets all the StoragedBlock instances with the given uuid, if any.

Parameters

client

A StoragedClient.

 

uuid

The uuid.

 

Returns

A list of StoragedBlock instances. The returned list should be freed with g_list_free() after each element has been freed with g_object_unref().

[transfer full][element-type StoragedBlock]


storaged_client_get_block_for_drive ()

StoragedBlock *
storaged_client_get_block_for_drive (StoragedClient *client,
                                     StoragedDrive *drive,
                                     gboolean get_physical);

Gets a block device corresponding to drive . The returned block device, if any, is for the whole disk drive, e.g. a partition block device is never returned.

Set get_physical to TRUE if you need a block device that you can send low-level SCSI commands with (for multipath, this returns one of the physical paths). Set it to FALSE if you need a block device that you can read/write data with (for multipath, this returns the mapped device).

Parameters

client

A StoragedClient.

 

drive

A StoragedDrive.

 

get_physical

TRUE to get a physical device, FALSE to get the logical device.

 

Returns

A StoragedBlock or NULL if the requested kind of block device is not available - use g_object_unref() to free the returned object.

[transfer full]


storaged_client_get_drive_for_block ()

StoragedDrive *
storaged_client_get_drive_for_block (StoragedClient *client,
                                     StoragedBlock *block);

Gets the StoragedDrive that block belongs to, if any.

Parameters

client

A StoragedClient.

 

block

A StoragedBlock.

 

Returns

A StoragedDrive or NULL if there is no StoragedDrive for block - free the returned object with g_object_unref().

[transfer full]


storaged_client_get_cleartext_block ()

StoragedBlock *
storaged_client_get_cleartext_block (StoragedClient *client,
                                     StoragedBlock *block);

If block is an unlocked encrypted device, gets the cleartext device.

Parameters

client

A StoragedClient.

 

block

A StoragedBlock.

 

Returns

A StoragedBlock or NULL. Free with g_object_unref() when done with it.

[transfer full]


storaged_client_get_partition_table ()

StoragedPartitionTable *
storaged_client_get_partition_table (StoragedClient *client,
                                     StoragedPartition *partition);

Gets the StoragedPartitionTable corresponding to partition .

Parameters

client

A StoragedClient.

 

partition

A StoragedPartition.

 

Returns

A StoragedPartitionTable. Free with g_object_unref().

[transfer full]


storaged_client_get_loop_for_block ()

StoragedLoop *
storaged_client_get_loop_for_block (StoragedClient *client,
                                    StoragedBlock *block);

Gets the corresponding loop interface for block .

This only works if block itself is a loop device or a partition of a loop device.

Parameters

client

A StoragedClient.

 

block

A StoragedBlock.

 

Returns

A StoragedLoop or NULL. Free with g_object_unref().

[transfer full]


storaged_client_get_partitions ()

GList *
storaged_client_get_partitions (StoragedClient *client,
                                StoragedPartitionTable *table);

Gets all partitions of table .

Parameters

client

A StoragedClient.

 

table

A StoragedPartitionTable.

 

Returns

A list of StoragedPartition instances. The returned list should be freed with g_list_free() after each element has been freed with g_object_unref().

[transfer full][element-type StoragedPartition]


storaged_client_get_drive_siblings ()

GList *
storaged_client_get_drive_siblings (StoragedClient *client,
                                    StoragedDrive *drive);

Gets all siblings for drive .

Parameters

client

A StoragedClient

 

drive

A StoragedDrive.

 

Returns

A list of StoragedDrive instances. The returned list should be freed with g_list_free() after each element has been freed with g_object_unref().

[transfer full][element-type StoragedDrive]

Since: 2.1


storaged_client_get_block_for_mdraid ()

StoragedBlock *
storaged_client_get_block_for_mdraid (StoragedClient *client,
                                      StoragedMDRaid *raid);

Gets the RAID device (e.g. /dev/md0) for raid .

In the case of a split-brain syndrome, it is undefined which RAID device is returned. For example this can happen if /dev/sda and /dev/sdb are components of a two-disk RAID-1 and /dev/md0 and /dev/md1 are two degraded arrays, each one using exactly one of the two devices. Use storaged_client_get_all_blocks_for_mdraid() to get all RAID devices.

Parameters

client

A StoragedClient.

 

raid

A StoragedMDRaid.

 

Returns

A StoragedBlock or NULL if no RAID device is running.

[transfer full]

Since: 2.1


storaged_client_get_all_blocks_for_mdraid ()

GList *
storaged_client_get_all_blocks_for_mdraid
                               (StoragedClient *client,
                                StoragedMDRaid *raid);

Gets all RAID devices (e.g. /dev/md0 and /dev/md1) for raid .

This is usually only useful in split-brain situations — see storaged_client_get_block_for_mdraid() for an example — and is normally used only to convey the problem in an user interface.

Parameters

client

A StoragedClient.

 

raid

A StoragedMDRaid.

 

Returns

A list of StoragedBlock instances. The returned list should be freed with g_list_free() after each element has been freed with g_object_unref().

[transfer full][element-type StoragedBlock]

Since: 2.1


storaged_client_get_members_for_mdraid ()

GList *
storaged_client_get_members_for_mdraid
                               (StoragedClient *client,
                                StoragedMDRaid *raid);

Gets the physical block devices that are part of raid .

Parameters

client

A StoragedClient.

 

raid

A StoragedMDRaid.

 

Returns

A list of StoragedBlock instances. The returned list should be freed with g_list_free() after each element has been freed with g_object_unref().

[transfer full][element-type StoragedBlock]

Since: 2.1


storaged_client_get_mdraid_for_block ()

StoragedMDRaid *
storaged_client_get_mdraid_for_block (StoragedClient *client,
                                      StoragedBlock *block);

Gets the StoragedMDRaid that block is the block device for, if any.

Parameters

client

A StoragedClient.

 

block

A StoragedBlock.

 

Returns

A StoragedMDRaid or NULL if there is no StoragedMDRaid for block or block is not a MD-RAID block device. Free the returned object with g_object_unref().

[transfer full]

Since: 2.1


storaged_client_get_object_info ()

StoragedObjectInfo *
storaged_client_get_object_info (StoragedClient *client,
                                 StoragedObject *object);

Gets information about a StoragedObject instance that is suitable to present in an user interface. Information is returned in the StoragedObjectInfo object and is localized.

Parameters

client

A StoragedClient.

 

object

A StoragedObject.

 

Returns

A StoragedObjectInfo instance that should be freed with g_object_unref().

[transfer full]

Since: 2.1


storaged_client_get_drive_info ()

void
storaged_client_get_drive_info (StoragedClient *client,
                                StoragedDrive *drive,
                                gchar **out_name,
                                gchar **out_description,
                                GIcon **out_drive_icon,
                                gchar **out_media_description,
                                GIcon **out_media_icon);

storaged_client_get_drive_info has been deprecated since version 2.1 and should not be used in newly-written code.

Use storaged_client_get_object_info() instead.

Gets information about a StoragedDrive object that is suitable to present in an user interface. The returned strings are localized.

Parameters

client

A StoragedClient.

 

drive

A StoragedDrive.

 

out_name

Return location for name or NULL.

[out][allow-none]

out_description

Return location for description or NULL.

[out][allow-none]

out_drive_icon

Return location for icon representing the drive or NULL.

[out][allow-none]

out_media_description

Return location for description of the media or NULL.

[out][allow-none]

out_media_icon

Return location for icon representing the media or NULL.

[out][allow-none]

storaged_client_get_partition_info ()

gchar *
storaged_client_get_partition_info (StoragedClient *client,
                                    StoragedPartition *partition);

Gets information about partition that is suitable to present in an user interface in a single line of text.

The returned string is localized and includes things like the partition type, flags (if any) and name (if any).

Parameters

client

A StoragedClient.

 

partition

 

Returns

A string that should be freed with g_free().

[transfer full]


storaged_client_get_size_for_display ()

gchar *
storaged_client_get_size_for_display (StoragedClient *client,
                                      guint64 size,
                                      gboolean use_pow2,
                                      gboolean long_string);

Utility function to get a human-readable string that represents size .

Parameters

client

A StoragedClient.

 

size

Size in bytes

 

use_pow2

Whether power-of-two units should be used instead of power-of-ten units.

 

long_string

Whether to produce a long string.

 

Returns

A string that should be freed with g_free().


storaged_client_get_id_for_display ()

gchar *
storaged_client_get_id_for_display (StoragedClient *client,
                                    const gchar *usage,
                                    const gchar *type,
                                    const gchar *version,
                                    gboolean long_string);

Gets a human readable localized string for usage , type and version .

Parameters

client

A StoragedClient.

 

usage

Usage id e.g. "filesystem" or "crypto".

 

type

Type e.g. "ext4" or "crypto_LUKS"

 

version

Version.

 

long_string

Whether to produce a long string.

 

Returns

A string that should be freed with g_free().


storaged_client_get_media_compat_for_display ()

gchar *
storaged_client_get_media_compat_for_display
                               (StoragedClient *client,
                                const gchar * const *media_compat);

Gets a human-readable string of the media described by media_compat . The returned information is localized.

Parameters

client

A StoragedClient.

 

media_compat

An array of media types.

 

Returns

A string that should be freed with g_free() or NULL if unknown.


storaged_partition_type_info_free ()

void
storaged_partition_type_info_free (StoragedPartitionTypeInfo *info);

Frees info .

Parameters


storaged_client_get_partition_type_infos ()

GList *
storaged_client_get_partition_type_infos
                               (StoragedClient *client,
                                const gchar *partition_table_type,
                                const gchar *partition_table_subtype);

Gets information about all known partition types for partition_table_type and partition_table_subtype .

Parameters

client

A StoragedClient.

 

partition_table_type

A partition table type e.g. 'dos' or 'gpt'.

 

partition_table_subtype

A partition table subtype or NULL to get all known types.

[allow-none]

Returns

A list of StoragedPartitionTypeInfo instances. The returned list should be freed with g_list_free() after freeing each element with storaged_partition_type_info_free().

[transfer full][element-type StoragedPartitionTypeInfo]


storaged_client_get_partition_table_subtypes ()

const gchar **
storaged_client_get_partition_table_subtypes
                               (StoragedClient *client,
                                const gchar *partition_table_type);

Gets all known subtypes for partition_table_type .

Parameters

client

A StoragedClient.

 

partition_table_type

A partition table type e.g. 'dos' or 'gpt'.

 

Returns

A NULL-terminated array of strings. Only the container should be freed with g_free().

[transfer container]


storaged_client_get_partition_type_for_display ()

const gchar *
storaged_client_get_partition_type_for_display
                               (StoragedClient *client,
                                const gchar *partition_table_type,
                                const gchar *partition_type);

Gets a human readable localized string for partiton_table_type and partition_type .

Parameters

client

A StoragedClient.

 

partition_table_type

A partitioning type e.g. 'dos' or 'gpt'.

 

partition_type

A partition type.

 

Returns

A description of partition_type or NULL if unknown.


storaged_client_get_partition_type_and_subtype_for_display ()

const gchar *
storaged_client_get_partition_type_and_subtype_for_display
                               (StoragedClient *client,
                                const gchar *partition_table_type,
                                const gchar *partition_table_subtype,
                                const gchar *partition_type);

Like storaged_client_get_partition_type_for_display() but also takes the partition table subtype into account, if available. This is useful in scenarios where different subtypes is using the same partition type.

Parameters

client

A StoragedClient.

 

partition_table_type

A partitioning type e.g. 'dos' or 'gpt'.

 

partition_table_subtype

A partitioning subtype or NULL.

 

partition_type

A partition type.

 

Returns

A description of partition_type or NULL if unknown.

Since: 2.1.1


storaged_client_get_partition_table_type_for_display ()

const gchar *
storaged_client_get_partition_table_type_for_display
                               (StoragedClient *client,
                                const gchar *partition_table_type);

Gets a human readable localized string for partition_table_type .

Parameters

client

A StoragedClient.

 

partition_table_type

A partition table type e.g. 'dos' or 'gpt'.

 

Returns

A description of partition_table_type or NULL.


storaged_client_get_partition_table_subtype_for_display ()

const gchar *
storaged_client_get_partition_table_subtype_for_display
                               (StoragedClient *client,
                                const gchar *partition_table_type,
                                const gchar *partition_table_subtype);

Gets a human readable localized string for partition_table_type and partition_table_subtype .

Parameters

client

A StoragedClient.

 

partition_table_type

A partition table type e.g. 'dos' or 'gpt'.

 

partition_table_subtype

A partition table type e.g. 'dos' or 'gpt'.

 

Returns

A description of partition_table_type and partition_table_subtype or NULL.

Types and Values

STORAGED_MAJOR_VERSION

#define STORAGED_MAJOR_VERSION 2

The major version of the libstoraged header files.


STORAGED_MINOR_VERSION

#define STORAGED_MINOR_VERSION 5

The minor version of the libstoraged header files.


STORAGED_MICRO_VERSION

#define STORAGED_MICRO_VERSION 3

The micro version of the libstoraged header files.


StoragedClient

typedef struct _StoragedClient StoragedClient;

The StoragedClient structure contains only private data and should only be accessed using the provided API.


StoragedPartitionTypeInfo

typedef struct {
  const gchar                  *table_type;
  const gchar                  *table_subtype;
  const gchar                  *type;
  StoragedPartitionTypeInfoFlags  flags;
} StoragedPartitionTypeInfo;

Detailed information about a partition type.

table_subtype is used to break the set of partition types for table_type into a logical subsets. It is typically only used in user interfaces where the partition type is selected.

This struct may grow in the future without it being considered an ABI break.

Members

const gchar *table_type;

A partition table type e.g. 'dos' or 'gpt'

 

const gchar *table_subtype;

A partition table sub-type.

 

const gchar *type;

A partition type.

 

StoragedPartitionTypeInfoFlags flags;

Flags from the StoragedPartitionTypeInfoFlags enumeration.

 

enum StoragedPartitionTypeInfoFlags

Flags describing a partition type.

Members

STORAGED_PARTITION_TYPE_INFO_FLAGS_NONE

No flags set.

 

STORAGED_PARTITION_TYPE_INFO_FLAGS_SWAP

Partition type is used for swap.

 

STORAGED_PARTITION_TYPE_INFO_FLAGS_RAID

Partition type is used for RAID/LVM or similar.

 

STORAGED_PARTITION_TYPE_INFO_FLAGS_HIDDEN

Partition type indicates the partition is hidden (e.g. 'dos' type 0x1b "Hidden W95 FAT32"). Note that this is not the same as user-toggleable attributs/flags for a partition.

 

STORAGED_PARTITION_TYPE_INFO_FLAGS_CREATE_ONLY

Partition type can only be used when creating a partition and e.g. should not be selectable in a "change partition type" user interface (e.g. 'dos' type 0x05, 0x0f and 0x85 for extended partitions).

 

STORAGED_PARTITION_TYPE_INFO_FLAGS_SYSTEM

Partition type indicates the partition is part of the system / bootloader (e.g. 'dos' types 0xee, 0xff, 'gpt' types for 'EFI System partition' and 'BIOS Boot partition').

 

Property Details

The “manager” property

  “manager”                  StoragedManager *

The StoragedManager interface on the well-known /org/storaged/Storaged/Manager object

Flags: Read


The “object-manager” property

  “object-manager”           GDBusObjectManager *

The GDBusObjectManager used by the StoragedClient instance.

Flags: Read

Signal Details

The “changed” signal

void
user_function (StoragedClient *client,
               gpointer        user_data)

This signal is emitted either when an object or interface is added or removed a when property has changed. Additionally, multiple received signals are coalesced into a single signal that is rate-limited to fire at most every 100ms.

Note that calling storaged_client_settle() will cause this signal to fire if any changes are outstanding.

For greater detail, connect to the “object-added”, “object-removed”, “interface-added”, “interface-removed”, “interface-proxy-properties-changed” and signals on the “object-manager” object.

Parameters

client

A StoragedClient.

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last