From owner-freebsd-hackers Mon Feb 24 11:18:39 2003 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8ED2B37B401; Mon, 24 Feb 2003 11:18:37 -0800 (PST) Received: from smtp-relay.omnis.com (smtp-relay.omnis.com [216.239.128.27]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9F73D43FA3; Mon, 24 Feb 2003 11:18:34 -0800 (PST) (envelope-from wes@softweyr.com) Received: from salty.rapid.stbernard.com (corp-2.ipinc.com [199.245.188.2]) by smtp-relay.omnis.com (Postfix) with ESMTP id 5DD7543C33; Mon, 24 Feb 2003 11:18:29 -0800 (PST) From: Wes Peters Organization: Softweyr.com To: Robert Watson , Kevin Fogleman Subject: Re: Monitoring changes in extended attributes? Date: Mon, 24 Feb 2003 11:18:26 -0800 User-Agent: KMail/1.5 Cc: freebsd-hackers@freebsd.org References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200302241118.26679.wes@softweyr.com> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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