PROP_DEVICE_IS_REMOVABLE,
PROP_DEVICE_IS_MEDIA_AVAILABLE,
PROP_DEVICE_IS_DRIVE,
+ PROP_DEVICE_IS_CRYPTO_CLEARTEXT,
PROP_DEVICE_SIZE,
PROP_DEVICE_BLOCK_SIZE,
PROP_DEVICE_IS_MOUNTED,
PROP_PARTITION_TABLE_OFFSETS,
PROP_PARTITION_TABLE_SIZES,
+ PROP_CRYPTO_CLEARTEXT_SLAVE,
+
PROP_DRIVE_VENDOR,
PROP_DRIVE_MODEL,
PROP_DRIVE_REVISION,
case PROP_DEVICE_IS_DRIVE:
g_value_set_boolean (value, device->priv->info.device_is_drive);
break;
+ case PROP_DEVICE_IS_CRYPTO_CLEARTEXT:
+ g_value_set_boolean (value, device->priv->info.device_is_crypto_cleartext);
+ break;
case PROP_DEVICE_SIZE:
g_value_set_uint64 (value, device->priv->info.device_size);
break;
g_value_set_boxed (value, device->priv->info.partition_table_sizes);
break;
+ case PROP_CRYPTO_CLEARTEXT_SLAVE:
+ if (device->priv->info.crypto_cleartext_slave != NULL)
+ g_value_set_boxed (value, device->priv->info.crypto_cleartext_slave);
+ else
+ g_value_set_boxed (value, "/");
+ break;
+
case PROP_DRIVE_VENDOR:
g_value_set_string (value, device->priv->info.drive_vendor);
break;
g_param_spec_boolean ("device-is-drive", NULL, NULL, FALSE, G_PARAM_READABLE));
g_object_class_install_property (
object_class,
+ PROP_DEVICE_IS_CRYPTO_CLEARTEXT,
+ g_param_spec_boolean ("device-is-crypto-cleartext", NULL, NULL, FALSE, G_PARAM_READABLE));
+ g_object_class_install_property (
+ object_class,
PROP_DEVICE_SIZE,
g_param_spec_uint64 ("device-size", NULL, NULL, 0, G_MAXUINT64, 0, G_PARAM_READABLE));
g_object_class_install_property (
g_object_class_install_property (
object_class,
+ PROP_CRYPTO_CLEARTEXT_SLAVE,
+ g_param_spec_boxed ("crypto-cleartext-slave", NULL, NULL, DBUS_TYPE_G_OBJECT_PATH, G_PARAM_READABLE));
+
+ g_object_class_install_property (
+ object_class,
PROP_DRIVE_VENDOR,
g_param_spec_string ("drive-vendor", NULL, NULL, NULL, G_PARAM_READABLE));
g_object_class_install_property (
g_free (device->priv->info.partition_table_scheme);
+ g_free (device->priv->info.crypto_cleartext_slave);
+
g_free (device->priv->info.drive_vendor);
g_free (device->priv->info.drive_model);
g_free (device->priv->info.drive_revision);
}
}
+#if 0
+// Oh well, may come in handy later
+static char *
+sysfs_resolve_link (const char *sysfs_path, const char *name)
+{
+ char *full_path;
+ char link_path[PATH_MAX];
+ char resolved_path[PATH_MAX];
+ ssize_t num;
+ gboolean found_it;
+
+ found_it = FALSE;
+
+ full_path = g_build_filename (sysfs_path, name, NULL);
+
+ //g_warning ("name='%s'", name);
+ //g_warning ("full_path='%s'", full_path);
+ num = readlink (full_path, link_path, sizeof (link_path) - 1);
+ if (num != -1) {
+ char *absolute_path;
+
+ link_path[num] = '\0';
+
+ //g_warning ("link_path='%s'", link_path);
+ absolute_path = g_build_filename (sysfs_path, link_path, NULL);
+ //g_warning ("absolute_path='%s'", absolute_path);
+ if (realpath (absolute_path, resolved_path) != NULL) {
+ //g_warning ("resolved_path='%s'", resolved_path);
+ found_it = TRUE;
+ }
+ g_free (absolute_path);
+ }
+ g_free (full_path);
+
+ if (found_it)
+ return g_strdup (resolved_path);
+ else
+ return NULL;
+}
+#endif
+
static devkit_bool_t
update_info_properties_cb (DevKitInfo *info, const char *key, void *user_data)
{
}
}
+ } else if (strcmp (key, "DM_TARGET_TYPES") == 0) {
+ if (strcmp (devkit_info_property_get_string (info, key), "crypt") == 0) {
+ char *slaves_path;
+ GDir *slaves_dir;
+ const char *slave_name;
+
+ /* we're a dm-crypt target, find our slave */
+ slaves_path = g_build_filename (device->priv->native_path, "slaves", NULL);
+ if((slaves_dir = g_dir_open (slaves_path, 0, NULL)) != NULL) {
+ while ((slave_name = g_dir_read_name (slaves_dir)) != NULL) {
+ device->priv->info.device_is_crypto_cleartext = TRUE;
+ device->priv->info.crypto_cleartext_slave =
+ compute_object_path_from_basename (slave_name);
+ }
+ g_dir_close (slaves_dir);
+ }
+ g_free (slaves_path);
+
+ }
+
} else if (strcmp (key, "MEDIA_AVAILABLE") == 0) {
if (device->priv->info.device_is_removable) {
device->priv->info.device_is_media_available = devkit_info_property_get_bool (info, key);
<property name="device-is-media-available" type="b" access="read"/>
<property name="device-is-drive" type="b" access="read"/>
<property name="device-is-mounted" type="b" access="read"/>
+ <property name="device-is-crypto-cleartext" type="b" access="read"/>
<property name="device-mount-path" type="s" access="read"/>
<property name="device-size" type="t" access="read"/>
<property name="device-block-size" type="t" access="read"/>
<property name="id-uuid" type="s" access="read"/>
<property name="id-label" type="s" access="read"/>
+ <!-- The following properties are only set if the device is
+ a clear text device for an encrypted block device (see
+ the property 'device-is-crypto-cleartext').
+
+ The property 'crypto-cleartext-slave' is a reference to the
+ encrypted block device.
+ -->
+ <property name="crypto-cleartext-slave" type="o" access="read"/>
+
<!-- the following properties are only set if the device is
a partition (see 'device-is-partition'). Known values
for the partitioning scheme are
gboolean device_is_removable;
gboolean device_is_media_available;
gboolean device_is_drive;
+ gboolean device_is_crypto_cleartext;
gboolean device_is_mounted;
char *device_mount_path;
guint64 device_size;
GArray *partition_table_offsets;
GArray *partition_table_sizes;
+ char *crypto_cleartext_slave;
+
char *drive_vendor;
char *drive_model;
char *drive_revision;
props->device_is_media_available = g_value_get_boolean (value);
else if (strcmp (key, "device-is-drive") == 0)
props->device_is_drive = g_value_get_boolean (value);
+ else if (strcmp (key, "device-is-crypto-cleartext") == 0)
+ props->device_is_crypto_cleartext = g_value_get_boolean (value);
else if (strcmp (key, "device-is-mounted") == 0)
props->device_is_mounted = g_value_get_boolean (value);
else if (strcmp (key, "device-mount-path") == 0)
props->partition_table_sizes = g_value_get_boxed (&dest_value);
}
+ else if (strcmp (key, "crypto-cleartext-slave") == 0)
+ props->crypto_cleartext_slave = g_strdup (g_value_get_boxed (value));
+
else if (strcmp (key, "drive-vendor") == 0)
props->drive_vendor = g_strdup (g_value_get_string (value));
else if (strcmp (key, "drive-model") == 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->crypto_cleartext_slave);
g_free (props->drive_model);
g_free (props->drive_vendor);
g_free (props->drive_revision);
g_print (" version: %s\n", props->id_version);
g_print (" uuid: %s\n", props->id_uuid);
g_print (" label: %s\n", props->id_label);
+ if (props->device_is_crypto_cleartext) {
+ g_print (" cleartext crypto device:\n");
+ g_print (" backed by: %s\n", props->crypto_cleartext_slave);
+ }
if (props->device_is_partition_table) {
g_print (" partition table:\n");
g_print (" scheme: %s\n", props->partition_table_scheme);