Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/inotify.h>
- #include <stdio.h>
- #include <errno.h>
- /* size of the event structure, not counting name */
- #define EVENT_SIZE (sizeof (struct inotify_event))
- /* reasonable guess as to size of 1024 events */
- #define BUF_LEN (1024 * (EVENT_SIZE + 16))
- int fd;
- int wd;
- char buf[BUF_LEN];
- int len, i = 0;
- int main()
- {
- fd = inotify_init();
- wd = inotify_add_watch(fd, "foo.txt", IN_MODIFY);
- len = read (fd, buf, BUF_LEN);
- while (i < len) {
- struct inotify_event *event;
- event = (struct inotify_event *) &buf[i];
- if (event->mask & IN_IGNORED)
- puts("IN_IGNORED");
- if (event->mask & IN_MODIFY)
- puts("IN_MODIFY");
- i += EVENT_SIZE + event->len;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment