Trigger inotify file change event

1.3k views Asked by At

How can I trigger linux inotify() file change event programmatically, without real read/write operation?

Inotify man page has only watching functions.

Actually I have to do it without any file operation. Maybe there is a possibility to do this via some system call ?

1

There are 1 answers

4
donjuedo On

You can change attributes to trigger an event for inotify() to report. You might change permissions, for example.

I used udev rules to write to a file upon thumb drive insertion, then inotify() to detect that write, and kicked off scripts to process everything on the drive, all without user interaction. inotify() is a very useful call.