physdev path start with /, like in hotplug. add dvd drive into devicedb. fix scanner...
authorFelix Domke <tmbinc@elitedvb.net>
Mon, 19 Jan 2009 13:10:02 +0000 (14:10 +0100)
committerFelix Domke <tmbinc@elitedvb.net>
Mon, 19 Jan 2009 13:10:02 +0000 (14:10 +0100)
lib/python/Components/Harddisk.py
lib/python/Components/Scanner.py

index d739e9842df052a79738d2c4a96a08dffc76a2d8..ad7f28de7f4a5c15ce2a8d7bfb5223aa61f56596 100644 (file)
@@ -252,9 +252,10 @@ class Partition:
 DEVICEDB =  \
        {
                # dm8000:
 DEVICEDB =  \
        {
                # dm8000:
-               "devices/platform/brcm-ehci.0/usb1/1-1/1-1.1/1-1.1:1.0": "Front USB Slot",
-               "devices/platform/brcm-ehci.0/usb1/1-1/1-1.2/1-1.2:1.0": "Back, upper USB Slot",
-               "devices/platform/brcm-ehci.0/usb1/1-1/1-1.3/1-1.3:1.0": "Back, lower USB Slot",
+               "/devices/platform/brcm-ehci.0/usb1/1-1/1-1.1/1-1.1:1.0": "Front USB Slot",
+               "/devices/platform/brcm-ehci.0/usb1/1-1/1-1.2/1-1.2:1.0": "Back, upper USB Slot",
+               "/devices/platform/brcm-ehci.0/usb1/1-1/1-1.3/1-1.3:1.0": "Back, lower USB Slot",
+               "/devices/platform/brcm-ehci-1.1/usb2/2-1/2-1:1.0/host1/target1:0:0/1:0:0:0": "DVD Drive",
        }
 
 class HarddiskManager:
        }
 
 class HarddiskManager:
@@ -352,14 +353,10 @@ class HarddiskManager:
                if not physdev:
                        dev, part = self.splitDeviceName(device)
                        try:
                if not physdev:
                        dev, part = self.splitDeviceName(device)
                        try:
-                               physdev = readlink("/sys/block/" + dev + "/device")[6:]
+                               physdev = readlink("/sys/block/" + dev + "/device")[5:]
                        except OSError:
                        except OSError:
-                               print "couldn't determine blockdev physdev for device", dev, "try", device, "now"
-                               try:
-                                       physdev = readlink("/sys/block/" + device + "/device")[6:]
-                               except OSError:
-                                       physdev = dev
-                                       print "couldn't determine blockdev physdev for device", device
+                               physdev = dev
+                               print "couldn't determine blockdev physdev for device", device
 
                # device is the device name, without /dev 
                # physdev is the physical device path, which we (might) use to determine the userfriendly name
 
                # device is the device name, without /dev 
                # physdev is the physical device path, which we (might) use to determine the userfriendly name
@@ -423,22 +420,21 @@ class HarddiskManager:
                return [x for x in parts if not x.device or x.device in devs]
 
        def splitDeviceName(self, devname):
                return [x for x in parts if not x.device or x.device in devs]
 
        def splitDeviceName(self, devname):
-               dev = ""
-               part = ""
-               for i in devname:
-                       if i in string.digits:
-                               part += i
-                       else:
-                               dev += i
+               # this works for: sdaX, hdaX, sr0 (which is in fact dev="sr0", part=""). It doesn't work for other names like mtdblock3, but they are blacklisted anyway.
+               dev = devname[:3]
+               part = devname[3:]
+               for p in part:
+                       if p not in string.digits:
+                               return devname, 0
                return dev, part and int(part) or 0
 
        def getUserfriendlyDeviceName(self, dev, phys):
                dev, part = self.splitDeviceName(dev)
                description = "External Storage %s" % dev
                try:
                return dev, part and int(part) or 0
 
        def getUserfriendlyDeviceName(self, dev, phys):
                dev, part = self.splitDeviceName(dev)
                description = "External Storage %s" % dev
                try:
-                       description = open("/sys/" + phys + "/model").read().strip()
+                       description = open("/sys" + phys + "/model").read().strip()
                except IOError, s:
                except IOError, s:
-                       print "couldn't read model (from /sys/" + phys + "/model): ", s
+                       print "couldn't read model: ", s
                for physdevprefix, pdescription in DEVICEDB.items():
                        if phys.startswith(physdevprefix):
                                description = pdescription
                for physdevprefix, pdescription in DEVICEDB.items():
                        if phys.startswith(physdevprefix):
                                description = pdescription
index 766d19663d30db286f112c73f8615d6d30700dd2..86a5431d6279de86d5c1311831f744b878a76354 100644 (file)
@@ -135,7 +135,7 @@ def scanDevice(mountpoint):
 
        from Components.Harddisk import harddiskmanager 
        blockdev = mountpoint.rstrip("/").rsplit('/',1)[-1]
 
        from Components.Harddisk import harddiskmanager 
        blockdev = mountpoint.rstrip("/").rsplit('/',1)[-1]
-       error, blacklisted, removable, is_cdrom, partitions = harddiskmanager.getBlockDevInfo(blockdev)
+       error, blacklisted, removable, is_cdrom, partitions, medium_found = harddiskmanager.getBlockDevInfo(blockdev)
 
        # now scan the paths
        for p in paths_to_scan:
 
        # now scan the paths
        for p in paths_to_scan: