If a block device has ID_PATH set, consider it to be a drive
authorDavid Zeuthen <zeuthen@gmail.com>
Tue, 5 Jun 2012 18:44:48 +0000 (14:44 -0400)
committerDavid Zeuthen <zeuthen@gmail.com>
Tue, 5 Jun 2012 18:59:27 +0000 (14:59 -0400)
This fixes problems with the devices where ID_SERIAL or
ID_WWN_WITH_EXTENSION is not set. For example, block devices from the
rts_pstor driver.

See https://bugzilla.redhat.com/show_bug.cgi?id=828492

Signed-off-by: David Zeuthen <zeuthen@gmail.com>
src/udiskslinuxdriveobject.c

index 41cc40e..1e8142a 100644 (file)
@@ -665,17 +665,17 @@ udisks_linux_drive_object_uevent (UDisksLinuxDriveObject *object,
 static gchar *
 check_for_vpd (GUdevDevice *device)
 {
-  gchar *ret;
+  gchar *ret = NULL;
   const gchar *serial;
   const gchar *wwn;
+  const gchar *path;
 
   g_return_val_if_fail (G_UDEV_IS_DEVICE (device), FALSE);
 
-  ret = NULL;
-
-  /* prefer WWN to serial */
+  /* order of preference: WWN, serial, path */
   serial = g_udev_device_get_property (device, "ID_SERIAL");
   wwn = g_udev_device_get_property (device, "ID_WWN_WITH_EXTENSION");
+  path = g_udev_device_get_property (device, "ID_PATH");
   if (wwn != NULL && strlen (wwn) > 0)
     {
       ret = g_strdup (wwn);
@@ -684,6 +684,10 @@ check_for_vpd (GUdevDevice *device)
     {
       ret = g_strdup (serial);
     }
+  else if (path != NULL && strlen (path) > 0)
+    {
+      ret = g_strdup (path);
+    }
   return ret;
 }