From cf6f50e5284acfe0e970d1922a23b62f9241b1ca Mon Sep 17 00:00:00 2001 From: "Jose M. Guisado" Date: Thu, 4 May 2023 09:58:04 +0200 Subject: utils: add umount_all function Add utility function to unmount any mountpoint present in the /mnt folder. This function is a simplified version of the legacy bash function ogUnmountAll used in several operations. --- src/utils/fs.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/utils/fs.py b/src/utils/fs.py index a0c12d4..49da7ce 100644 --- a/src/utils/fs.py +++ b/src/utils/fs.py @@ -69,6 +69,15 @@ def umount(target): return not proc.returncode +def umount_all(): + """ + Umounts all mountpoints present in the /mnt folder. + """ + for path in ['/mnt/'+child for child in os.listdir('/mnt/')]: + if os.path.ismount(path): + umount(path) + + def get_usedperc(mountpoint): """ Returns percetage of used filesystem as decimal number. -- cgit v1.2.3-18-g5258