1 |
commit: c24962dfa39cf76bcae004b3e90ce9b7ddf3c66c |
2 |
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Oct 22 18:52:46 2020 +0000 |
4 |
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Oct 29 03:33:10 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=c24962df |
7 |
|
8 |
catalyst: Rewrite ismount() to use libmount |
9 |
|
10 |
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org> |
11 |
|
12 |
catalyst/support.py | 14 +++++++------- |
13 |
1 file changed, 7 insertions(+), 7 deletions(-) |
14 |
|
15 |
diff --git a/catalyst/support.py b/catalyst/support.py |
16 |
index 4458ed20..ddbd9ab9 100644 |
17 |
--- a/catalyst/support.py |
18 |
+++ b/catalyst/support.py |
19 |
@@ -8,6 +8,8 @@ import time |
20 |
from pathlib import Path |
21 |
from subprocess import Popen |
22 |
|
23 |
+import libmount |
24 |
+ |
25 |
from catalyst import log |
26 |
|
27 |
BASH_BINARY = "/bin/bash" |
28 |
@@ -182,15 +184,13 @@ def read_makeconf(mymakeconffile): |
29 |
|
30 |
def ismount(path): |
31 |
"""Like os.path.ismount, but also support bind mounts""" |
32 |
- if os.path.ismount(path): |
33 |
+ path = Path(path) |
34 |
+ if path.is_mount(): |
35 |
return True |
36 |
|
37 |
- a = os.popen("mount") |
38 |
- mylines = a.readlines() |
39 |
- a.close() |
40 |
- for line in mylines: |
41 |
- mysplit = line.split() |
42 |
- if Path(path) == Path(mysplit[2]): |
43 |
+ cxt = libmount.Context() |
44 |
+ while (fs := cxt.mtab.next_fs()) is not None: |
45 |
+ if path == Path(fs.target): |
46 |
return True |
47 |
|
48 |
return False |