Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fs mount point identification in 'tools/opensnoop.py' #5153

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dennisorlando
Copy link

Hi :)
Not sure if this addresses existing issues, a quick look didn't give me any result..
Anyways: there are a ton of filesystem roots in the linux filetree which mess up the output of opensnoop.py.
E.g. when working with files in /tmp, let's say /tmp/averynicefile, only /averynicefile gets displayed since that file is in the "root" / of a tmpfs file system.
This simple commit reconstructs the mountpoint information by passing the device identifier (dev_t) field of the BPF's PWD directory to the userspace python program, which retrieves the mountpoint information by grepping /proc/self/mountinfo

@dennisorlando
Copy link
Author

Update: I just stumbled upon #4285 but that's literally 2 years old... + it's outdated: struct vfsmount doesn't appear to include mnt_parent anymore

@xingfeng2510
Copy link
Contributor

xingfeng2510 commented Nov 23, 2024

Update: I just stumbled upon #4285 but that's literally 2 years old... + it's outdated: struct vfsmount doesn't appear to include mnt_parent anymore

Not outdated actually, struct vfsmount never includes mnt_parent, the fixup still works now, you should try it.

And, unwind dentry by reading /proc/self/mountinfo frequently is inefficient. #4285 refers to kernel function d_path, which returns the path of a dentry and unwinds in kernel.

for example, when reading such a link file /proc/793073/fd/4, it converts dentry to full path /usr/local/agent/log/agent.log, which contains at least two mountpoints, by invoking kernel functions do_proc_readlink -> d_path -> __prepend_path source link: d_path

# ls -l /proc/793073/fd/4
lrwx------ 1 root root 64 Nov 17 22:41 /proc/793073/fd/4 -> /usr/local/agent/log/agent.log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants