Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Feb 2003 11:18:26 -0800
From:      Wes Peters <wes@softweyr.com>
To:        Robert Watson <rwatson@freebsd.org>, Kevin Fogleman <krfogleman@comcast.net>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Monitoring changes in extended attributes?
Message-ID:  <200302241118.26679.wes@softweyr.com>
In-Reply-To: <Pine.NEB.3.96L.1030224102046.39246D-100000@fledge.watson.org>
References:  <Pine.NEB.3.96L.1030224102046.39246D-100000@fledge.watson.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Monday 24 February 2003 07:25, Robert Watson wrote:
> On Wed, 12 Feb 2003, Kevin Fogleman wrote:
> > Is there an existing way to monitor the entire filesystem for changes
> > to any file, particularly changes in extended attributes?
> >
> > I'm looking to write a program that builds an index of all
> > user-accessable extended attributes for every file in the filesystem
> > and then updates that index in real time according to modifications to
> > existing files' attributes, creation of new files and deletion of
> > files. I've read over the documentation for kqueue, but some things
> > were left unclear.  For example, it appears that kqueue needs a file
> > descriptor for each file that one would want to monitor, making any
> > large-scale file monitoring impractical.  Is there any other way in
> > FreeBSD to be notified of file modifications in a way that would allow
> > one to monitor the whole file system or large portions of it?  Also,
> > I'm not very knowledgable about file system conventions, so I'm
> > wondering how one would detect the creation of new files?  I don't
> > really need to know whether a particular attribute changed, but rather
> > just whether any of them changed.
> >
> > BTW, I have posted this question earlier to freebsd-questions, but
> > nobody answered and, judging by the content of the other questions on
> > that list, I thought that my question would be more appropriate here.
>
> Currently, you can monitor particular files for meta-data changes, which
> include extended attribute modifications, and you can monitor directories
> for changes, which might include the addition of a new name (and hence
> possibly a file).  However, currently there's no way to monitor at the
> granularity of a file system for events such as "Some EA changed" or "A
> new file was allocated".  I guess such primitives haven't generally been
> needed in the past, although I can certainly imagine scenarios where they
> might be used.  Kqueue is the vehicle the two events I identified above
> can be monitored with, and it's certainly possible to imagine adding new
> event categories to monitor a file system for global events, assuming
> it's a local file system.  However, then the question becomes "Once I
> know that a file has been added, how do I find it", which I would guess
> generally results in a recursive search, at which point I suspect you
> might as well just re-search the entire fs once in a while anyway.  The
> functionality you're looking for sounds a bit more database-esque than in
> line with a traditional file store.

BeFS (in BeOS) had some interesting capabilities along these lines.

It seems to me that the ability to monitor a mounted filesystem for inode 
changes would be a big plus.  If you need to get from the inode number back 
to the filename or directory entry, you could either search or maintain an 
in-memory cache of the directory structure.

-- 
         "Where am I, and what am I doing in this handbasket?"

Wes Peters                                                   Softweyr LLC
wes@softweyr.com                                     http://softweyr.com/



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200302241118.26679.wes>