summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-10-15 07:04:27 +0200
committerAnton Khirnov <anton@khirnov.net>2023-10-15 07:05:08 +0200
commit187248696e4398d00e703d97bdf8cd281bb79a05 (patch)
treece682278dbc5471686ad454be4f309d3cf51a701
parent0fa705c1171557e59f0c35eb14e42f7d5efec326 (diff)
_mountinfo: add parent reference to mounts
-rw-r--r--lbup/_mountinfo.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/lbup/_mountinfo.py b/lbup/_mountinfo.py
index 35be209..973e135 100644
--- a/lbup/_mountinfo.py
+++ b/lbup/_mountinfo.py
@@ -48,6 +48,9 @@ class _MountEntry:
raw_entry = None
"raw mountinfo line, bytes"
+ parent = None
+ "parent mountinfo entry, None if it does not exit"
+
def __init__(self, line):
self.raw_entry = line
@@ -118,6 +121,13 @@ class MountInfo:
self.mounts = mounts
+ for e in mounts.values():
+ try:
+ e.parent = mounts[e.parent_id]
+ except KeyError:
+ pass
+
+
def __str__(self):
return '%s(%d entries)' % (self.__class__.__name__, len(self.mounts))