summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2013-11-19 12:20:26 -0500
committerScott Moser <smoser@ubuntu.com>2013-11-19 12:20:26 -0500
commit18eba1557bd7af83b64d2c95c3eafc8345f7f74f (patch)
tree065a7f961fcb67f768ceebd69e39bd551e6ae409
parentaafb9b5557e2be1fa7d8a37b285207ea3fede3d8 (diff)
parent9af91df4446ec7e62bc780612e05f869c269ccf0 (diff)
downloadvyos-cloud-init-18eba1557bd7af83b64d2c95c3eafc8345f7f74f.tar.gz
vyos-cloud-init-18eba1557bd7af83b64d2c95c3eafc8345f7f74f.zip
fix issue with get_mount_info on older kernels
This removes the requirement for /proc/PID/mountinfo, which was added in linux kernel 2.6.26. We could potentially re-visit this and read /proc/mounts rather than /proc/mtab, but mtab proves effective in testing. LP: #1248625
-rw-r--r--ChangeLog2
-rw-r--r--cloudinit/util.py16
2 files changed, 16 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index ca856e6b..33f43530 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,8 @@
- support apt-add-archive with 'cloud-archive:' format. (LP: #1244355)
- Change SmartOS verb for availability zone (LP: #1249124)
- documentation fix for boothooks to use 'cloud-init-per'
+ - fix resizefs module by supporting kernels that do not have
+ /proc/PID/mountinfo. (LP: #1248625) [Tim Daly Jr.]
0.7.3:
- fix omnibus chef installer (LP: #1182265) [Chris Wing]
- small fix for OVF datasource for iso transport on non-iso9660 filesystem
diff --git a/cloudinit/util.py b/cloudinit/util.py
index 9e6e0a73..a8ddb390 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -1737,6 +1737,15 @@ def parse_mount_info(path, mountinfo_lines, log=LOG):
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 @@ def get_mount_info(path, log=LOG):
# 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):