FindFirstChangeNotification (Was: miranda)

Hans Leidekker hans at
Tue Mar 4 09:53:03 CST 2003

On Saturday 01 March 2003 20:53, Eric Pouech wrote:

> > fixme:file:FindFirstChangeNotificationA this is not supported yet
> > (non-trivial).
> >
> > <sigh> Am I going to regret enquiring what this means? :-)
> >
> > So my question is in two parts;
> >
> > (1) is the above something that I can work on and/or help anyone else
> > work on?
> We sometimes doubt will be able to support correctly
> FindFirstChangeNotification under Wine without proper kernel support,
> which doesn't exist yet...
> so it'd be a hard task

You know, a couple of weeks ago I looked at the possibilities
of a FAM based implementation, as suggested in bugrequest #588:
There are other solutions (dnotify, fmon on FreeBSD), but FAM is
available now on RedHat and Mandrake distributions, which gives 
it an avantage. Furthermore, FAM will fall back to a polling
strategy when kernel level support is absent. I think it's
the best candidate.

The real question is: does FAM provide enough functionality to
implement all of FindFirstChangeNotification and friends? The short
answer is no. For example, Win32 change notifications can be obtained
for complete subtrees, e.g  you can ask to be notified of changes
to C:\ and everything beneath. As far as I can tell FAM only 
supports directory level notifications.

In addition, I found that there isn't a straight mapping from Win32
change events to FAM monitoring events: under Win32 you ask for
directories to be watched for certain events: file deletions,
added files, changes to file attributes and some more. With FAM,
you watch a directory OR a file for changes. This could mean that,
in order to mimic Win32 behaviour, one would have to watch both the
specified directory and ALL files in that directory to gather
all necessary information. And then FAM doesn't support file 
deletion events. We could of course regain those by doing some
extra bookkeeping, but it starts getting hairy.

All of this did not scare me enough however to actually implement
some of this API on top of FAM. And you know what, it already works!
It's really neat to see that Word file dialog automatically refresh
when you add a file to the directory you're looking at!

I will try to clean it up sometime and submit what I have. Don't
know if it's worth doing that though since it implements so little 
of the API. Another thing is that I wrote it against wine-20030115
and I saw that in CVS there are changes to the files (no pun!) I

Oh, and file monitoring eats a lot of CPU right now, since
my implementation amounts to polling FAMPending() from change_signaled() 
to see if there are any outstanding events. A better way to use FAM is
to use poll()/select() on an fd that FAM supplies. But of course
we can't block in a wineserver call. So I tried to have the wineserver
poll loop do that for me, but I was unsuccessful so far.



Hans Leidekker               Vrije Universiteit
                             Dienst IT
Systeembeheer Campusnetwerk  De Boelelaan 1105 
                             1081 HV  Amsterdam 
+31 (0) 20 444 5385          The Netherlands 

More information about the wine-devel mailing list