From b63467ca06216d4951516639922ade3612af21a4 Mon Sep 17 00:00:00 2001 From: Mike Hiretsky Date: Fri, 24 Dec 2010 10:18:47 +0300 Subject: [PATCH] Fix get mount options if fstab contains UUID. --- pym/cl_fill_install.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/pym/cl_fill_install.py b/pym/cl_fill_install.py index 9e55112..46084e9 100644 --- a/pym/cl_fill_install.py +++ b/pym/cl_fill_install.py @@ -258,6 +258,14 @@ class fillVars(object, glob_attr): key = blkid_hash[key] disk_hash[dev][key] = value[1:-1] # discard comment and empty string + devuuid = '/dev/disk/by-uuid' + mapUuidDev = dict( + map(lambda x:("UUID=%s"%os.path.basename(x), + os.path.normpath(os.path.join(devuuid,os.readlink(x)))), + filter(os.path.islink, + map(lambda x:os.path.join(devuuid,x), + os.listdir(devuuid))))) + mapDevUuid = dict(map(lambda x:(x[1],x[0]),mapUuidDev.items())) mountOptionsList = \ filter(lambda x: x.strip() and not x.strip().startswith('#'), open("/etc/fstab").readlines()) @@ -270,12 +278,12 @@ class fillVars(object, glob_attr): mountOptionsList)) # get dev which has ntfs filesystem mountFormatList = \ - filter(lambda x: x[0] in disk_hash.keys() and \ - x[1] in ("ntfs","ntfs-3g"), + filter(lambda x: mapUuidDev.get(x[0],x[0]) in disk_hash.keys() \ + and x[1] in ("ntfs","ntfs-3g"), map(lambda y: (y[0],y[2]), mountOptionsList)) # split options and discard rw opt mountOptionsList = \ - filter(lambda x: x[0] in disk_hash.keys(), + filter(lambda x: mapUuidDev.get(x[0],x[0]) in disk_hash.keys(), map(lambda y: (y[0],filter(lambda z: z!="rw", y[3].split(','))), mountOptionsList)) @@ -283,11 +291,12 @@ class fillVars(object, glob_attr): dictOptionList = dict(mountOptionsList) dictFormatList = dict(mountFormatList) for dev in disk_hash.keys(): - if dev in dictOptionList: - disk_hash[dev]['options'] = ",".join(dictOptionList[dev]) - if dev in dictFormatList and "format" in disk_hash[dev] and \ + iddev = mapDevUuid.get(dev,dev) + if iddev in dictOptionList: + disk_hash[dev]['options'] = ",".join(dictOptionList[iddev]) + if iddev in dictFormatList and "format" in disk_hash[dev] and \ disk_hash[dev]['format'] in ("ntfs","ntfs-3g"): - disk_hash[dev]['format'] = dictFormatList[dev] + disk_hash[dev]['format'] = dictFormatList[iddev] return disk_hash def separateDevice(self,device):