From 0a0c1bb7defe74d93aa55a28eea2d481efd761a4 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Tue, 20 Apr 2021 18:31:31 +0200 Subject: mpm: sysutils: mount: Check both mount point and data path This will return False on ismounted() if a Mount class is mounted, but in the wrong spot. --- mpm/python/usrp_mpm/sys_utils/mount.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'mpm/python/usrp_mpm/sys_utils') diff --git a/mpm/python/usrp_mpm/sys_utils/mount.py b/mpm/python/usrp_mpm/sys_utils/mount.py index 3212a37cb..6dcadf03f 100644 --- a/mpm/python/usrp_mpm/sys_utils/mount.py +++ b/mpm/python/usrp_mpm/sys_utils/mount.py @@ -35,10 +35,11 @@ class Mount(): Returns true if the mount point is mounted """ assert self.devicepath is not None - collection = [line.split()[0] for line in open("/etc/mtab") - if line.split()[0] == self.devicepath] - mounted = len(collection) != 0 - return mounted + with open("/etc/mtab") as mtab_f: + return any( + line.split()[0] == self.devicepath and line.split()[1] == self.mountpoint \ + for line in mtab_f + ) def get_mount_point(self): """ -- cgit v1.2.3