![]() |
![]() |
![]() |
UDisks Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Properties |
UDisksCleanup; UDisksCleanup * udisks_cleanup_new (UDisksDaemon *daemon
); void udisks_cleanup_start (UDisksCleanup *cleanup
); void udisks_cleanup_stop (UDisksCleanup *cleanup
); void udisks_cleanup_check (UDisksCleanup *cleanup
); UDisksDaemon * udisks_cleanup_get_daemon (UDisksCleanup *cleanup
); void udisks_cleanup_add_mounted_fs (UDisksCleanup *cleanup
,const gchar *mount_point
,dev_t block_device
,uid_t uid
,gboolean fstab_mount
); gchar * udisks_cleanup_find_mounted_fs (UDisksCleanup *cleanup
,dev_t block_device
,uid_t *out_uid
,gboolean *out_fstab_mount
); void udisks_cleanup_add_unlocked_luks (UDisksCleanup *cleanup
,dev_t cleartext_device
,dev_t crypto_device
,const gchar *dm_uuid
,uid_t uid
); dev_t udisks_cleanup_find_unlocked_luks (UDisksCleanup *cleanup
,dev_t crypto_device
,uid_t *out_uid
); void udisks_cleanup_add_loop (UDisksCleanup *cleanup
,const gchar *device_file
,const gchar *backing_file
,dev_t backing_file_device
,uid_t uid
); gboolean udisks_cleanup_has_loop (UDisksCleanup *cleanup
,const gchar *device_file
,uid_t *out_uid
);
This type is used for cleaning up when devices set up via the udisks interfaces are removed while still in use - for example, a USB stick being yanked. The UDisksPersistentStore type is used to record this information to ensure that it exists across daemon restarts and OS reboots.
The following files are used:
Table 2. Persistent information used for cleanup
File | Usage |
---|---|
/run/udisks2/mounted-fs |
A serialized 'a{sa{sv}}' GVariant mapping from the
mount point (e.g. /media/EOS_DIGITAL ) into a set of details.
Known details include
block-device
(of type 't') that is the dev_t
for the mounted device,
mounted-by-uid
(of type 'u') that is the uid_t
of the user who mounted the device, and
fstab-mount
(of type 'b') that is TRUE
if the device was mounted via an entry in /etc/fstab.
|
/run/udisks2/unlocked-luks |
A serialized 'a{ta{sv}}' GVariant mapping from the
dev_t of the clear-text device (e.g. /dev/dm-0 ) into a set of details.
Known details include
crypto-device
(of type 't') that is the dev_t
for the crypto-text device,
dm-uuid
(of type 'ay') that is the device mapper UUID
for the clear-text device and
unlocked-by-uid
(of type 'u') that is the uid_t
of the user who unlocked the device.
|
/run/udisks2/loop |
A serialized 'a{sa{sv}}' GVariant mapping from the
loop device name (e.g. /dev/loop0 ) into a set of details.
Known details include
backing-file
(of type 'ay') for the name of the backing file and
backing-file-device
(of type 't') for the dev_t
for of the device holding the backing file (or 0 if unknown) and
setup-by-uid
(of type 'u') that is the uid_t
of the user who set up the loop device.
|
Cleaning up is implemented by running a thread (to ensure that
actions are serialized) that checks all data in the files mentioned
above and cleans up the entry in question by e.g. unmounting a
filesystem, removing a mount point or tearing down a device-mapper
device when needed. The clean-up thread itself needs to be manually
kicked using e.g. udisks_cleanup_check()
from suitable places in
the UDisksDaemon and UDisksProvider implementations.
Since cleaning up is only necessary when a device has been removed without having been properly stopped or shut down, the fact that it was cleaned up is logged to ensure that the information is brought to the attention of the system administrator.
typedef struct _UDisksCleanup UDisksCleanup;
The UDisksCleanup structure contains only private data and should only be accessed using the provided API.
UDisksCleanup * udisks_cleanup_new (UDisksDaemon *daemon
);
Creates a new UDisksCleanup object.
|
A UDisksDaemon. |
Returns : |
A UDisksCleanup that should be freed with g_object_unref() . |
void udisks_cleanup_start (UDisksCleanup *cleanup
);
Starts the clean-up thread.
The clean-up thread will hold a reference to cleanup
for as long
as it's running - use udisks_cleanup_stop()
to stop it.
|
A UDisksCleanup. |
void udisks_cleanup_stop (UDisksCleanup *cleanup
);
Stops the clean-up thread. Blocks the calling thread until it has stopped.
|
A UDisksCleanup. |
void udisks_cleanup_check (UDisksCleanup *cleanup
);
Causes the clean-up thread for cleanup
to check if anything should be cleaned up.
This can be called from any thread and will not block the calling thread.
|
A UDisksCleanup. |
UDisksDaemon * udisks_cleanup_get_daemon (UDisksCleanup *cleanup
);
Gets the daemon used by cleanup
.
|
A UDisksCleanup. |
Returns : |
A UDisksDaemon. Do not free, the object is owned by cleanup . |
void udisks_cleanup_add_mounted_fs (UDisksCleanup *cleanup
,const gchar *mount_point
,dev_t block_device
,uid_t uid
,gboolean fstab_mount
);
Adds a new entry to the
/run/udisks2/mounted-fs
file.
|
A UDisksCleanup. |
|
The mount point. |
|
The block device. |
|
The user id of the process requesting the device to be mounted. |
|
TRUE if the device was mounted via /etc/fstab. |
gchar * udisks_cleanup_find_mounted_fs (UDisksCleanup *cleanup
,dev_t block_device
,uid_t *out_uid
,gboolean *out_fstab_mount
);
Gets the mount point for block_device
, if it exists in the
/run/udisks2/mounted-fs
file.
|
A UDisksCleanup. |
|
The block device. |
|
Return location for the user id who mounted the device or NULL . |
|
Return location for whether the device was a fstab mount or NULL . |
Returns : |
The mount point for block_device or NULL if not found. |
void udisks_cleanup_add_unlocked_luks (UDisksCleanup *cleanup
,dev_t cleartext_device
,dev_t crypto_device
,const gchar *dm_uuid
,uid_t uid
);
Adds a new entry to the
/run/udisks2/unlocked-luks
file.
|
A UDisksCleanup. |
|
The clear-text device. |
|
The crypto device. |
|
The UUID of the unlocked dm device. |
|
The user id of the process requesting the device to be unlocked. |
dev_t udisks_cleanup_find_unlocked_luks (UDisksCleanup *cleanup
,dev_t crypto_device
,uid_t *out_uid
);
Gets the clear-text device for crypto_device
, if it exists in the
/run/udisks2/unlocked-luks
file.
|
A UDisksCleanup. |
|
The block device. |
|
Return location for the user id who mounted the device or NULL . |
Returns : |
The cleartext device for crypto_device or 0 if not found. |
void udisks_cleanup_add_loop (UDisksCleanup *cleanup
,const gchar *device_file
,const gchar *backing_file
,dev_t backing_file_device
,uid_t uid
);
Adds a new entry to the /run/udisks2/loop
file.
|
A UDisksCleanup. |
|
The loop device file. |
|
The backing file. |
|
The dev_t of the backing file or 0 if unknown. |
|
The user id of the process requesting the loop device. |
gboolean udisks_cleanup_has_loop (UDisksCleanup *cleanup
,const gchar *device_file
,uid_t *out_uid
);
Checks if device_file
is set up via udisks.
|
A UDisksCleanup |
|
A loop device file. |
|
Return location for the user id who setup the loop device or NULL . |
Returns : |
TRUE if set up via udisks, otherwise FALSE or if error is set. |
"daemon"
property"daemon" UDisksDaemon* : Read / Write / Construct Only
The UDisksDaemon object.