UDisksDaemon

UDisksDaemon — Main daemon object

Functions

UDisksDaemon * udisks_daemon_new ()
GDBusConnection * udisks_daemon_get_connection ()
GDBusObjectManagerServer * udisks_daemon_get_object_manager ()
UDisksMountMonitor * udisks_daemon_get_mount_monitor ()
UDisksCrypttabMonitor * udisks_daemon_get_crypttab_monitor ()
UDisksLinuxProvider * udisks_daemon_get_linux_provider ()
PolkitAuthority * udisks_daemon_get_authority ()
UDisksState * udisks_daemon_get_state ()
gboolean udisks_daemon_get_disable_modules ()
gboolean udisks_daemon_get_force_load_modules ()
UDisksModuleManager * udisks_daemon_get_module_manager ()
UDisksConfigManager * udisks_daemon_get_config_manager ()
gboolean udisks_daemon_get_enable_tcrypt ()
gboolean udisks_daemon_get_uninstalled ()
UDisksUtabMonitor * udisks_daemon_get_utab_monitor ()
gchar * udisks_daemon_get_parent_for_tracking ()
gpointer (*UDisksDaemonWaitFuncGeneric) ()
UDisksObject * udisks_daemon_wait_for_object_sync ()
GList * udisks_daemon_get_objects ()
UDisksObject * udisks_daemon_find_object ()
UDisksObject * udisks_daemon_find_block ()
UDisksObject * udisks_daemon_find_block_by_device_file ()
UDisksObject * udisks_daemon_find_block_by_sysfs_path ()
UDisksBaseJob * udisks_daemon_launch_simple_job ()
UDisksBaseJob * udisks_daemon_launch_spawned_job ()
gboolean udisks_daemon_launch_spawned_job_sync ()
UDisksBaseJob * udisks_daemon_launch_spawned_job_gstring ()
gboolean udisks_daemon_launch_spawned_job_gstring_sync ()
UDisksBaseJob * udisks_daemon_launch_threaded_job ()
gboolean udisks_daemon_launch_threaded_job_sync ()
const gchar * udisks_daemon_get_uuid ()

Properties

GDBusConnection * connection Read / Write / Construct Only
gboolean disable-modules Read / Write / Construct Only
gboolean enable-tcrypt Read / Write / Construct Only
gboolean force-load-modules Read / Write / Construct Only
UDisksMountMonitor * mount-monitor Read
GDBusObjectManagerServer * object-manager Read
gboolean uninstalled Read / Write / Construct Only
char * uuid Read / Write

Types and Values

Object Hierarchy

    GObject
    ╰── UDisksDaemon

Description

Object holding all global state.

Functions

udisks_daemon_new ()

UDisksDaemon *
udisks_daemon_new (GDBusConnection *connection,
                   gboolean disable_modules,
                   gboolean force_load_modules,
                   gboolean uninstalled,
                   gboolean enable_tcrypt);

Create a new daemon object for exporting objects on connection .

Parameters

connection

A GDBusConnection.

 

disable_modules

Indicates whether modules should never be activated.

 

force_load_modules

Activate modules on startup (for debugging purposes).

 

uninstalled

Loads modules from the build directory (for debugging purposes).

 

enable_tcrypt

Checks whether devices could be TCRYPT encrypted.

 

Returns

A UDisksDaemon object. Free with g_object_unref().


udisks_daemon_get_connection ()

GDBusConnection *
udisks_daemon_get_connection (UDisksDaemon *daemon);

Gets the D-Bus connection used by daemon .

Parameters

daemon

A UDisksDaemon.

 

Returns

A GDBusConnection. Do not free, the object is owned by daemon .


udisks_daemon_get_object_manager ()

GDBusObjectManagerServer *
udisks_daemon_get_object_manager (UDisksDaemon *daemon);

Gets the D-Bus object manager used by daemon .

Parameters

daemon

A UDisksDaemon.

 

Returns

A GDBusObjectManagerServer. Do not free, the object is owned by daemon .


udisks_daemon_get_mount_monitor ()

UDisksMountMonitor *
udisks_daemon_get_mount_monitor (UDisksDaemon *daemon);

Gets the mount monitor used by daemon .

Parameters

daemon

A UDisksDaemon

 

Returns

A UDisksMountMonitor. Do not free, the object is owned by daemon .


udisks_daemon_get_crypttab_monitor ()

UDisksCrypttabMonitor *
udisks_daemon_get_crypttab_monitor (UDisksDaemon *daemon);

Gets the crypttab monitor used by daemon .

Parameters

daemon

A UDisksDaemon

 

Returns

A UDisksCrypttabMonitor. Do not free, the object is owned by daemon .


udisks_daemon_get_linux_provider ()

UDisksLinuxProvider *
udisks_daemon_get_linux_provider (UDisksDaemon *daemon);

Gets the Linux Provider, if any.

Parameters

daemon

A UDisksDaemon.

 

Returns

A UDisksLinuxProvider or NULL. Do not free, the object is owned by daemon .


udisks_daemon_get_authority ()

PolkitAuthority *
udisks_daemon_get_authority (UDisksDaemon *daemon);

Gets the PolicyKit authority used by daemon .

Parameters

daemon

A UDisksDaemon.

 

Returns

A PolkitAuthority instance or NULL if the polkit authority is not available. Do not free, the object is owned by daemon .


udisks_daemon_get_state ()

UDisksState *
udisks_daemon_get_state (UDisksDaemon *daemon);

Gets the state object used by daemon .

Parameters

daemon

A UDisksDaemon.

 

Returns

A UDisksState instance. Do not free, the object is owned by daemon .


udisks_daemon_get_disable_modules ()

gboolean
udisks_daemon_get_disable_modules (UDisksDaemon *daemon);

Gets daemon setting whether modules should never be loaded.

Parameters

daemon

A UDisksDaemon.

 

Returns

TRUE if --disable-modules commandline switch has been specified.


udisks_daemon_get_force_load_modules ()

gboolean
udisks_daemon_get_force_load_modules (UDisksDaemon *daemon);

Gets daemon setting whether modules should be activated upon start.

Parameters

daemon

A UDisksDaemon.

 

Returns

TRUE if --force-load-modules commandline switch has been specified.


udisks_daemon_get_module_manager ()

UDisksModuleManager *
udisks_daemon_get_module_manager (UDisksDaemon *daemon);

Gets the module manager used by daemon .

Parameters

daemon

A UDisksDaemon.

 

Returns

A UDisksModuleManager. Do not free, the object is owned by daemon .


udisks_daemon_get_config_manager ()

UDisksConfigManager *
udisks_daemon_get_config_manager (UDisksDaemon *daemon);

Gets the config manager used by daemon .

Parameters

daemon

A UDisksDaemon.

 

Returns

A UDisksConfigManager. Do not free, the object is owned by daemon .


udisks_daemon_get_enable_tcrypt ()

gboolean
udisks_daemon_get_enable_tcrypt (UDisksDaemon *daemon);

Gets daemon setting whether devices should be tested for being TCRYPT encrypted.

Parameters

daemon

A UDisksDaemon.

 

Returns

TRUE if "/etc/udisks2/tcrypt.conf" was an existing file during daemon startup.


udisks_daemon_get_uninstalled ()

gboolean
udisks_daemon_get_uninstalled (UDisksDaemon *daemon);

Gets daemon setting whether the modules should be loaded from the build directory.

Parameters

daemon

A UDisksDaemon.

 

Returns

TRUE if --uninstalled commandline switch has been specified.


udisks_daemon_get_utab_monitor ()

UDisksUtabMonitor *
udisks_daemon_get_utab_monitor (UDisksDaemon *daemon);

Gets the utab monitor used by daemon .

Parameters

daemon

A UDisksDaemon

 

Returns

A UDisksUtabMonitor. Do not free, the object is owned by daemon .


udisks_daemon_get_parent_for_tracking ()

gchar *
udisks_daemon_get_parent_for_tracking (UDisksDaemon *daemon,
                                       const gchar *path,
                                       gchar **uuid);

Finds parent block device and returns its object path and UUID. If the return value is NULL, the value of uuid has not been changed.

Parameters

daemon

A UDisksDaemon.

 

path

object path of a child to find parent of

 

uuid

a pointer to return parent UUID string

 

Returns

object path of the parent device. Free with g_free().

[transfer full]


UDisksDaemonWaitFuncGeneric ()

gpointer
(*UDisksDaemonWaitFuncGeneric) (UDisksDaemon *daemon,
                                gpointer user_data);

Type for callback function used with udisks_daemon_wait_for_object_sync().

Parameters

daemon

A UDisksDaemon.

 

user_data

The gpointer passed to udisks_daemon_wait_for_object_sync().

 

Returns

NULL if the object to wait for was not found, otherwise a full reference to a UDisksObject.

[transfer full]


udisks_daemon_wait_for_object_sync ()

UDisksObject *
udisks_daemon_wait_for_object_sync (UDisksDaemon *daemon,
                                    UDisksDaemonWaitFuncObject wait_func,
                                    gpointer user_data,
                                    GDestroyNotify user_data_free_func,
                                    guint timeout_seconds,
                                    GError **error);

