If I were to do this, I'd add kevent handling to struct mount, and notify when page caches are committed to be written out to a disk (genfs_putpages()). Per-directory notification, being aware of subdirectories, sounds a bit too complex to me. I personally hope that such a complex feature will not be added to VFS. :p
On Tue, Aug 11, 2015 at 11:44 PM, Emmanuel Dreyfus <[email protected]> wrote: > Hello > > Do we have a smart way to monitor a whole filesystem hierarchy for > changes? kqueue seems a good answer at a glance, but as far as I > understand, I need to setup a filter for every single file and > directory in the hierachy, and this can quickly hit kern.maxfiles. > Of course kern.maxfiles can be increased, but that hints this solution > may not scale very well. > > I also though about crawling on the hierarchy using FTS functions and > look for ctime/mtime newer than previous crawl, but that can be CPU > consuming. > > Any idea how this can be done efficiently? > > -- > Emmanuel Dreyfus > [email protected]
