Jump to content
  • Advertisement
Sign in to follow this  
spraff

Recently-accessed files and devices

This topic is 3869 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi. I want to get a list of whatever processes recently accessed a given file (by name or descriptor) or block device. Where is this information logged? Do I have to enable a certain type of logging?

Share this post


Link to post
Share on other sites
Advertisement
In /proc/yourpid/fd you can see the currently opened files.
You could make little script which searches all processes for having a specific file opened.

I don't know of any better way.

Share this post


Link to post
Share on other sites
Quote:
Original post by spraff
Hi. I want to get a list of whatever processes recently accessed a given file (by name or descriptor) or block device. Where is this information logged? Do I have to enable a certain type of logging?

There's no way to get a list of processes that recently accessed a filesystem object or a device because that's done by the kernel, not a process. There may be a way to get the kernel to report what process made what system call, but that's not necessarily useful information since processes come and go rapidly and you're going to have difficulty mapping pid to programs after the process is gone.

What you can do quite effectively on Linux at least is to watch an inode for various transitions and try to capture which process is acessing the file at that point. Use the inotify calls to watch the inode. You are still liable to race conditions so your information is not guaranteed to be completely accurate, but at least you'll be able to get a good idea of file activity.

Share this post


Link to post
Share on other sites
Quote:
Original post by spraff
Hi. I want to get a list of whatever processes recently accessed a given file (by name or descriptor) or block device. Where is this information logged? Do I have to enable a certain type of logging?


For what purpose do you need to do this?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!