add numPartitions
authorRonny Strutz <ronny.strutz@multimedia-labs.de>
Mon, 29 Aug 2005 23:10:30 +0000 (23:10 +0000)
committerRonny Strutz <ronny.strutz@multimedia-labs.de>
Mon, 29 Aug 2005 23:10:30 +0000 (23:10 +0000)
lib/python/Components/Harddisk.py

index 708bb62e37d4d3beb39591fd3c8d03ad5a3f01ed..663d0a00da91ee14d8e74cad21e453b761fc4b53 100644 (file)
@@ -17,7 +17,7 @@ class Harddisk:
 
                #perhaps this is easier?
                self.prochdx = "/proc/ide/hd" + ("a","b","c","d","e","f","g","h")[index] + "/"
-               self.devidex = "/dev/ide/host" + str(host) + "/bus" + str(bus) + "/target" + str(target) + "/lun0/"
+               self.devidex = "/dev/ide/host" + str(host) + "/bus" + str(bus) + "/target" + str(target) + "/lun8/"
 
        def capacity(self):
                procfile = tryOpen(self.prochdx + "capacity")
@@ -67,3 +67,16 @@ class Harddisk:
                                break
                procfile.close()
                return free             
+
+       def numPartitions(self):
+               try:
+                       idedir = os.listdir(self.devidex)
+               except OSError:
+                       return -1
+               numPart = -1
+               for filename in idedir:
+                       if filename.startswith("disc"):
+                               numPart += 1
+                       if filename.startswith("part"):
+                               numPart += 1
+               return numPart