FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Fedora Desktop

 
 
LinkBack Thread Tools
 
Old 03-02-2011, 02:51 PM
Ales Kozumplik
 
Default Translate dm-0 to mapper/ (#667014)

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

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 03-02-2011, 03:20 PM
Martin Gracik
 
Default Translate dm-0 to mapper/ (#667014)

The name_from_dm_node() docstring says that it translates dm-0 to
mapper/mpath0, but then later you have

dev = "mapper/%s" % bootyutil.name_from_dm_node(dev)

So how it is?

On Wed, 2011-03-02 at 16:51 +0100, Ales Kozumplik wrote:
> 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."""

--
Martin Gracik <mgracik@redhat.com>

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 03-02-2011, 03:21 PM
Ales Kozumplik
 
Default Translate dm-0 to mapper/ (#667014)

On 03/02/2011 05:20 PM, Martin Gracik wrote:

The name_from_dm_node() docstring says that it translates dm-0 to
mapper/mpath0, but then later you have

dev = "mapper/%s" % bootyutil.name_from_dm_node(dev)

So how it is?


Good catch. The docstring is wrong, the code is what I meant (and what
rhel6 does).


Al_

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 06:53 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org