PROP_DEVICE_IS_READ_ONLY,
PROP_DEVICE_IS_DRIVE,
PROP_DEVICE_IS_OPTICAL_DISC,
+ PROP_DEVICE_IS_LUKS,
PROP_DEVICE_IS_LUKS_CLEARTEXT,
PROP_DEVICE_IS_LINUX_MD_COMPONENT,
PROP_DEVICE_IS_LINUX_MD,
PROP_PARTITION_TABLE_OFFSETS,
PROP_PARTITION_TABLE_SIZES,
+ PROP_LUKS_HOLDER,
+
PROP_LUKS_CLEARTEXT_SLAVE,
PROP_LUKS_CLEARTEXT_UNLOCKED_BY_UID,
case PROP_DEVICE_IS_OPTICAL_DISC:
g_value_set_boolean (value, device->priv->info.device_is_optical_disc);
break;
+ case PROP_DEVICE_IS_LUKS:
+ g_value_set_boolean (value, device->priv->info.device_is_luks);
+ break;
case PROP_DEVICE_IS_LUKS_CLEARTEXT:
g_value_set_boolean (value, device->priv->info.device_is_luks_cleartext);
break;
g_value_set_boxed (value, device->priv->info.partition_table_sizes);
break;
+ case PROP_LUKS_HOLDER:
+ if (device->priv->info.luks_holder != NULL)
+ g_value_set_boxed (value, device->priv->info.luks_holder);
+ else
+ g_value_set_boxed (value, "/");
+ break;
+
case PROP_LUKS_CLEARTEXT_SLAVE:
if (device->priv->info.luks_cleartext_slave != NULL)
g_value_set_boxed (value, device->priv->info.luks_cleartext_slave);
g_param_spec_boolean ("device-is-optical-disc", NULL, NULL, FALSE, G_PARAM_READABLE));
g_object_class_install_property (
object_class,
+ PROP_DEVICE_IS_LUKS,
+ g_param_spec_boolean ("device-is-luks", NULL, NULL, FALSE, G_PARAM_READABLE));
+ g_object_class_install_property (
+ object_class,
PROP_DEVICE_IS_LUKS_CLEARTEXT,
g_param_spec_boolean ("device-is-luks-cleartext", NULL, NULL, FALSE, G_PARAM_READABLE));
g_object_class_install_property (
g_object_class_install_property (
object_class,
+ PROP_LUKS_HOLDER,
+ g_param_spec_boxed ("luks-holder", NULL, NULL, DBUS_TYPE_G_OBJECT_PATH, G_PARAM_READABLE));
+
+ g_object_class_install_property (
+ object_class,
PROP_LUKS_CLEARTEXT_SLAVE,
g_param_spec_boxed ("luks-cleartext-slave", NULL, NULL, DBUS_TYPE_G_OBJECT_PATH, G_PARAM_READABLE));
g_object_class_install_property (
g_free (device->priv->info.partition_table_scheme);
+ g_free (device->priv->info.luks_holder);
+
g_free (device->priv->info.luks_cleartext_slave);
g_free (device->priv->info.drive_vendor);
device->priv->info.id_usage = g_strdup (value);
} else if (strcmp (key, "ID_FS_TYPE") == 0) {
device->priv->info.id_type = g_strdup (value);
+
+ if (g_strcmp0 (device->priv->info.id_type, "crypto_LUKS") == 0) {
+
+ device->priv->info.device_is_luks = TRUE;
+
+ if (device->priv->info.holders_objpath->len == 1)
+ device->priv->info.luks_holder = g_strdup (device->priv->info.holders_objpath->pdata[0]);
+ }
+
} else if (strcmp (key, "ID_FS_VERSION") == 0) {
device->priv->info.id_version = g_strdup (value);
if (device->priv->info.device_is_linux_md_component) {
}
static void
+update_holders (DevkitDisksDevice *device)
+{
+ unsigned int n;
+
+ /* This is similar to update_slaves() only the other way around. */
+
+ for (n = 0; n < device->priv->info.holders_objpath->len; n++) {
+ const char *holder_objpath = device->priv->info.holders_objpath->pdata[n];
+ DevkitDisksDevice *holder;
+
+ holder = devkit_disks_daemon_local_find_by_object_path (device->priv->daemon, holder_objpath);
+ if (holder != NULL) {
+ update_info (holder);
+ }
+ }
+}
+
+static void
update_drive_properties (DevkitDisksDevice *device)
{
char *s;
return FALSE;
}
+static guint clear_handler_id = 0;
+
+static gboolean
+clear_is_updated_flags (DevkitDisksDaemon *daemon)
+{
+ GList *devices, *l;
+
+ devices = devkit_disks_daemon_local_get_all_devices (daemon);
+ for (l = devices; l != NULL; l = l->next) {
+ DevkitDisksDevice *device = DEVKIT_DISKS_DEVICE (l->data);
+
+ device->priv->is_updated = FALSE;
+ }
+
+ g_list_free (devices);
+
+ clear_handler_id = 0;
+
+ return FALSE;
+}
+
/**
* update_info:
* @device: the device
ret = FALSE;
+ if (device->priv->is_updated) {
+ g_debug ("Skipping update of %s because is_updated==TRUE", device->priv->native_path);
+ ret = TRUE;
+ goto out;
+ }
+
+ device->priv->is_updated = TRUE;
+
+ /* ensure we have set up and idle handler to clear all flags */
+ if (clear_handler_id == 0)
+ clear_handler_id = g_idle_add ((GSourceFunc) clear_is_updated_flags, device->priv->daemon);
+
+
/* md is special; we don't get "remove" events from the kernel when an array is
* stopped; so catch it very early before erasing our existing slave variable (we
* need this to set them slaves free)
}
update_slaves (device);
+ update_holders (device);
/* Linux MD detection */
if (sysfs_file_exists (device->priv->native_path, "md")) {
device->priv->removed = TRUE;
update_slaves (device);
+ update_holders (device);
/* If the device is busy, we possibly need to clean up if the
* device itself is busy. This includes
device->priv->info.device_is_luks_cleartext &&
strcmp (device->priv->info.luks_cleartext_slave, data->device->priv->object_path) == 0) {
+ /* update and emit a Changed() signal on the holder since the luks-holder
+ * property indicates the cleartext device
+ */
+ update_info (data->device);
+ emit_changed (data->device);
if (data->hook_func != NULL) {
data->hook_func (data->context, device, data->hook_user_data);
} else {
- /* yay! it is.. return value to the user */
dbus_g_method_return (data->context, object_path);
}
cleartext_device = find_cleartext_device (data->device);
if (cleartext_device != NULL) {
+ /* update and emit a Changed() signal on the holder since the luks-holder
+ * property indicates the cleartext device
+ */
+ update_info (data->device);
+ emit_changed (data->device);
if (data->hook_func != NULL) {
data->hook_func (data->context, cleartext_device, data->hook_user_data);
} else {
job_local_end (data->luks_device);
+ /* update and emit a Changed() signal on the holder since the luks-holder
+ * property indicates the cleartext device
+ */
+ update_info (data->luks_device);
+ emit_changed (data->luks_device);
dbus_g_method_return (data->context);
g_signal_handler_disconnect (daemon, data->device_removed_signal_handler_id);
/* if device is already removed, just return */
if (data->cleartext_device->priv->removed) {
+ /* update and emit a Changed() signal on the holder since the luks-holder
+ * property indicates the cleartext device
+ */
+ update_info (data->luks_device);
+ emit_changed (data->luks_device);
dbus_g_method_return (context);
} else {
/* otherwise sit and wait for the device to disappear */
gboolean device_is_read_only;
gboolean device_is_drive;
gboolean device_is_optical_disc;
+ gboolean device_is_luks;
gboolean device_is_luks_cleartext;
gboolean device_is_mounted;
gboolean device_is_busy;
GArray *partition_table_offsets;
GArray *partition_table_sizes;
+ char *luks_holder;
+
char *luks_cleartext_slave;
uid_t luks_cleartext_unlocked_by_uid;
props->device_is_drive = g_value_get_boolean (value);
else if (strcmp (key, "device-is-optical-disc") == 0)
props->device_is_optical_disc = g_value_get_boolean (value);
+ else if (strcmp (key, "device-is-luks") == 0)
+ props->device_is_luks = g_value_get_boolean (value);
else if (strcmp (key, "device-is-luks-cleartext") == 0)
props->device_is_luks_cleartext = g_value_get_boolean (value);
else if (strcmp (key, "device-is-linux-md-component") == 0)
props->partition_table_sizes = g_value_get_boxed (&dest_value);
}
+ else if (strcmp (key, "luks-holder") == 0)
+ props->luks_holder = g_strdup (g_value_get_boxed (value));
+
else if (strcmp (key, "luks-cleartext-slave") == 0)
props->luks_cleartext_slave = g_strdup (g_value_get_boxed (value));
else if (strcmp (key, "luks-cleartext-unlocked-by-uid") == 0)
g_free (props->partition_table_scheme);
g_array_free (props->partition_table_offsets, TRUE);
g_array_free (props->partition_table_sizes, TRUE);
+ g_free (props->luks_holder);
g_free (props->luks_cleartext_slave);
g_free (props->drive_model);
g_free (props->drive_vendor);
g_print (" %s (state: %s)\n",
props->linux_md_slaves[n], props->linux_md_slaves_state[n]);
}
+ if (props->device_is_luks) {
+ g_print (" luks device:\n");
+ g_print (" holder: %s\n", props->luks_holder);
+ }
if (props->device_is_luks_cleartext) {
g_print (" cleartext luks device:\n");
g_print (" backed by: %s\n", props->luks_cleartext_slave);