From 7d4ac01275a2b9ab03ca9eca1b168846474b1bad Mon Sep 17 00:00:00 2001 From: Jan Fajerski Date: Thu, 12 Dec 2019 09:28:27 +0100 Subject: [PATCH] util/system: add unmount_tmpfs helper Thsi unmounts a path if and only if it's a tmpfs mount. Signed-off-by: Jan Fajerski (cherry picked from commit 705ed1110138b1e7c77768f97d5acda4a76d868f) --- src/ceph-volume/ceph_volume/util/system.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/ceph-volume/ceph_volume/util/system.py b/src/ceph-volume/ceph_volume/util/system.py index 27d62ea9c6210..4998623373fdf 100644 --- a/src/ceph-volume/ceph_volume/util/system.py +++ b/src/ceph-volume/ceph_volume/util/system.py @@ -175,6 +175,19 @@ class tmp_mount(object): encryption.dmcrypt_close(self.device) +def unmount_tmpfs(path): + """ + Removes the mount at the given path iff the path is a tmpfs mount point. + Otherwise no action is taken. + """ + _out, _err, rc = process.call(['findmnt', '-t', 'tmpfs', '-M', path]) + if rc != 0: + logger.info('{} does not appear to be a tmpfs mount'.format(path)) + else: + logger.info('Unmounting tmpfs path at {}'.format( path)) + unmount(path) + + def unmount(path): """ Removes mounts at the given path -- 2.39.5