From 2403fcbc78087900f0766b10d58efc69c3eb3733 Mon Sep 17 00:00:00 2001 From: Mike Hiretsky Date: Tue, 19 Oct 2010 16:01:32 +0400 Subject: [PATCH] Add childMounts function for detect mount points. --- pym/cl_utils.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pym/cl_utils.py b/pym/cl_utils.py index 483eb9f..059010d 100644 --- a/pym/cl_utils.py +++ b/pym/cl_utils.py @@ -617,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: