[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH 4/8] booty make getDiskPart use the devicetree



---
 booty/util.py |   36 +++++++-----------------------------
 1 files changed, 7 insertions(+), 29 deletions(-)

diff --git a/booty/util.py b/booty/util.py
index 48c3194..9b79e73 100644
--- a/booty/util.py
+++ b/booty/util.py
@@ -1,33 +1,11 @@
-import string
-from flags import flags
-
 def getDiskPart(dev, storage):
-    path = storage.devicetree.getDeviceByName(dev).path[5:]
-    cut = len(dev)
-    if dev[-1] in string.digits:
-        if (path.startswith('rd/') or path.startswith('ida/') or
-                path.startswith('cciss/') or path.startswith('sx8/') or
-                path.startswith('mapper/') or path.startswith('mmcblk') or
-                path.startswith('md')):
-            if dev[-2] == 'p':
-                cut = -2
-            elif dev[-3] == 'p' and dev[-2] in string.digits:
-                cut = -3
-        else:
-            if dev[-2] in string.digits:
-                cut = -2
-            else:
-                cut = -1
-
-    name = dev[:cut]
+    dev = storage.devicetree.getDeviceByName(dev)
 
-    if cut < 0:
-        part = dev[cut:]
-        if part[0] == 'p':
-            part = part[1:]
-        partNum = int(part) - 1
+    if dev.type == "partition":
+        partNum = dev.partedPartition.number - 1
+        disk = dev.disk
     else:
         partNum = None
-
-    return (name, partNum)
-
+        disk = dev
+    
+    return (disk.name, partNum)
-- 
1.7.0.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]