How to trace per-file IO operations in Linux?

前端 未结 6 1314
不知归路
不知归路 2020-12-28 09:45

I need to track read system calls for specific files, and I\'m currently doing this by parsing the output of strace. Since read operat

6条回答
  •  暖寄归人
    2020-12-28 09:55

    First, you probably don't need to keep track because mapping between fd and path is available in /proc/PID/fd/.

    Second, maybe you should use the LD_PRELOAD trick and overload in C open, seek and read system call. There are some article here and there about how to overload malloc/free.

    I guess it won't be too different to apply the same kind of trick for those system calls. It needs to be implemented in C, but it should take far less code and be more precise than parsing strace output.

提交回复
热议问题