Blocks the calling thread until an object picked by wait_func is available or until timeout_seconds has passed (in which case the function fails with UDISKS_ERROR_TIMED_OUT).

Note that wait_func will be called from time to time - for example if there is a device event.

Parameters

daemon

A UDisksDaemon.

 

wait_func

Function to check for desired object.

 

user_data

User data to pass to wait_func .

 

user_data_free_func

Function to free user_data or NULL.

[allow-none]

timeout_seconds

Maximum time to wait for the object (in seconds) or 0 to never wait.

 

error

Return location for error or NULL.

[allow-none]

Returns

The object picked by wait_func or NULL if error is set.

[transfer full]


udisks_daemon_get_objects ()

GList *
udisks_daemon_get_objects (UDisksDaemon *daemon);

Gets all D-Bus objects exported by daemon .

Parameters

daemon

A UDisksDaemon.

 

Returns

A list of UDisksObject 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 UDisksObject]


udisks_daemon_find_object ()

UDisksObject *
udisks_daemon_find_object (UDisksDaemon *daemon,
                           const gchar *object_path);

Finds an exported object with the object path given by object_path .

Parameters

daemon

A UDisksDaemon.

 

object_path

A dev_t with the device number to find.

 

Returns

A UDisksObject or NULL if not found. Free with g_object_unref().

[transfer full]


udisks_daemon_find_block ()

UDisksObject *
udisks_daemon_find_block (UDisksDaemon *daemon,
                          dev_t block_device_number);

Finds a block device with the number given by block_device_number .

Parameters

daemon

A UDisksDaemon.

 

block_device_number

A dev_t with the device number to find.

 

Returns

A UDisksObject or NULL if not found. Free with g_object_unref().

[transfer full]


udisks_daemon_find_block_by_device_file ()

UDisksObject *
udisks_daemon_find_block_by_device_file
                               (UDisksDaemon *daemon,
                                const gchar *device_file);

Finds a block device with device file given by device_file .

Parameters

daemon

A UDisksDaemon.

 

device_file

A device file.

 

Returns

A UDisksObject or NULL if not found. Free with g_object_unref().

[transfer full]


udisks_daemon_find_block_by_sysfs_path ()

UDisksObject *
udisks_daemon_find_block_by_sysfs_path
                               (UDisksDaemon *daemon,
                                const gchar *sysfs_path);

Finds a block device with a sysfs path given by sysfs_path .

Parameters

daemon

A UDisksDaemon.

 

sysfs_path

A sysfs path.

 

Returns

A UDisksObject or NULL if not found. Free with g_object_unref().

[transfer full]


udisks_daemon_launch_simple_job ()

UDisksBaseJob *
udisks_daemon_launch_simple_job (UDisksDaemon *daemon,
                                 UDisksObject *object,
                                 const gchar *job_operation,
                                 uid_t job_started_by_uid,
                                 GCancellable *cancellable);

Launches a new simple job.

The returned object will be exported on the bus until the “completed” signal is emitted on the object. It is not valid to use the returned object after this signal fires.

Parameters

daemon

A UDisksDaemon.

 

object

A UDisksObject to add to the job or NULL.

[allow-none]

job_operation

The operation for the job.

 

job_started_by_uid

The user who started the job.

 

cancellable

A GCancellable or NULL.

 

Returns

A UDisksSimpleJob object. Do not free, the object belongs to manager .


udisks_daemon_launch_spawned_job ()

UDisksBaseJob *
udisks_daemon_launch_spawned_job (UDisksDaemon *daemon,
                                  UDisksObject *object,
                                  const gchar *job_operation,
                                  uid_t job_started_by_uid,
                                  GCancellable *cancellable,
                                  uid_t run_as_uid,
                                  uid_t run_as_euid,
                                  const gchar *input_string,
                                  const gchar *command_line_format,
                                  ...);

Launches a new job for command_line_format .

The job is not started automatically! Use udisks_spawned_job_start() to start the job after “spawned-job-completed” or “completed” signals are connected (to get notified when the job is done). This is to prevent a race condition with the spawned process terminating before the signals are connected in which case the signal handlers are never triggered.

The returned object will be exported on the bus until the “completed” signal is emitted on the object. It is not valid to use the returned object after this signal fires.

Parameters

daemon

A UDisksDaemon.

 

object

A UDisksObject to add to the job or NULL.

[allow-none]

job_operation

The operation for the job.

 

job_started_by_uid

The user who started the job.

 

cancellable

A GCancellable or NULL.

 

run_as_uid

The uid_t to run the command as.

 

run_as_euid

The effective uid_t to run the command as.

 

