summaryrefslogtreecommitdiff
path: root/lbup/_mountinfo.py
diff options
context:
space:
mode:
Diffstat (limited to 'lbup/_mountinfo.py')
-rw-r--r--lbup/_mountinfo.py15
1 files changed, 5 insertions, 10 deletions
diff --git a/lbup/_mountinfo.py b/lbup/_mountinfo.py
index bbced58..0328131 100644
--- a/lbup/_mountinfo.py
+++ b/lbup/_mountinfo.py
@@ -142,15 +142,10 @@ class MountInfo:
def mountpoint_for_path(self, path):
"""
- Find the longest mountpoint that is a parent of path.
+ Find the mount entry which contains path.
"""
- best_match = None
- for e in self.mounts.values():
- if (path in e.mount_point and
- (best_match is None or len(best_match) < len(e.mount_point))):
- best_match = e.mount_point
+ for mount in reversed(self.mounts.values()):
+ if path in mount.mount_point:
+ return mount
- if best_match is None:
- raise LookupError('No mountpoint for', path)
-
- return best_match
+ raise LookupError('No mountpoint for', path)