|
|
|
@ -584,6 +584,28 @@ def getRunCommands():
|
|
|
|
|
filter(lambda x:x.isdigit(),
|
|
|
|
|
os.listdir('/proc')))
|
|
|
|
|
|
|
|
|
|
def isFstabMount(pathname):
|
|
|
|
|
"""Get mount point or device from fstab"""
|
|
|
|
|
if pathname == "swap":
|
|
|
|
|
absPath = "swap"
|
|
|
|
|
else:
|
|
|
|
|
absPath = os.path.abspath(pathname)
|
|
|
|
|
# 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"))))
|
|
|
|
|
# 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]
|
|
|
|
|
|
|
|
|
|
def isMount(path):
|
|
|
|
|
"""В случае монтирования директории выдает другой примонтированный путь"""
|
|
|
|
|
absPath = os.path.abspath(path)
|
|
|
|
@ -595,6 +617,22 @@ def isMount(path):
|
|
|
|
|
map(lambda x: [x[0], x[1]], map(lambda x: x.split(" "),
|
|
|
|
|
open(mtabFile)))),[""]))[0]
|
|
|
|
|
|
|
|
|
|
def childMounts(path):
|
|
|
|
|
"""Get all mount points which contain path"""
|
|
|
|
|
if path != "none":
|
|
|
|
|
absPath = os.path.abspath(path)
|
|
|
|
|
else:
|
|
|
|
|
absPath = path
|
|
|
|
|
mtabFile = '/etc/mtab'
|
|
|
|
|
if not os.access(mtabFile,os.R_OK):
|
|
|
|
|
return ""
|
|
|
|
|
return reduce(lambda x,y: x + [y],
|
|
|
|
|
filter(lambda x: absPath in x[0] or absPath in x[1],
|
|
|
|
|
map(lambda x: [x[0], x[1]],
|
|
|
|
|
map(lambda x: x.split(" "),
|
|
|
|
|
open(mtabFile)))),
|
|
|
|
|
[])
|
|
|
|
|
|
|
|
|
|
def pathJoin(*paths):
|
|
|
|
|
"""Складывает пути, в отличии от os.path.join, складывает абсолютные пути"""
|
|
|
|
|
if len(paths)==1:
|
|
|
|
|