From e51a767d92c21af547a92caf677f2753cbe99b44 Mon Sep 17 00:00:00 2001 From: Mike Hiretsky Date: Tue, 19 Oct 2010 12:00:27 +0400 Subject: [PATCH] Move function isFstabMount from calculate-install. --- pym/cl_utils.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pym/cl_utils.py b/pym/cl_utils.py index 6f97380..483eb9f 100644 --- a/pym/cl_utils.py +++ b/pym/cl_utils.py @@ -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)