Blame SOURCES/0026-sysfs-businfo-for-USB-devices-692.patch

99c779
From 466aaa3977c8cd9728a9f53a457de385c49d4e37 Mon Sep 17 00:00:00 2001
99c779
From: Dan Callaghan <dcallagh@redhat.com>
99c779
Date: Wed, 29 Jul 2015 18:09:49 +1000
99c779
Subject: [PATCH 26/26] sysfs: businfo for USB devices (#692)
99c779
99c779
This matches the behaviour of guessBusInfo() for USB device names of the
99c779
form host-port:config.interface.
99c779
99c779
This patch allows SCSI devices where the host is a USB device to be
99c779
parented correctly.
99c779
---
99c779
 src/core/sysfs.cc | 11 +++++++++++
99c779
 1 file changed, 11 insertions(+)
99c779
99c779
diff --git a/src/core/sysfs.cc b/src/core/sysfs.cc
99c779
index d17d33d..4f6a51f 100644
99c779
--- a/src/core/sysfs.cc
99c779
+++ b/src/core/sysfs.cc
99c779
@@ -137,6 +137,17 @@ static string sysfstobusinfo(const string & path)
99c779
   if (bustype == "ide")
99c779
     return sysfstoide(path);
99c779
 
99c779
+  if (bustype == "usb")
99c779
+  {
99c779
+    string name = basename(path.c_str());
99c779
+    if (matches(name, "^[0-9]+-[0-9]+(\\.[0-9]+)*:[0-9]+\\.[0-9]+$"))
99c779
+    {
99c779
+      size_t colon = name.rfind(":");
99c779
+      size_t dash = name.find("-");
99c779
+      return "usb@" + name.substr(0, dash) + ":" + name.substr(dash+1, colon-dash-1);
99c779
+    }
99c779
+  }
99c779
+
99c779
   if (bustype == "virtio")
99c779
   {
99c779
     string name = basename(path.c_str());
99c779
-- 
99c779
2.10.2
99c779