Re: [booty rhel5-branch 2/2] Translate dm-0 to mapper/<devicename> (#667014)

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

 



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@xxxxxxxxxx>.
> ---
>  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@xxxxxxxxxx>

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


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux