From 621d1b9147a0b52cb133fe856b3a13b67711ea57 Mon Sep 17 00:00:00 2001 From: "Jose M. Guisado" Date: Mon, 9 May 2022 13:43:52 +0200 Subject: utils: mount_mkdir success if target is a mountpoint Returns true if target is already a mountpoint. Does not call mount. It's possible that another device might be mounted in the target mountpoint. A future check between the source and target for equal device major:minor must be added. --- src/utils/fs.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/utils') diff --git a/src/utils/fs.py b/src/utils/fs.py index 7500ebd..191fb86 100644 --- a/src/utils/fs.py +++ b/src/utils/fs.py @@ -27,11 +27,17 @@ def find_mountpoint(path): def mount_mkdir(source, target): """ Mounts and creates the mountpoint directory if it's not present. + + Return True if mount is sucessful or if target is already a mountpoint. """ if not os.path.exists(target): os.mkdir(target) + if not os.path.ismount(target): return mount(source, target) + else: + return True + return False -- cgit v1.2.3-18-g5258