input_string

A string to write to stdin of the spawned program or NULL.

 

command_line_format

printf()-style format for the command line to spawn.

 

...

Arguments for command_line_format .

 

Returns

A UDisksSpawnedJob object. Do not free, the object belongs to manager .


udisks_daemon_launch_spawned_job_sync ()

gboolean
udisks_daemon_launch_spawned_job_sync (UDisksDaemon *daemon,
                                       UDisksObject *object,
                                       const gchar *job_operation,
                                       uid_t job_started_by_uid,
                                       GCancellable *cancellable,
                                       uid_t run_as_uid,
                                       uid_t run_as_euid,
                                       gint *out_status,
                                       gchar **out_message,
                                       const gchar *input_string,
                                       const gchar *command_line_format,
                                       ...);

Like udisks_daemon_launch_spawned_job() but blocks the calling thread until the job completes.

Parameters

daemon

A UDisksDaemon.

 

object

A UDisksObject to add to the job or NULL.

[allow-none]

job_operation

The operation for the job.

 

job_started_by_uid

The user who started the job.

 

cancellable

A GCancellable or NULL.

 

run_as_uid

The uid_t to run the command as.

 

run_as_euid

The effective uid_t to run the command as.

 

input_string

A string to write to stdin of the spawned program or NULL.

 

out_status

Return location for the status parameter of the “spawned-job-completed” signal.

 

out_message

Return location for the message parameter of the “completed” signal.

 

command_line_format

printf()-style format for the command line to spawn.

 

...

Arguments for command_line_format .

 

Returns

The success parameter of the “completed” signal.


udisks_daemon_launch_spawned_job_gstring ()

UDisksBaseJob *
udisks_daemon_launch_spawned_job_gstring
                               (UDisksDaemon *daemon,
                                UDisksObject *object,
                                const gchar *job_operation,
                                uid_t job_started_by_uid,
                                GCancellable *cancellable,
                                uid_t run_as_uid,
                                uid_t run_as_euid,
                                GString *input_string,
                                const gchar *command_line_format,
                                ...);

Launches a new job for command_line_format .

The job is not started automatically! Use udisks_spawned_job_start() to start the job after “spawned-job-completed” or “completed” signals are connected (to get notified when the job is done). This is to prevent a race condition with the spawned process terminating before the signals are connected in which case the signal handlers are never triggered.

The returned object will be exported on the bus until the “completed” signal is emitted on the object. It is not valid to use the returned object after this signal fires.

This function is the same as udisks_daemon_launch_spawned_job, with the only difference that it takes a GString and is therefore able to handle binary inputs that contain '\0' bytes.

Parameters

daemon

A UDisksDaemon.

 

object

A UDisksObject to add to the job or NULL.

[allow-none]

job_operation

The operation for the job.

 

job_started_by_uid

The user who started the job.

 

cancellable

A GCancellable or NULL.

 

run_as_uid

The uid_t to run the command as.

 

run_as_euid

The effective uid_t to run the command as.

 

input_string

A string to write to stdin of the spawned program or NULL.

 

command_line_format

printf()-style format for the command line to spawn.

 

...

Arguments for command_line_format .

 

Returns

A UDisksSpawnedJob object. Do not free, the object belongs to manager .


udisks_daemon_launch_spawned_job_gstring_sync ()

gboolean
udisks_daemon_launch_spawned_job_gstring_sync
                               (UDisksDaemon *daemon,
                                UDisksObject *object,
                                const gchar *job_operation,
                                uid_t job_started_by_uid,
                                GCancellable *cancellable,
                                uid_t run_as_uid,
                                uid_t run_as_euid,
                                gint *out_status,
                                gchar **out_message,
                                GString *input_string,
                                const gchar *command_line_format,
                                ...);

Like udisks_daemon_launch_spawned_job() but blocks the calling thread until the job completes.

This function is the same as udisks_daemon_launch_spawned_job_sync, with the only difference that it takes a GString and is therefore able to handle binary inputs that contain '\0' bytes.

Parameters

daemon

A UDisksDaemon.

 

object

A UDisksObject to add to the job or NULL.

[allow-none]

job_operation

The operation for the job.

 

job_started_by_uid

The user who started the job.

 

cancellable

A GCancellable or NULL.

 

run_as_uid

The uid_t to run the command as.

 

run_as_euid

The effective uid_t to run the command as.

 

input_string

A string to write to stdin of the spawned program or NULL.

 

out_status

Return location for the status parameter of the “spawned-job-completed” signal.

 

out_message

Return location for the message parameter of the “completed” signal.

 

command_line_format

printf()-style format for the command line to spawn.

 

...

