]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
util/system: add unmount_tmpfs helper
authorJan Fajerski <jfajerski@suse.com>
Thu, 12 Dec 2019 08:28:27 +0000 (09:28 +0100)
committerJan Fajerski <jfajerski@suse.com>
Thu, 27 Feb 2020 08:43:41 +0000 (09:43 +0100)
Thsi unmounts a path if and only if it's a tmpfs mount.

Signed-off-by: Jan Fajerski <jfajerski@suse.com>
(cherry picked from commit 705ed1110138b1e7c77768f97d5acda4a76d868f)

src/ceph-volume/ceph_volume/util/system.py

index 27d62ea9c621080e2642d62cc4374488e7e21880..4998623373fdfc8b49f341fabceaf74566b99f50 100644 (file)
@@ -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