summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Zeuthen <davidz@redhat.com>2011-08-15 13:06:33 -0400
committerDavid Zeuthen <davidz@redhat.com>2011-08-15 13:06:33 -0400
commit157b215bfccf469e729633e67e32a7ebc4590169 (patch)
tree18b37a36b92eb7afe4de34ec964d6c6a67859e13
parentd188b9e46e2800dfacccee7c5ccfd5fde90550d4 (diff)
Refine the libudev hack
Signed-off-by: David Zeuthen <davidz@redhat.com>
-rw-r--r--src/udiskslinuxdrive.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/udiskslinuxdrive.c b/src/udiskslinuxdrive.c
index 940fd33..df42c98 100644
--- a/src/udiskslinuxdrive.c
+++ b/src/udiskslinuxdrive.c
@@ -925,16 +925,17 @@ drive_update (UDisksLinuxDrive *drive,
sort_key = g_strdup_printf ("%" G_GUINT64_FORMAT,
time (NULL) * G_USEC_PER_SEC - g_udev_device_get_usec_since_initialized (device));
#else
- /* need to use this lame hack until libudev's get_usec_since_initialized() works */
+ /* need to use this lame hack until libudev's get_usec_since_initialized() works
+ * for devices received via the netlink socket
+ */
{
- const gchar *name;
- name = g_udev_device_get_name (device);
- if (g_str_has_prefix (name, "sr"))
- sort_key = g_strdup_printf ("z0_%s", name);
- else if (g_str_has_prefix (name, "sd"))
- sort_key = g_strdup_printf ("z1_%s", name);
- else
- sort_key = g_strdup (name);
+ GUdevClient *client;
+ GUdevDevice *ns_device;
+ client = udisks_linux_provider_get_udev_client (udisks_daemon_get_linux_provider (drive->daemon));
+ ns_device = g_udev_client_query_by_sysfs_path (client, g_udev_device_get_sysfs_path (device));
+ sort_key = g_strdup_printf ("%" G_GUINT64_FORMAT,
+ time (NULL) * G_USEC_PER_SEC - g_udev_device_get_usec_since_initialized (ns_device));
+ g_object_unref (ns_device);
}
#endif
udisks_drive_set_sort_key (iface, sort_key);