diff options
-rw-r--r-- | lbup/_mountinfo.py | 15 | ||||
-rw-r--r-- | lbup/targets.py | 2 |
2 files changed, 7 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) diff --git a/lbup/targets.py b/lbup/targets.py index bd53b1e..3f86563 100644 --- a/lbup/targets.py +++ b/lbup/targets.py @@ -49,6 +49,8 @@ def _resolve_mntdev(mntinfo, dirs): mountpoint = None fstype = None for d in dirs: + d = AbsPath(d) + mp = mntinfo.mountpoint_for_path(d) e = list(mntinfo.entries_for_mountpoint(mp)) |