summaryrefslogtreecommitdiff
path: root/lbup/_mountinfo.py
diff options
context:
space:
mode:
Diffstat (limited to 'lbup/_mountinfo.py')
-rw-r--r--lbup/_mountinfo.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/lbup/_mountinfo.py b/lbup/_mountinfo.py
index 110eb6c..e687e96 100644
--- a/lbup/_mountinfo.py
+++ b/lbup/_mountinfo.py
@@ -15,6 +15,12 @@ def _oct_unescape(b):
return b
+class NotAbsRoot(Exception):
+ # This exception is raised for mount entries whose root is not
+ # a valid absolute path (this happens e.g. for persistent namespaces bound
+ # to a file). Such entries are skipped from MountInfo
+ pass
+
class _MountEntry:
"mount ID, bytes"
mount_id = None
@@ -56,7 +62,10 @@ class _MountEntry:
raise ValueError('Invalid device number', devnum)
self.devnum = (major << 8) + minor
- self.root = AbsPath(_oct_unescape(root))
+ root = _oct_unescape(root)
+ if len(root) < 1 or not root.startswith(b'/'):
+ raise NotAbsRoot()
+ self.root = AbsPath(root)
self.mount_point = AbsPath(_oct_unescape(mount_point))
self.mount_opts = mount_opts
@@ -94,7 +103,10 @@ class MountInfo:
def __init__(self, data):
self.entries = []
for line in data.splitlines():
- self.entries.append(_MountEntry(line))
+ try:
+ self.entries.append(_MountEntry(line))
+ except NotAbsRoot:
+ pass
def __str__(self):
return '%s(%d entries)' % (self.__class__.__name__, len(self.entries))