[gnome-disk-utility] First cut at device-mapper multipath support
- From: David Zeuthen <davidz src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility] First cut at device-mapper multipath support
- Date: Fri, 22 Jan 2010 18:29:15 +0000 (UTC)
commit 3ca17765b49d582f15d7648a9cf8f0d139d9b5e6
Author: David Zeuthen <davidz redhat com>
Date: Fri Jan 22 13:29:43 2010 -0500
First cut at device-mapper multipath support
src/gdu/gdu-device.c | 76 ++++++++++++++++++++++++++++++++++
src/gdu/gdu-device.h | 7 +++
src/gdu/gdu-drive.c | 21 +++++++++-
src/gdu/gdu-volume.c | 14 ------
src/palimpsest/gdu-section-drive.c | 6 ++-
src/palimpsest/gdu-section-volumes.c | 16 +++++--
6 files changed, 120 insertions(+), 20 deletions(-)
---
diff --git a/src/gdu/gdu-device.c b/src/gdu/gdu-device.c
index c906440..7befefd 100644
--- a/src/gdu/gdu-device.c
+++ b/src/gdu/gdu-device.c
@@ -51,6 +51,7 @@ typedef struct
gint64 device_major;
gint64 device_minor;
char *device_file;
+ char *device_file_presentation;
char **device_file_by_id;
char **device_file_by_path;
gboolean device_is_system_internal;
@@ -72,6 +73,8 @@ typedef struct
gboolean device_is_linux_md;
gboolean device_is_linux_lvm2_lv;
gboolean device_is_linux_lvm2_pv;
+ gboolean device_is_linux_dmmp;
+ gboolean device_is_linux_dmmp_component;
char **device_mount_paths;
uid_t device_mounted_by_uid;
gboolean device_presentation_hide;
@@ -180,6 +183,12 @@ typedef struct
guint64 linux_lvm2_pv_group_extent_size;
char **linux_lvm2_pv_group_physical_volumes;
char **linux_lvm2_pv_group_logical_volumes;
+
+ gchar *linux_dmmp_component_holder;
+
+ gchar *linux_dmmp_name;
+ gchar **linux_dmmp_slaves;
+
} DeviceProperties;
static void
@@ -202,6 +211,8 @@ collect_props (const char *key,
props->device_minor = g_value_get_int64 (value);
else if (strcmp (key, "DeviceFile") == 0)
props->device_file = g_strdup (g_value_get_string (value));
+ else if (strcmp (key, "DeviceFilePresentation") == 0)
+ props->device_file_presentation = g_strdup (g_value_get_string (value));
else if (strcmp (key, "DeviceFileById") == 0)
props->device_file_by_id = g_strdupv (g_value_get_boxed (value));
else if (strcmp (key, "DeviceFileByPath") == 0)
@@ -242,6 +253,10 @@ collect_props (const char *key,
props->device_is_linux_lvm2_lv = g_value_get_boolean (value);
else if (strcmp (key, "DeviceIsLinuxLvm2PV") == 0)
props->device_is_linux_lvm2_pv = g_value_get_boolean (value);
+ else if (strcmp (key, "DeviceIsLinuxDmmp") == 0)
+ props->device_is_linux_dmmp = g_value_get_boolean (value);
+ else if (strcmp (key, "DeviceIsLinuxDmmpComponent") == 0)
+ props->device_is_linux_dmmp_component = g_value_get_boolean (value);
else if (strcmp (key, "DeviceIsMounted") == 0)
props->device_is_mounted = g_value_get_boolean (value);
else if (strcmp (key, "DeviceMountPaths") == 0)
@@ -471,6 +486,24 @@ collect_props (const char *key,
else if (strcmp (key, "LinuxLvm2PVGroupLogicalVolumes") == 0)
props->linux_lvm2_pv_group_logical_volumes = g_strdupv (g_value_get_boxed (value));
+ else if (strcmp (key, "LinuxDmmpComponentHolder") == 0)
+ props->linux_dmmp_component_holder = g_strdup (g_value_get_boxed (value));
+
+ else if (strcmp (key, "LinuxDmmpName") == 0)
+ props->linux_dmmp_name = g_strdup (g_value_get_string (value));
+ else if (strcmp (key, "LinuxDmmpSlaves") == 0)
+ {
+ guint n;
+ GPtrArray *object_paths;
+
+ object_paths = g_value_get_boxed (value);
+
+ props->linux_dmmp_slaves = g_new0 (char *, object_paths->len + 1);
+ for (n = 0; n < object_paths->len; n++)
+ props->linux_dmmp_slaves[n] = g_strdup (object_paths->pdata[n]);
+ props->linux_dmmp_slaves[n] = NULL;
+ }
+
else
handled = FALSE;
@@ -483,6 +516,7 @@ device_properties_free (DeviceProperties *props)
{
g_free (props->native_path);
g_free (props->device_file);
+ g_free (props->device_file_presentation);
g_strfreev (props->device_file_by_id);
g_strfreev (props->device_file_by_path);
g_strfreev (props->device_mount_paths);
@@ -545,6 +579,11 @@ device_properties_free (DeviceProperties *props)
g_strfreev (props->linux_lvm2_pv_group_physical_volumes);
g_strfreev (props->linux_lvm2_pv_group_logical_volumes);
+ g_free (props->linux_dmmp_component_holder);
+
+ g_free (props->linux_dmmp_name);
+ g_strfreev (props->linux_dmmp_slaves);
+
g_free (props);
}
@@ -819,6 +858,12 @@ gdu_device_get_device_file (GduDevice *device)
return device->priv->props->device_file;
}
+const char *
+gdu_device_get_device_file_presentation (GduDevice *device)
+{
+ return device->priv->props->device_file_presentation;
+}
+
guint64
gdu_device_get_size (GduDevice *device)
{
@@ -928,6 +973,18 @@ gdu_device_is_linux_lvm2_pv (GduDevice *device)
}
gboolean
+gdu_device_is_linux_dmmp (GduDevice *device)
+{
+ return device->priv->props->device_is_linux_dmmp;
+}
+
+gboolean
+gdu_device_is_linux_dmmp_component (GduDevice *device)
+{
+ return device->priv->props->device_is_linux_dmmp_component;
+}
+
+gboolean
gdu_device_is_mounted (GduDevice *device)
{
return device->priv->props->device_is_mounted;
@@ -1466,6 +1523,25 @@ gdu_device_linux_lvm2_pv_get_group_logical_volumes (GduDevice *device)
return device->priv->props->linux_lvm2_pv_group_logical_volumes;
}
+/* ---------------------------------------------------------------------------------------------------- */
+
+const char *
+gdu_device_linux_dmmp_component_get_holder (GduDevice *device)
+{
+ return device->priv->props->linux_dmmp_component_holder;
+}
+
+const char *
+gdu_device_linux_dmmp_get_name (GduDevice *device)
+{
+ return device->priv->props->linux_dmmp_name;
+}
+
+char **
+gdu_device_linux_dmmp_get_slaves (GduDevice *device)
+{
+ return device->priv->props->linux_dmmp_slaves;
+}
/* ---------------------------------------------------------------------------------------------------- */
diff --git a/src/gdu/gdu-device.h b/src/gdu/gdu-device.h
index f3e5291..73a1edf 100644
--- a/src/gdu/gdu-device.h
+++ b/src/gdu/gdu-device.h
@@ -71,6 +71,7 @@ dev_t gdu_device_get_dev (GduDevice *device);
guint64 gdu_device_get_detection_time (GduDevice *device);
guint64 gdu_device_get_media_detection_time (GduDevice *device);
const char *gdu_device_get_device_file (GduDevice *device);
+const char *gdu_device_get_device_file_presentation (GduDevice *device);
guint64 gdu_device_get_size (GduDevice *device);
guint64 gdu_device_get_block_size (GduDevice *device);
gboolean gdu_device_is_removable (GduDevice *device);
@@ -91,6 +92,8 @@ gboolean gdu_device_is_linux_md_component (GduDevice *device);
gboolean gdu_device_is_linux_md (GduDevice *device);
gboolean gdu_device_is_linux_lvm2_lv (GduDevice *device);
gboolean gdu_device_is_linux_lvm2_pv (GduDevice *device);
+gboolean gdu_device_is_linux_dmmp (GduDevice *device);
+gboolean gdu_device_is_linux_dmmp_component (GduDevice *device);
gboolean gdu_device_is_mounted (GduDevice *device);
const char *gdu_device_get_mount_path (GduDevice *device);
char **gdu_device_get_mount_paths (GduDevice *device);
@@ -195,6 +198,10 @@ guint64 gdu_device_linux_lvm2_pv_get_group_sequence_number (GduDevice *devic
gchar **gdu_device_linux_lvm2_pv_get_group_physical_volumes (GduDevice *device);
gchar **gdu_device_linux_lvm2_pv_get_group_logical_volumes (GduDevice *device);
+const char *gdu_device_linux_dmmp_component_get_holder (GduDevice *device);
+const char *gdu_device_linux_dmmp_get_name (GduDevice *device);
+char **gdu_device_linux_dmmp_get_slaves (GduDevice *device);
+
gboolean gdu_device_drive_ata_smart_get_is_available (GduDevice *device);
guint64 gdu_device_drive_ata_smart_get_time_collected (GduDevice *device);
const gchar *gdu_device_drive_ata_smart_get_status (GduDevice *device);
diff --git a/src/gdu/gdu-drive.c b/src/gdu/gdu-drive.c
index 410d9a7..228fb22 100644
--- a/src/gdu/gdu-drive.c
+++ b/src/gdu/gdu-drive.c
@@ -905,6 +905,7 @@ gdu_drive_get_icon (GduPresentable *presentable)
const char *presentation_icon_name;
gchar **drive_media_compat;
gboolean is_removable;
+ GIcon *icon;
connection_interface = gdu_device_drive_get_connection_interface (drive->priv->device);
is_removable = gdu_device_is_removable (drive->priv->device);
@@ -984,7 +985,25 @@ gdu_drive_get_icon (GduPresentable *presentable)
name = "drive-harddisk";
}
- return g_themed_icon_new_with_default_fallbacks (name);
+ /* Attach a MP emblem if it's a multipathed device */
+ icon = g_themed_icon_new_with_default_fallbacks (name);
+ if (gdu_device_is_linux_dmmp (drive->priv->device)) {
+ GEmblem *emblem;
+ GIcon *padlock;
+ GIcon *emblemed_icon;
+
+ padlock = g_themed_icon_new ("gdu-emblem-mp");
+ emblem = g_emblem_new_with_origin (padlock, G_EMBLEM_ORIGIN_DEVICE);
+
+ emblemed_icon = g_emblemed_icon_new (icon, emblem);
+ g_object_unref (icon);
+ icon = emblemed_icon;
+
+ g_object_unref (padlock);
+ g_object_unref (emblem);
+ }
+
+ return icon;
}
static guint64
diff --git a/src/gdu/gdu-volume.c b/src/gdu/gdu-volume.c
index 5239cae..271ae34 100644
--- a/src/gdu/gdu-volume.c
+++ b/src/gdu/gdu-volume.c
@@ -646,20 +646,6 @@ out:
icon = g_themed_icon_new_with_default_fallbacks (name);
if (usage != NULL && strcmp (usage, "crypto") == 0) {
- GEmblem *emblem;
- GIcon *padlock;
- GIcon *emblemed_icon;
-
- padlock = g_themed_icon_new ("gdu-encrypted-lock");
- emblem = g_emblem_new_with_origin (padlock, G_EMBLEM_ORIGIN_DEVICE);
-
- emblemed_icon = g_emblemed_icon_new (icon, emblem);
- g_object_unref (icon);
- icon = emblemed_icon;
-
- g_object_unref (padlock);
- g_object_unref (emblem);
-
}
if (gdu_device_is_luks_cleartext (volume->priv->device)) {
diff --git a/src/palimpsest/gdu-section-drive.c b/src/palimpsest/gdu-section-drive.c
index e964caa..26217b5 100644
--- a/src/palimpsest/gdu-section-drive.c
+++ b/src/palimpsest/gdu-section-drive.c
@@ -113,6 +113,7 @@ gdu_section_drive_update (GduSection *_section)
gboolean show_detach_button;
gboolean show_smart_button;
gboolean show_benchmark_button;
+ const gchar *device_file;
show_cddvd_button = FALSE;
show_format_button = FALSE;
@@ -188,7 +189,10 @@ gdu_section_drive_update (GduSection *_section)
} else {
gdu_details_element_set_text (section->priv->location_element, "â??");
}
- gdu_details_element_set_text (section->priv->device_element, gdu_device_get_device_file (d));
+ device_file = gdu_device_get_device_file_presentation (d);
+ if (device_file == NULL || strlen (device_file) == 0)
+ device_file = gdu_device_get_device_file (d);
+ gdu_details_element_set_text (section->priv->device_element, device_file);
model = gdu_device_drive_get_model (d);
vendor = gdu_device_drive_get_vendor (d);
diff --git a/src/palimpsest/gdu-section-volumes.c b/src/palimpsest/gdu-section-volumes.c
index 72f87e3..26d5ac2 100644
--- a/src/palimpsest/gdu-section-volumes.c
+++ b/src/palimpsest/gdu-section-volumes.c
@@ -2051,8 +2051,11 @@ gdu_section_volumes_update (GduSection *_section)
}
if (section->priv->device_element != NULL) {
if (d != NULL) {
- gdu_details_element_set_text (section->priv->device_element,
- gdu_device_get_device_file (d));
+ const char *device_file;
+ device_file = gdu_device_get_device_file_presentation (d);
+ if (device_file == NULL || strlen (device_file) == 0)
+ device_file = gdu_device_get_device_file (d);
+ gdu_details_element_set_text (section->priv->device_element, device_file);
} else {
gdu_details_element_set_text (section->priv->device_element, "â??");
}
@@ -2179,10 +2182,15 @@ gdu_section_volumes_update (GduSection *_section)
} else if (GDU_IS_VOLUME_HOLE (v)) {
GduDevice *drive_device;
+ const char *device_file;
+
gdu_details_element_set_text (section->priv->usage_element, _("Unallocated Space"));
drive_device = gdu_presentable_get_device (gdu_section_get_presentable (GDU_SECTION (section)));
- gdu_details_element_set_text (section->priv->device_element,
- gdu_device_get_device_file (drive_device));
+
+ device_file = gdu_device_get_device_file_presentation (drive_device);
+ if (device_file == NULL || strlen (device_file) == 0)
+ device_file = gdu_device_get_device_file (drive_device);
+ gdu_details_element_set_text (section->priv->device_element, device_file);
g_object_unref (drive_device);
if (can_create_partition (section, GDU_VOLUME_HOLE (v), NULL))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]