Some examples maintained by Robert Love: http://www.kernel.org/pub/linux/kernel/people/rml/inotify/utils/
> In inotify example, on any event, the name of the file is printed. I
> am looking for absolute path to the file and the filename. I have
> tried programming it, but was unsuccessful. Can you give me some pointers?
“Ah, okay. There is no nontrivial way to do this inside of the kernel (because, among other reasons, file paths are not definite to get to any one file. Also, it is nontrivial to assemble paths inside of the kernel).
So what you need to do is save the mapping back from a given watch descriptor (wd) to the path.
So if you create a watch at /foo/bar/ and it is wd=1, when an event on
wd=1 arrives with payload “baz” you somehow (hash seems smart) map wd=1 back to /foo/bar/ and append baz.
Of course, if you are only watching a single thing, you can hardcode the mapping backward.”
An article about Inotify: http://www-128.ibm.com/developerworks/linux/library/l-inotify.html?ca=dgr-lnxw07Inotify
Kernel Patch: http://www.kernel.org/pub/linux/kernel/people/rml/inotify/utils/
Comments
Leave a comment