Monitoring FS changes

Mark Felder feld at FreeBSD.org
Sun Jan 3 21:08:38 UTC 2016



On Thu, Dec 31, 2015, at 01:24, Chris Stankevitz wrote:
> Hi,
> 
> I have a directory /foo that recursively contain ~250,000
> files/directories.
> 
> I would like my application to know when a file is added, removed, or 
> modified under /foo.  Is there a way to do that with FreeBSD?
> 
> I believe on linux a facility called iNotify accomplishes this.
> 
> On OSX a facility called FSEvents accomplishes this.
> 
> kqueue apparently requires me to open every file and/or directory in my 
> tree... which won't work because I have so many.
> 
> Is there any other option?  Perhaps
> 
> i=0
> while (true)
> {
>   zfs snapshot pool/foo@${i}
>   zfs diff pool/foo@${i-1} pool/foo@${i}
>   ++i
> }
> 

Yes, Linux has inotify (just be aware it doesn't actually work on inodes
like it indicates: changes to alternative hard links are ignored if
they're not in the file path you're monitoring), OSX has fsevents,
Solaris derivatives have File Events Notification, and we're stuck with
kqueue which doesn't scale. I'm not aware of anything else being
available for us.

If someone, anyone out there is capable of bringing us something that
does scale it would be greatly appreciated. Lots of nice Linux software
uses this, but when they do port to FreeBSD we have to do full
filesystem scans. It's such a waste.


-- 
  Mark Felder
  ports-secteam member
  feld at FreeBSD.org


More information about the freebsd-fs mailing list