On Fri, Sep 05, 2003 at 03:37:34PM +0300, Vitali Malicky wrote:

> There is  a question, sorry if you find it stupid.
> 
> I need to control a bunch of files.
> 
> As soon as any of these files changes it should be immediately
> rechecked and correct chmod and chown reset on this file(s).
> 
> Though I can do it from a simple script executed by the cron every
> five minutes or so, I'd like them to be controlled by a process which
> would monitor any possible changes in these files and would do the
> job upon the event.
> 
> Can anybody give me a hint?

Are you any good at C programming? If so, check out the man page for
kqueue(2) -- you can register a series of kevents with the kernel, and
it will inform your process whenever one of those events occurs.  One
of the standard "event filters" is EVFILT_VNODE, which will tell you
when a vnode (ie file, in this case) gets modified, including such
changes as unlinking the file, renaming it, change of attributes
(ownership, mode) etc.

        Cheers,

        Matthew

-- 
Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                      Savill Way
PGP: http://www.infracaninophile.co.uk/pgpkey         Marlow
Tel: +44 1628 476614                                  Bucks., SL7 1TH UK

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to