#include #include #include #include int main(int argc, char* argv[]) { printf("Start watching changes...\n"); int fds = inotify_init(); int watchds = inotify_add_watch(fds, "/home/kalyttab", IN_MODIFY | IN_ATTRIB | IN_MOVED_FROM | IN_MOVED_TO | IN_DELETE | IN_CREATE); struct inotify_event* event = malloc(4096); printf("Watch Descriptor: %x, File Descriptor: %x\n", watchds, fds); int count = 0; while ((count = read(fds, event, 4096)) > 0) { struct inotify_event* event_ptr = event; while (count > 0) { printf("Event %x occured in \"%s\", Cookie: %x\n", event_ptr->mask, event_ptr->name, event_ptr->cookie); int size = offsetof(struct inotify_event, name) + event_ptr->len; count -= size; } } close(fds); return 0; }