Added support detect root dev by cmdline by UUID.

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

@ -487,10 +487,25 @@ class fillVars(glob_attr):
def get_os_root_dev(self): def get_os_root_dev(self):
"""корневой раздел файловой системы""" """корневой раздел файловой системы"""
for record in open('/proc/cmdline','rb').readlines(): 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: if re_res:
return re_res.group(1) rootparam=re_res.group(1)
else: # 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") mountLunes = self._runos("mount")
if not mountLunes: if not mountLunes:
return "" return ""

Loading…
Cancel
Save