summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Zeuthen <davidz@redhat.com>2009-12-08 13:15:52 -0500
committerDavid Zeuthen <davidz@redhat.com>2009-12-08 13:15:52 -0500
commitc1994adbc67be47838d2a20bf1c6420d521cf5d7 (patch)
tree7665efbc983fce59cde4e415392e96e1a25b55c3
parent5b082a22bcecb6ad3767bf70dbc3d98f08368e19 (diff)
downloadgvfs-c1994adbc67be47838d2a20bf1c6420d521cf5d7.tar.gz
[gdu] Stop assuming that drives have no enclosing presentable
This makes the gdu volume monitor works with recent gnome-disk-utility versions with things like GduHub presentables that represents HBAs and Expanders. This will not affect previous gnome-disk-utility versions. Signed-off-by: David Zeuthen <davidz@redhat.com>
-rw-r--r--monitor/gdu/ggduvolume.c16
-rw-r--r--monitor/gdu/ggduvolumemonitor.c78
2 files changed, 66 insertions, 28 deletions
diff --git a/monitor/gdu/ggduvolume.c b/monitor/gdu/ggduvolume.c
index 28839fd6..be324c98 100644
--- a/monitor/gdu/ggduvolume.c
+++ b/monitor/gdu/ggduvolume.c
@@ -988,7 +988,21 @@ mount_with_mount_operation (MountOpData *data)
device = gdu_presentable_get_device (GDU_PRESENTABLE (data->volume->gdu_volume));
- toplevel = gdu_presentable_get_toplevel (GDU_PRESENTABLE (data->volume->gdu_volume));
+ toplevel = gdu_presentable_get_enclosing_presentable (GDU_PRESENTABLE (data->volume->gdu_volume));
+ /* handle logical partitions enclosed by an extented partition */
+ if (GDU_IS_VOLUME (toplevel))
+ {
+ GduPresentable *temp;
+ temp = toplevel;
+ toplevel = gdu_presentable_get_enclosing_presentable (toplevel);
+ g_object_unref (temp);
+ if (!GDU_IS_DRIVE (toplevel))
+ {
+ g_object_unref (toplevel);
+ toplevel = NULL;
+ }
+ }
+
if (toplevel != NULL)
drive_name = gdu_presentable_get_name (toplevel);
diff --git a/monitor/gdu/ggduvolumemonitor.c b/monitor/gdu/ggduvolumemonitor.c
index 398fed48..c5b58a00 100644
--- a/monitor/gdu/ggduvolumemonitor.c
+++ b/monitor/gdu/ggduvolumemonitor.c
@@ -1298,24 +1298,36 @@ update_volumes (GGduVolumeMonitor *monitor,
if (volume == NULL)
{
- GduPresentable *toplevel_presentable;
+ GduPresentable *toplevel_drive;
- toplevel_presentable = gdu_presentable_get_toplevel (p);
- if (toplevel_presentable != NULL)
+ toplevel_drive = gdu_presentable_get_enclosing_presentable (p);
+ /* handle logical partitions enclosed by an extented partition */
+ if (GDU_IS_VOLUME (toplevel_drive))
{
- GduDevice *toplevel_device;
+ GduPresentable *temp;
+ temp = toplevel_drive;
+ toplevel_drive = gdu_presentable_get_enclosing_presentable (toplevel_drive);
+ g_object_unref (temp);
+ }
- drive = NULL;
- toplevel_device = gdu_presentable_get_device (toplevel_presentable);
- if (toplevel_device != NULL)
+ if (toplevel_drive != NULL)
+ {
+ if (GDU_IS_DRIVE (toplevel_drive))
{
- drive = find_drive_by_device_file (monitor, gdu_device_get_device_file (toplevel_device));
- /*g_debug ("adding volume %s (drive %s)",
- gdu_device_get_device_file (d),
- gdu_device_get_device_file (toplevel_device));*/
- g_object_unref (toplevel_device);
+ GduDevice *toplevel_drive_device;
+
+ drive = NULL;
+ toplevel_drive_device = gdu_presentable_get_device (toplevel_drive);
+ if (toplevel_drive_device != NULL)
+ {
+ drive = find_drive_by_device_file (monitor, gdu_device_get_device_file (toplevel_drive_device));
+ /*g_debug ("adding volume %s (drive %s)",
+ gdu_device_get_device_file (d),
+ gdu_device_get_device_file (toplevel_device));*/
+ g_object_unref (toplevel_drive_device);
+ }
}
- g_object_unref (toplevel_presentable);
+ g_object_unref (toplevel_drive);
}
else
{
@@ -1512,7 +1524,7 @@ update_mounts (GGduVolumeMonitor *monitor,
if (volume == NULL)
volume = find_volume_for_mount_path (monitor, mount_path);
- /*g_debug ("adding mount %s (vol %p)", g_unix_mount_get_device_path (mount_entry), volume);*/
+ /*g_debug ("adding mount %s (vol %p) (device %s, mount_path %s)", g_unix_mount_get_device_path (mount_entry), volume, device_file, mount_path);*/
mount = g_gdu_mount_new (G_VOLUME_MONITOR (monitor), mount_entry, volume);
if (mount)
{
@@ -1640,24 +1652,36 @@ update_discs (GGduVolumeMonitor *monitor,
if (volume == NULL)
{
- GduPresentable *toplevel_presentable;
+ GduPresentable *toplevel_drive;
- toplevel_presentable = gdu_presentable_get_toplevel (p);
- if (toplevel_presentable != NULL)
+ toplevel_drive = gdu_presentable_get_enclosing_presentable (p);
+ /* handle logical partitions enclosed by an extented partition */
+ if (GDU_IS_VOLUME (toplevel_drive))
{
- GduDevice *toplevel_device;
+ GduPresentable *temp;
+ temp = toplevel_drive;
+ toplevel_drive = gdu_presentable_get_enclosing_presentable (toplevel_drive);
+ g_object_unref (temp);
+ }
- drive = NULL;
- toplevel_device = gdu_presentable_get_device (toplevel_presentable);
- if (toplevel_device != NULL)
+ if (toplevel_drive != NULL)
+ {
+ if (GDU_IS_DRIVE (toplevel_drive))
{
- drive = find_drive_by_device_file (monitor, gdu_device_get_device_file (toplevel_device));
- /*g_debug ("adding volume %s (drive %s)",
- gdu_device_get_device_file (d),
- gdu_device_get_device_file (toplevel_device));*/
- g_object_unref (toplevel_device);
+ GduDevice *toplevel_drive_device;
+
+ drive = NULL;
+ toplevel_drive_device = gdu_presentable_get_device (toplevel_drive);
+ if (toplevel_drive_device != NULL)
+ {
+ drive = find_drive_by_device_file (monitor, gdu_device_get_device_file (toplevel_drive_device));
+ /*g_debug ("adding volume %s (drive %s)",
+ gdu_device_get_device_file (d),
+ gdu_device_get_device_file (toplevel_device));*/
+ g_object_unref (toplevel_drive_device);
+ }
}
- g_object_unref (toplevel_presentable);
+ g_object_unref (toplevel_drive);
}
else
{