diff options
author | Gui Chen <gui.chen@intel.com> | 2014-08-13 04:19:36 -0400 |
---|---|---|
committer | admin <yuhuan.yang@samsung.com> | 2016-02-04 18:22:15 +0800 |
commit | bdee32128ab5fd1a17e0faf46632930a42c418de (patch) | |
tree | 7e830c59c8debd1bacd5c696e65667083ffbf47a | |
parent | 77bd261599ca4ab34dc330d10de5ba7cae3bc24b (diff) | |
download | mic-bdee32128ab5fd1a17e0faf46632930a42c418de.tar.gz mic-bdee32128ab5fd1a17e0faf46632930a42c418de.tar.bz2 mic-bdee32128ab5fd1a17e0faf46632930a42c418de.zip |
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 <gui.chen@intel.com>
-rw-r--r-- | mic/utils/partitionedfs.py | 15 |
1 files changed, 15 insertions, 0 deletions
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) |