read() returns as many events as are available and will fit in buffer.
struct inotify_event { /* Structure returned by reading inotify fd */
int wd; /* Watch descriptor */
uint32_t mask; /* Mask of events */
uint32_t cookie; /* Unique cookie connecting related events
(rename from one directory to another) */
uint32_t len; /* Length of name */
char name[]; /* Optional name (relative to watch directory);
may be padded with null bytes */
};
/* Size of record == sizeof(inotify_event) + len */
| mask bit | Input? (passed to inotfy_add_watch()) |
Output? (returned by read()) |
Description |
| IN_ACCESS | Yes | Yes | File was accessed |
| IN_MODIFY | Yes | Yes | File was modified |
| IN_ATTRIB | Yes | Yes | Metadata change (permissions, timestamps, extended attributes, etc.) |
| IN_CLOSE_WRITE | Yes | Yes | File opened for writing was closed |
| IN_CLOSE_NOWRITE | Yes | Yes | File not opened for writing was closed |
| IN_OPEN | Yes | Yes | File was opened |
| IN_MOVED_FROM | Yes | Yes | Moved from X |
| IN_MOVED_TO | Yes | Yes | Moved to Y |
| IN_CREATE | Yes | Yes | File/directory created under this directory |
| IN_DELETE | Yes | Yes | File/directory deleted under this directory |
| IN_DELETE_SELF | Yes | Yes | Monitored file/directory was deleted |
| IN_MOVE_SELF | Yes | Yes | Monitored file/directory was moved |
| IN_ALL_EVENTS | Yes | -- | All of the above |
| IN_ONLYDIR | Yes | n | Only watch path if it is directory |
| IN_DONT_FOLLOW | Yes | n | Don't follow symbolic link in path |
| IN_MASK_ADD | Yes | n | Add events to existing mask |
| IN_ONESHOT | Yes | n | Monitor path once, then remove from list |
| IN_UNMOUNT | n | Yes | File system was unmounted |
| IN_Q_OVERFLOW | n | Yes | Event queue overflowed |
| IN_IGNORED | n | Yes | Watch was explicitly removed, or automatically removed because file was deleted or file system was unmounted |
| IN_ISDIR | n | Yes | The subject of this event is a directory (this bit is set in addition some other bit above) |
(C) 2006, Michael Kerrisk