commit:     b32c42d1bd0e500a85db0cd17b6252dfa753bb61
Author:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 22 18:52:46 2020 +0000
Commit:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Wed Oct 28 21:33:01 2020 +0000
URL:        https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=b32c42d1

catalyst: Rewrite ismount() to use libmount

Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>

 catalyst/support.py | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/catalyst/support.py b/catalyst/support.py
index 4458ed20..ddbd9ab9 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -8,6 +8,8 @@ import time
 from pathlib import Path
 from subprocess import Popen
 
+import libmount
+
 from catalyst import log
 
 BASH_BINARY = "/bin/bash"
@@ -182,15 +184,13 @@ def read_makeconf(mymakeconffile):
 
 def ismount(path):
     """Like os.path.ismount, but also support bind mounts"""
-    if os.path.ismount(path):
+    path = Path(path)
+    if path.is_mount():
         return True
 
-    a = os.popen("mount")
-    mylines = a.readlines()
-    a.close()
-    for line in mylines:
-        mysplit = line.split()
-        if Path(path) == Path(mysplit[2]):
+    cxt = libmount.Context()
+    while (fs := cxt.mtab.next_fs()) is not None:
+        if path == Path(fs.target):
             return True
 
     return False

Reply via email to