diff options
author | David Zeuthen <davidz@redhat.com> | 2011-08-15 12:18:34 -0400 |
---|---|---|
committer | David Zeuthen <davidz@redhat.com> | 2011-08-15 12:18:34 -0400 |
commit | d188b9e46e2800dfacccee7c5ccfd5fde90550d4 (patch) | |
tree | 359c49edfe99d3a707de3d824d2153f5c491717c | |
parent | d5600d543103d68fdc333a72e5381955e76edb0c (diff) |
Workaround get_usec_since_initialized() not always working in libudev
Signed-off-by: David Zeuthen <davidz@redhat.com>
-rw-r--r-- | src/udiskslinuxdrive.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/udiskslinuxdrive.c b/src/udiskslinuxdrive.c index 5c2e3c5..940fd33 100644 --- a/src/udiskslinuxdrive.c +++ b/src/udiskslinuxdrive.c @@ -920,9 +920,23 @@ drive_update (UDisksLinuxDrive *drive, drive_set_rotation_rate (drive, iface, device); drive_set_connection_bus (drive, iface, device); +#if 0 /* This ensures that devices are shown in the order they are detected */ 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 */ + { + 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); + } +#endif udisks_drive_set_sort_key (iface, sort_key); g_free (sort_key); out: |