I'd like to trace writes on a specific file, so I've had the idea that I could do this:
I create a probe on do_sys_open
, if the filename
argument matches the pattern I'm looking for I use a trigger to enable a return probe that fetches the returned file descriptor id (it's $retval
). This return probe would have a filter on the common_pid
because I'm only interested in the fd
s returned by do_sys_open
calls that just opened the filename
I want to monitor.
The return probe takes the fd
and enables another probe on sys_write
with a filter on the common_pid
and the fd
.
My hope is that this way I would be able to only trace write
operations on the one file that I'm monitoring.
The problem is that this doesn't work with multi threaded processes. If one process calls open
twice at the same time (using two threads) the above described mechanism could fail. Now I'm trying to figure out a way to do this association between the entry of do_sys_open
and the return probe on do_sys_open
and I would be happy about any suggestions.
PS: I'm not sure if that question belongs to stackoverflow or unix & linux.