From 40dbe591b1943ca61a8d13ee816683643c2366a0 Mon Sep 17 00:00:00 2001 From: Mike Hiretsky Date: Tue, 26 Oct 2010 17:39:06 +0400 Subject: [PATCH] Fix childMounts function. --- pym/cl_utils.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pym/cl_utils.py b/pym/cl_utils.py index 23a4ae1..497d8a2 100644 --- a/pym/cl_utils.py +++ b/pym/cl_utils.py @@ -617,6 +617,13 @@ def isMount(path): map(lambda x: [x[0], x[1]], map(lambda x: x.split(" "), open(mtabFile)))),[""]))[0] +def commonPath(*paths): + """Return common path from list of paths""" + paths = map(lambda x:os.path.abspath(x).split('/'),paths) + res = map(lambda x:x[0], + filter(lambda x:filter(lambda y:x[0]==y,x[1:]),zip(*paths))) + return "/".join(res) + def childMounts(path): """Get all mount points which contain path""" if path != "none": @@ -627,7 +634,8 @@ def childMounts(path): 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], + filter(lambda x: commonPath(absPath,x[0])==absPath or \ + commonPath(absPath,x[1])==absPath, map(lambda x: [x[0], x[1]], map(lambda x: x.split(" "), open(mtabFile)))),