Added support detect root dev by cmdline by UUID.

develop
Mike Hiretsky 14 years ago
parent 3936440d9e
commit 22eba09cdd

@ -487,18 +487,33 @@ class fillVars(glob_attr):
def get_os_root_dev(self):
"""корневой раздел файловой системы"""
for record in open('/proc/cmdline','rb').readlines():
re_res=re.search('^root=(\/dev\/[a-z]+[0-9]).*',record.strip())
re_res=re.search('(?:^|\s)root=(\S+)(\s|$)',record.strip())
if re_res:
return re_res.group(1)
else:
mountLunes = self._runos("mount")
if not mountLunes:
return ""
if type(mountLunes) == types.ListType:
root_dev = mountLunes[0].split("on / type")[0].strip()
if root_dev:
return root_dev
rootparam=re_res.group(1)
# check root for /dev/sd view
if re.match("^\/dev\/[a-z]+[0-9]$",rootparam):
return rootparam
# check root set by uuid
uuidpath = '/dev/disk/by-uuid'
if os.access(uuidpath,os.R_OK):
uuidDevs = filter(os.path.islink,
map(lambda x: os.path.join(uuidpath,x),
os.listdir(uuidpath)))
mapUuidDev = dict(map(lambda x:(os.path.basename(x),
os.path.normpath(os.path.join(uuidpath,
os.readlink(x)))), uuidDevs))
if re.match("^UUID=.*$",rootparam):
uuid = rootparam[5:]
if uuid in mapUuidDev:
return mapUuidDev[uuid]
mountLunes = self._runos("mount")
if not mountLunes:
return ""
if type(mountLunes) == types.ListType:
root_dev = mountLunes[0].split("on / type")[0].strip()
if root_dev:
return root_dev
return ""
def get_os_root_type(self):
"""тип носителя (ram, hdd, livecd)"""

Loading…
Cancel
Save