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

Extend open_files #859

Closed
wants to merge 2 commits into from
Closed

Extend open_files #859

wants to merge 2 commits into from

Conversation

tijko
Copy link
Contributor

@tijko tijko commented Jul 11, 2016

This allows for tracking of anonymous inodes and also adds a field for mnt_id inside of popenfile.

mnt_id This field, present since Linux 3.15, is the ID of the
mount point containing this file. See the description
of /proc/[pid]/mountinfo


popenfile = namedtuple('popenfile', ['path', 'fd', 'position', 'mode',
'flags', 'mnt_id', 'anon_fields'])

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the mnt_id field and a anon_fields which defaults to an empty dict if a regular file.

@giampaolo
Copy link
Owner

What's the use case for this? What's an anonymous file? What's a mnt_id? You're introducing a difference in term of API for one platform, so it must be worth it.

@tijko
Copy link
Contributor Author

tijko commented Jul 12, 2016

Anonymous files are open files that don't have corresponding inodes (i.e. they do not have a path on the filesystem). Examples of these would be created using epoll_create, inotify_init, signalfd, eventfd, and others. Nevertheless, there is still very useful data that is contained in their respective /proc/$pid/fdinfo entries. For instance, if a process had numerous fd's being monitored by an epoll fd, you can then see which events were masked into said poll. Another use (and the one that I had been needing) would be if you have an inotify fd in a process and needed to see what the inode of contained watch is, you would be able to find this under the inotifys ino field.

The mnt_id has been exposed since Linux 3.15. The mnt_id is needed when a there are two file descriptors with the same path but, are on different mount points with separate namespaces.

There was definitely more that could have been included in this commit but, I felt as though I wanted to see how you felt about this kind of change first before adding more into it.

@a-sk
Copy link

a-sk commented Jul 12, 2017

I would like to see mountinfo information for a given process.

@giampaolo
Copy link
Owner

Closing this out as outdated.

@giampaolo giampaolo closed this Dec 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants