Gentoo Archives: gentoo-commits

From: Matt Turner <mattst88@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/
Date: Wed, 28 Oct 2020 21:33:36
Message-Id: 1603920781.b32c42d1bd0e500a85db0cd17b6252dfa753bb61.mattst88@gentoo
1 commit: b32c42d1bd0e500a85db0cd17b6252dfa753bb61
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: Wed Oct 28 21:33:01 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=b32c42d1
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