I got a little script that lists the number of inotify watches per process. That usually gets me what I want, but now I would like to know which files are being watched. I assume this is possible and that a inotify watch corresponds to a file being monitored by an inotify instance?
I also assume that I can build upon what I currently have in that script. For instance,
sudo find /proc/*/fd -lname anon_inode:inotify | cut -d "/" -f 3
gets me a list of processes with inotify
file descriptors. If I look at the info for one of the file descriptors, I get what I assume is a list of file handles/watches:
$ sudo cat /proc/50679/fdinfo/19
pos: 0
flags: 00
mnt_id: 15
inotify wd:8 ino:640001 sdev:800001 mask:3cc ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:01006400feaad211
inotify wd:7 ino:a08da sdev:800001 mask:3cc ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:da080a0094019e8f
inotify wd:6 ino:840003 sdev:800001 mask:3cc ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:030084005ae9e3df
inotify wd:5 ino:840002 sdev:800001 mask:3cc ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:020084000d506c1f
inotify wd:4 ino:840001 sdev:800001 mask:3cc ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:01008400e47bab26
inotify wd:3 ino:32004e sdev:800001 mask:3cc ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:4e003200488122df
inotify wd:2 ino:320001 sdev:800001 mask:3cc ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:01003200545a9f32
inotify wd:1 ino:2 sdev:800001 mask:3cc ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:0200000000000000
I was hoping I could find out which file f_handle:01003200545a9f32
corresponds to, basically translate a f_handle
in /proc/../fdinfo/ to a file name.
strace
: hassansin.github.io/…