[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[booty rhel5-branch 2/2] Translate dm-0 to mapper/<devicename> (#667014)
- From: Ales Kozumplik <akozumpl redhat com>
- To: anaconda-devel-list redhat com
- Subject: [booty rhel5-branch 2/2] Translate dm-0 to mapper/<devicename> (#667014)
- Date: Wed, 2 Mar 2011 16:51:57 +0100
The fix is based on a patch by Masahiro Matsuya <mmatsuya redhat com>.
---
bootyutil.py | 20 ++++++++++++++++++++
checkbootloader.py | 6 ++++--
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/bootyutil.py b/bootyutil.py
index cbfab5c..7b301f5 100644
--- a/bootyutil.py
+++ b/bootyutil.py
@@ -12,8 +12,11 @@
#
#
+import os
import string
+import rhpl.executil
+
# return (disk, partition number) eg ('hda', 1)
def getDiskPart(dev):
cut = len(dev)
@@ -46,3 +49,20 @@ def getDiskPart(dev):
partNum = None
return (name, partNum)
+
+def name_from_dm_node(dm_node):
+ """ Translate dm node to the device name.
+
+ For instance dm-0 to mapper/mpath0
+ """
+
+ full_path = "/sys/block/%s/dev" % dm_node
+ if not os.path.exists(full_path):
+ raise RuntimeError("name_from_dm_node: device does not exist: %s" %
+ full_path)
+ dev_file = open(full_path)
+ (major, minor) = dev_file.readline().strip().split(":")
+ name = rhpl.executil.execWithCapture(\
+ "/sbin/dmsetup",["/sbin/dmsetup", "info", "--columns", "--noheadings",
+ "-o", "name", "-j", str(major), "-m", str(minor)])
+ return name.strip()
diff --git a/checkbootloader.py b/checkbootloader.py
index 512e880..29e6a50 100644
--- a/checkbootloader.py
+++ b/checkbootloader.py
@@ -23,6 +23,7 @@ liloConfigFile = "/etc/lilo.conf"
yabootConfigFile = "/etc/yaboot.conf"
siloConfigFile = "/etc/silo.conf"
+import bootyutil
from bootyutil import getDiskPart
def getRaidDisks(raidDevice, raidLevel=None, stripPart=1):
@@ -39,7 +40,7 @@ def getRaidDisks(raidDevice, raidLevel=None, stripPart=1):
f.close()
except:
return rc
-
+
for line in lines:
fields = string.split(line, ' ')
if fields[0] == raidDevice:
@@ -51,6 +52,8 @@ def getRaidDisks(raidDevice, raidLevel=None, stripPart=1):
dev = string.split(field, '[')[0]
if len(dev) == 0:
continue
+ if dev.startswith("dm-"):
+ dev = "mapper/%s" % bootyutil.name_from_dm_node(dev)
if stripPart:
disk = getDiskPart(dev)[0]
rc.append(disk)
@@ -58,7 +61,6 @@ def getRaidDisks(raidDevice, raidLevel=None, stripPart=1):
rc.append(dev)
return rc
-
def getBootBlock(bootDev, instRoot, seekBlocks=0):
"""Get the boot block from bootDev. Return a 512 byte string."""
--
1.7.3.3
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]