Strace – How to Show Filename/Path for Read/Write Syscalls

strace

If, on Linux, I strace a process, then the reads and writes are shown with the file descriptor handle number. If I look in /proc/$PID/fd I can see the symlinks to the files that correspond to the fd number (if applicable).

Is there anyway to get strace to do this look up for me and (by dereferencing the symlink) show me the filename inside the strace output? It already looks up Linux errno's and truncates & encodes strings, so can it do this too?

Update: I know strace will have shown the open call which shows the path & fd. Which is fine for short running processes. But presume I have a very long running process (measured in days), and did not run the whole thing under strace, merely connect to it later with strace -p.

Best Answer

A quick look through the fine manual turns up:

   -y          Print paths associated with  file  descriptor  argu-
               ments.