|
|
|
@ -591,27 +591,37 @@ def getRunCommands():
|
|
|
|
|
return map(getCmd,filter(lambda x:x.isdigit(),
|
|
|
|
|
os.listdir('/proc')))
|
|
|
|
|
|
|
|
|
|
def isFstabMount(pathname):
|
|
|
|
|
def isFstabMount(pathname,mapDevUuid={}):
|
|
|
|
|
"""Get mount point or device from fstab"""
|
|
|
|
|
def removeQuotes(s):
|
|
|
|
|
return s.replace('"','').replace("'","")
|
|
|
|
|
if pathname == "swap":
|
|
|
|
|
absPath = "swap"
|
|
|
|
|
else:
|
|
|
|
|
absPath = os.path.abspath(pathname)
|
|
|
|
|
if not mapDevUuid:
|
|
|
|
|
devuuid = '/dev/disk/by-uuid'
|
|
|
|
|
mapDevUuid.update(
|
|
|
|
|
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)))))
|
|
|
|
|
# convert fstab to
|
|
|
|
|
# [['/dev/sda3', '/', '', 'reiserfs', 'noatime', '', '', '0', '2\n'],
|
|
|
|
|
# ['/dev/sda5', '/var/calculate', 'reiserfs', 'noatime', '0', '0\n']]
|
|
|
|
|
listFstab = filter(lambda x: len(x) >= 4,
|
|
|
|
|
map(lambda x: filter(lambda x: x,
|
|
|
|
|
x.replace('\t',' ').split(' ')),
|
|
|
|
|
filter(lambda x: not x.startswith('#') and x.strip(),
|
|
|
|
|
open("/etc/fstab"))))
|
|
|
|
|
x.replace('\t',' ').split(' ')),
|
|
|
|
|
filter(lambda x: not x.startswith('#') and x.strip(),
|
|
|
|
|
open("/etc/fstab"))))
|
|
|
|
|
# get mount point or device or dir
|
|
|
|
|
return filter(lambda x: x!=absPath,
|
|
|
|
|
reduce(lambda x,y: y,
|
|
|
|
|
filter(lambda x: absPath in x and x[1] != "none",
|
|
|
|
|
map(lambda x: [x[0],
|
|
|
|
|
x[1] if x[2] != "swap" else "swap"],
|
|
|
|
|
listFstab)),[""]))[0]
|
|
|
|
|
reduce(lambda x,y: y,
|
|
|
|
|
filter(lambda x: absPath in x and x[1] != "none",
|
|
|
|
|
map(lambda x: [mapDevUuid.get(removeQuotes(x[0]),x[0]),
|
|
|
|
|
x[1] if x[2] != "swap" else "swap"],
|
|
|
|
|
listFstab)),[""]))[0]
|
|
|
|
|
|
|
|
|
|
def isMount(path):
|
|
|
|
|
"""В случае монтирования директории выдает другой примонтированный путь"""
|
|
|
|
|