<p>I'd like to be able to track file read/writes of specific program invocations.  No information about the actual transactions is required, just the file names involved.</p>

<p>Is there a cross platform solution to this?  <br />
What are various platform specific methods?  <br />
On Linux I know there's strace/ptrace (if there are faster methods that'd be good too). <br />I think on mac os there's ktrace.  <br />
What about Windows?</p>

<p>Also, it would be amazing if it would be possible to block (stall out) file accesses until some later time.</p>

<p>Thanks!</p>

[{'answer_id': 21102, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>On Windows you can use the command line tool <a href="http://technet.microsoft.com/en-us/sysinternals/bb896655.aspx" rel="nofollow noreferrer" title="Handle">Handle</a> or the GUI version <a href="http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx" rel="nofollow noreferrer" title="Process Explorer">Process Explorer</a> to see which files a given process has open.</p>\n\n<p>If you\'re looking for a get this information in your own program you can use the <a href="http://www.microsoft.com/whdc/devtools/ifskit/default.mspx" rel="nofollow noreferrer" title="Installable File System Kit">IFS kit</a> from Microsoft to write a file system filter. The file system filter will show all file system operation for all process. File system filters are used in AV software to scan files before they are open or to scan newly created files.</p>\n'}, {'answer_id': 21269, 'author': 'Mat Noguchi', 'author_id': 1799, 'author_profile': 'https://Stackoverflow.com/users/1799', 'pm_score': 1, 'selected': False, 'text': "<p>The short answer is no. There are plenty of platform specific solutions which all probably have similar interfaces, but they aren't inherently cross platform since file systems tend to be platform specific.</p>\n\n<hr>\n\n<blockquote>\n  <p>How do I do it well on each platform?</p>\n</blockquote>\n\n<p>Again, it will depend on the platform :) For Windows, if you want to track reads/writes in flight, you might have to go with IFS. If you just want to get notified of changes, you can use <code>ReadDirectoryChangesW</code> or the NTFS change journal.</p>\n\n<p>I'd recommend using the NTFS change journal only because it tends to be more reliable.</p>\n"}, {'answer_id': 2062612, 'author': 'Emil', 'author_id': 250383, 'author_profile': 'https://Stackoverflow.com/users/250383', 'pm_score': 0, 'selected': False, 'text': "<p>As long as your program launches the processes you want to monitor, you can write a debugger and then you'll be notified every time a process starts or exits. When a process starts, you can inject a DLL to hook the CreateFile system calls for each individual process. The hook can then use a pipe or a socket to report file activity to the debugger.</p>\n"}]
['https://Stackoverflow.com/questions/20852', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1164871/']