Arguments for command_line_format .

 

Returns

The success parameter of the “completed” signal.


udisks_daemon_launch_threaded_job ()

UDisksBaseJob *
udisks_daemon_launch_threaded_job (UDisksDaemon *daemon,
                                   UDisksObject *object,
                                   const gchar *job_operation,
                                   uid_t job_started_by_uid,
                                   UDisksThreadedJobFunc job_func,
                                   gpointer user_data,
                                   GDestroyNotify user_data_free_func,
                                   GCancellable *cancellable);

Launches a new job by running job_func in a new dedicated thread.

The job is not started automatically! Use udisks_threaded_job_start() to start the job after “threaded-job-completed” or “completed” signals are connected (to get notified when the job is done). This is to prevent a race condition with the job_func finishing before the signals are connected in which case the signal handlers are never triggered.

Long-running jobs should periodically check cancellable to see if they have been cancelled.

The returned object will be exported on the bus until the “completed” signal is emitted on the object. It is not valid to use the returned object after this signal fires.

Parameters

daemon

A UDisksDaemon.

 

object

A UDisksObject to add to the job or NULL.

[allow-none]

job_operation

The operation for the job.

 

job_started_by_uid

The user who started the job.

 

job_func

The function to run in another thread.

 

user_data

User data to pass to job_func .

 

user_data_free_func

Function to free user_data with or NULL.

 

cancellable

A GCancellable or NULL.

 

Returns

A UDisksThreadedJob object. Do not free, the object belongs to manager .


udisks_daemon_launch_threaded_job_sync ()

gboolean
udisks_daemon_launch_threaded_job_sync
                               (UDisksDaemon *daemon,
                                UDisksObject *object,
                                const gchar *job_operation,
                                uid_t job_started_by_uid,
                                UDisksThreadedJobFunc job_func,
                                gpointer user_data,
                                GDestroyNotify user_data_free_func,
                                GCancellable *cancellable,
                                GError **error);

Like udisks_daemon_launch_threaded_job() but blocks the calling thread until the job completes.

Parameters

daemon

A UDisksDaemon.

 

object

A UDisksObject to add to the job or NULL.

[allow-none]

job_operation

The operation for the job.

 

job_started_by_uid

The user who started the job.

 

job_func

The function to run in another thread.

 

user_data

User data to pass to job_func .

 

user_data_free_func

Function to free user_data with or NULL.

 

cancellable

A GCancellable or NULL.

 

error

The GError set by the UDisksThreadedJobFunc.

 

Returns

The success parameter of the “completed” signal.


udisks_daemon_get_uuid ()

const gchar *
udisks_daemon_get_uuid (UDisksDaemon *daemon);

Gets the UUID string specific to this daemon instance.

Parameters

daemon

A UDisksDaemon.

 

Returns

the UUID string. Do not free, the string is owned by daemon .

Types and Values

UDisksDaemon

typedef struct _UDisksDaemon UDisksDaemon;

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


UDISKS_DEFAULT_WAIT_TIMEOUT

#define UDISKS_DEFAULT_WAIT_TIMEOUT 20  /* seconds */

Default timeout in seconds to wait for an object or uevent.

Property Details

The “connection” property

  “connection”               GDBusConnection *

The GDBusConnection the daemon is for.

Owner: UDisksDaemon

Flags: Read / Write / Construct Only


The “disable-modules” property

  “disable-modules”          gboolean

Whether modules should be disabled

Owner: UDisksDaemon

Flags: Read / Write / Construct Only

Default value: FALSE


The “enable-tcrypt” property

  “enable-tcrypt”            gboolean

Whether devices should be tested for being TCRYPT encrypted.

Owner: UDisksDaemon

Flags: Read / Write / Construct Only

Default value: FALSE


The “force-load-modules” property

  “force-load-modules”       gboolean

Whether modules should be activated upon startup

Owner: UDisksDaemon

Flags: Read / Write / Construct Only

Default value: FALSE


The “mount-monitor” property

  “mount-monitor”            UDisksMountMonitor *

The UDisksMountMonitor used by the daemon

Owner: UDisksDaemon

Flags: Read


The “object-manager” property

  “object-manager”           GDBusObjectManagerServer *

The GDBusObjectManager used by the daemon

Owner: UDisksDaemon

Flags: Read


The “uninstalled” property

  “uninstalled”              gboolean

Loads modules from the build directory.

Owner: UDisksDaemon

Flags: Read / Write / Construct Only

Default value: FALSE


The “uuid” property

  “uuid”                     char *

The UUID specific for this daemon instance.

Owner: UDisksDaemon

Flags: Read / Write

Default value: NULL