How to detect file creation and file modification inside a directory?
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 29 Aug 2022 12:59:11 UTC
Hi. I would like to port a inotify capable program to FreeBSD. I've asked around here and I was recommended to use libinotify-kqueue. This is nice because I wouldn't have to rewrite the inotify logic and I could just reuse it. Or so I thought. My goal is to detect file creation and file changes in a specific directory. The way I do this is to inotify_add_watch(fd, "directory", IN_MODIFY). But I've found out that getting a IN_MODIFY event is pretty much impossible on FreeBSD. Here are my experiments: https://asciinema.org/a/DJMUCLyAWjyHgUQmG4BAfgDRU I'm getting IN_OPEN and IN_ACCESS events. But these are ambiguous. I don't care about opening or accessing the files, I am interested in writing them. How can I detect this? Is libinotify-kqueue capable of this or should I look for alternatives? My other options are raw kqueue() and sysutils/direvent. sysutils/direvent doesn't really have a way to integrate it into a C++ program.