← Back to team overview

cloud-init-dev team mailing list archive

[Merge] lp:~timjr/cloud-init/cloud-init into lp:cloud-init

 

Tim Daly Jr. has proposed merging lp:~timjr/cloud-init/cloud-init into lp:cloud-init.

Requested reviews:
  cloud init development team (cloud-init-dev)

For more details, see:
https://code.launchpad.net/~timjr/cloud-init/cloud-init/+merge/195166
-- 
https://code.launchpad.net/~timjr/cloud-init/cloud-init/+merge/195166
Your team cloud init development team is requested to review the proposed merge of lp:~timjr/cloud-init/cloud-init into lp:cloud-init.
=== modified file 'cloudinit/util.py'
--- cloudinit/util.py	2013-10-04 21:29:25 +0000
+++ cloudinit/util.py	2013-11-14 03:32:30 +0000
@@ -1737,6 +1737,15 @@
         return None
 
 
+def parse_mtab(path):
+    """On older kernels there's no /proc/$$/mountinfo, so use mtab."""
+    for line in load_file("/etc/mtab").splitlines():
+        devpth, mount_point, fs_type = line.split()[:3]
+        if mount_point == path:
+            return devpth, fs_type, mount_point
+    return None
+
+
 def get_mount_info(path, log=LOG):
     # Use /proc/$$/mountinfo to find the device where path is mounted.
     # This is done because with a btrfs filesystem using os.stat(path)
@@ -1767,8 +1776,11 @@
     # So use /proc/$$/mountinfo to find the device underlying the
     # input path.
     mountinfo_path = '/proc/%s/mountinfo' % os.getpid()
-    lines = load_file(mountinfo_path).splitlines()
-    return parse_mount_info(path, lines, log)
+    if os.path.exists(mountinfo_path):
+        lines = load_file(mountinfo_path).splitlines()
+        return parse_mount_info(path, lines, log)
+    else:
+        return parse_mtab(path)
 
 
 def which(program):


Follow ups