From: Jan Fajerski Date: Thu, 12 Dec 2019 08:28:27 +0000 (+0100) Subject: util/system: add unmount_tmpfs helper X-Git-Tag: v15.1.0~522^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=705ed1110138b1e7c77768f97d5acda4a76d868f;p=ceph.git util/system: add unmount_tmpfs helper Thsi unmounts a path if and only if it's a tmpfs mount. Signed-off-by: Jan Fajerski --- diff --git a/src/ceph-volume/ceph_volume/util/system.py b/src/ceph-volume/ceph_volume/util/system.py index 5aaca59af7557..775be4e708be7 100644 --- a/src/ceph-volume/ceph_volume/util/system.py +++ b/src/ceph-volume/ceph_volume/util/system.py @@ -164,6 +164,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