From a188f1ef745d1aafe153c6cc9d88fc57fad77f51 Mon Sep 17 00:00:00 2001
From: Balazs Lecz <leczb@google.com>
Date: Mon, 5 Jul 2010 17:57:27 +0000
Subject: [PATCH] LXC: use utils.GetMounts()

Signed-off-by: Balazs Lecz <leczb@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 lib/hypervisor/hv_lxc.py | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/lib/hypervisor/hv_lxc.py b/lib/hypervisor/hv_lxc.py
index 9dfcbad36..81e416ef7 100644
--- a/lib/hypervisor/hv_lxc.py
+++ b/lib/hypervisor/hv_lxc.py
@@ -99,23 +99,15 @@ class LXCHypervisor(hv_base.BaseHypervisor):
   def _GetMountSubdirs(path):
     """Return the list of mountpoints under a given path.
 
-    This function is Linux-specific.
-
     """
-    #TODO(iustin): investigate and document non-linux options
-    #(e.g. via mount output)
-    data = []
-    fh = open("/proc/mounts", "r")
-    try:
-      for line in fh:
-        _, mountpoint, _ = line.split(" ", 2)
-        if (mountpoint.startswith(path) and
-            mountpoint != path):
-          data.append(mountpoint)
-    finally:
-      fh.close()
-    data.sort(key=lambda x: x.count("/"), reverse=True)
-    return data
+    result = []
+    for _, mountpoint, _, _ in utils.GetMounts():
+      if (mountpoint.startswith(path) and
+          mountpoint != path):
+        result.append(mountpoint)
+
+    result.sort(key=lambda x: x.count("/"), reverse=True)
+    return result
 
   @classmethod
   def _InstanceDir(cls, instance_name):
-- 
GitLab