It took a lot longer than I thought, but fam source is now available at
http://oss.sgi.com/projects/fam/.
I'd be really surprised if it builds on SCO OpenServer without a fair amount
of effort, but either way I'd be interested to hear how it goes.
If getting it to build looks like it will take more time than you want to
spend, and you just want to use the fam source for an example of polling the
contents of a directory, files for the fam daemon are in fam-2.6.0/fam.
(Keep in mind that polling is not what fam is all about; normally it only
polls if the kernel doesn't have imon support.)
Pollster.c++ keeps a list of Interests that are being polled. (Each
Interest represents a single monitored file or directory.) Files are pretty
simple; every time they're polled, stat() is called on them, and their
modification time is compared to the time which was stored last time the
file was checked. Probably more interesting to you is
DirectoryScanner::done(), which determines whether files have been added or
removed. It keeps a list of the directory's contents; for every element
returned by readdir(), it sees whether the element is new/removed/changed.
The code is actually pretty hard to follow... depending on what you want to
use the code for, you might be better off if you can just get fam to build &
run, and use FAMMonitorDirectory() etc. to talk to fam (see the fam(3X) man
page, which is included in the source).
--Rusty
|