Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>On Linux, I'd definitely use <a href="http://linux.die.net/man/1/strace" rel="noreferrer"><code>strace</code></a> -- it's simple and powerful. E.g.:</p> <pre><code>$ strace -o/tmp/blah -f -eopen,read bash -c "cat ciao.txt" </code></pre> <p>runs the requested command (including the subprocesses it spawns, due to <code>-f</code>) and also leaves in <code>/tmp/blah</code> (120 lines in my case for this example) detailing all the open and read calls made by these processes, and their results. </p> <p>You do need a little processing afterwards to extract just the set of files that were successfully read, as you require; for example, with Python, you could do:</p> <pre><code>import re linere = re.compile(r'^(\d+)\s+(\w+)\(([^)]+)\)\s+\=\s*(.*)$') def main(): openfiles = dict() filesread = set() with open('/tmp/blah') as f: for line in f: mo = linere.match(line) if mo is None: print "Unmatched line %r" % line pid, command, args, results = mo.groups() if command == 'open': fn = args.split(',', 1)[0].strip('"') fd = results.split(' ', 1)[0] openfiles[fd] = fn elif command == 'read': if results != '0': fd = args.split(',', 1)[0] filesread.add(openfiles[fd]) else: print "Unknown command %r" % command print sorted(filesread) </code></pre> <p>This is a bit oversimplified (you need to watch some other syscalls such as <code>dup</code> &amp;c) but, I hope, shows the gist of the work needed. In my example, this emits:</p> <pre><code>['/lib/libc.so.6', '/lib/libdl.so.2', '/lib/libncurses.so.5', '/proc/meminfo', '/proc/sys/kernel/ngroups_max', '/usr/share/locale/locale.alias', 'ciao.txt'] </code></pre> <p>so it also counts as "reads" those that are done to get dynamic libraries &amp;c, not just "data files"... at syscall level, there's little difference. I imagine you could filter non-data files out, if that's what you need.</p> <p>I find <code>strace</code> so handy for such purposes that, were I tasked to do the same job on Windows, my first try would be to go for <a href="http://www.intellectualheaven.com/default.asp?BH=projects&amp;H=strace.htm" rel="noreferrer">StraceNT</a> -- not 100% compatible, and of course the underlying syscall names &amp;c differ, but I think I could account for these differences in my Python code (preparing and executing the <code>strace</code> command, and post-processing the results).</p> <p>Unfortunately, some other Unix systems, to my knowledge, only offer this kind of facilities if you're root (super-user) -- e.g. on Mac OS X you need to go via <code>sudo</code> in order to execute such tracing utilities as <code>dtrace</code> and <code>dtruss</code>; I don't know of a straightforward port of <code>strace</code> to the Mac, nor other ways to perform such tasks without root privileges.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload