From: Gui Chen Date: Wed, 13 Aug 2014 08:19:36 +0000 (-0400) Subject: add real path of device mapper to partition dict X-Git-Tag: released-tools-18.01.7~79^2~30 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bdee32128ab5fd1a17e0faf46632930a42c418de;p=tools%2Fmic.git add real path of device mapper to partition dict actually /dev/mapper/loop0p1 is symbol link in some distros, so add its real path to dict Change-Id: I2c9655e61e8878c3bbf5ea134f28996df1c6d78a Signed-off-by: Gui Chen --- diff --git a/mic/utils/partitionedfs.py b/mic/utils/partitionedfs.py index 60ff98e..cac360b 100644 --- a/mic/utils/partitionedfs.py +++ b/mic/utils/partitionedfs.py @@ -34,6 +34,13 @@ GPT_OVERHEAD = 34 # Size of a sector in bytes SECTOR_SIZE = 512 +def resolve_ref(ref): + real = os.readlink(ref) + if not real.startswith('/'): + return os.path.realpath(os.path.join(ref, real)) + else: + return real + class PartitionedMount(Mount): def __init__(self, mountdir, skipformat = False): Mount.__init__(self, mountdir) @@ -123,6 +130,7 @@ class PartitionedMount(Mount): 'disk_name': disk_name, # physical disk name holding partition 'device': None, # kpartx device node for partition 'mapper_device': None, # mapper device node + 'mpath_device': None, # multipath device of device mapper 'mount': None, # Mount object 'subvol': subvol, # Subvolume name 'boot': boot, # Bootable flag @@ -149,6 +157,7 @@ class PartitionedMount(Mount): 'disk_name': disk_name, # physical disk name holding partition 'device': None, # kpartx device node for partition 'mapper_device': None, # mapper device node + 'mpath_device': None, # multipath device of device mapper 'mount': None, # Mount object 'num': None, # Partition number 'boot': boot, # Bootable flag @@ -461,6 +470,12 @@ class PartitionedMount(Mount): raise MountError("Failed to map partitions for '%s'" % d['disk'].device) + for p in self.partitions: + if p['mapper_device'] and os.path.islink(p['mapper_device']): + p['mpath_device'] = resolve_ref(p['mapper_device']) + else: + p['mpath_device'] = '' + # FIXME: need a better way to fix the latency import time time.sleep(1)