diff --git a/lib/hypervisor/hv_chroot.py b/lib/hypervisor/hv_chroot.py index e9f2317f5cee2f749d6b67eaa435ca34c6feb22f..f33fed2041319e86d5986214546087e17fcbb928 100644 --- a/lib/hypervisor/hv_chroot.py +++ b/lib/hypervisor/hv_chroot.py @@ -83,23 +83,15 @@ class ChrootManager(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):