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

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