Fix get mount options if fstab contains UUID.

netsetup
Mike Hiretsky 14 years ago
parent ff882d9101
commit b63467ca06

@ -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):

Loading…
Cancel
Save