mirror of
https://github.com/JakeHillion/drgn.git
synced 2024-12-23 17:53:07 +00:00
helpers: fix d_path() for bind mounts
d_path() for bind mounts returns the wrong path. E.g., for mount --bind /tmp/foo /tmp/foo print_mounts() shows '/tmp/foo/foo'. Let's do exactly what prepend_path() in the kernel does, which fixes this case.
This commit is contained in:
parent
5fbe1b1ba9
commit
20a7c8c85f
@ -148,18 +148,19 @@ def d_path(path_or_vfsmnt, dentry=None):
|
||||
|
||||
components = []
|
||||
while True:
|
||||
while True:
|
||||
d_parent = dentry.d_parent.read_()
|
||||
if dentry == d_parent:
|
||||
if dentry == mnt.mnt.mnt_root:
|
||||
mnt_parent = mnt.mnt_parent.read_()
|
||||
if mnt == mnt_parent:
|
||||
break
|
||||
components.append(dentry.d_name.name.string_())
|
||||
components.append(b'/')
|
||||
dentry = d_parent
|
||||
mnt_parent = mnt.mnt_parent.read_()
|
||||
if mnt == mnt_parent:
|
||||
dentry = mnt.mnt_mountpoint.read_()
|
||||
mnt = mnt_parent
|
||||
continue
|
||||
d_parent = dentry.d_parent.read_()
|
||||
if dentry == d_parent:
|
||||
break
|
||||
dentry = mnt.mnt_mountpoint
|
||||
mnt = mnt_parent
|
||||
components.append(dentry.d_name.name.string_())
|
||||
components.append(b'/')
|
||||
dentry = d_parent
|
||||
if components:
|
||||
return b''.join(reversed(components))
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user