2003-01-16 18:52:22

by Jeroen van Disseldorp

[permalink] [raw]
Subject: Detecting changes in a directory tree

Hi,

For an application I'm writing I need to know if files in a certain
directory tree were modified and/or deleted by another process. I
assume that that tree is mounted on the machine that my app is running
on. The device it has mounted on can be a local HD, but it can also be
hosted remotely and mounted over nfs.

I know of FAM, but this is documented to only watch a directory 1 level
deep, and I need the whole tree to be monitored. Does anyone know a
solution for this? Does the kernel provide facilities for this?

(Please send me replies directly or via CC, as I am not subscribed to
the kernel mailinglist)

Regards,
Jeroen van Disseldorp mailto:[email protected]
--
Be the change you wish to see in the world -- Gandhi


2003-01-17 00:50:47

by Adrian Bunk

[permalink] [raw]
Subject: Re: Detecting changes in a directory tree

On Thu, Jan 16, 2003 at 01:58:36PM -0500, Jeroen van Disseldorp wrote:

> Hi,

Hi Jeroen,

> For an application I'm writing I need to know if files in a certain
> directory tree were modified and/or deleted by another process. I
> assume that that tree is mounted on the machine that my app is running
> on. The device it has mounted on can be a local HD, but it can also be
> hosted remotely and mounted over nfs.
>
> I know of FAM, but this is documented to only watch a directory 1 level
> deep, and I need the whole tree to be monitored. Does anyone know a
> solution for this? Does the kernel provide facilities for this?
>...

with a kernel >= 2.4.19 dnotify [1] might do what you want.

> Regards,
> Jeroen van Disseldorp mailto:[email protected]

cu
Adrian

[1] http://www.student.lu.se/~nbi98oli/dnotify.html

--

"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed

2003-01-17 03:49:38

by Jeroen van Disseldorp

[permalink] [raw]
Subject: Re: Detecting changes in a directory tree

On Thursday 16 January 2003 19:59, Adrian Bunk wrote:
> with a kernel >= 2.4.19 dnotify [1] might do what you want.

Close, but is doesn't do it quite for me. I understand the problem of
traversing inodes back up the tree, once they have changed, to see
whether someone wants to receive an event. However I am not convinced
that this is necessary. The idea I had was the following:

I would like to have a passthrough kind of filesystem (lets call is myfs
for now) that can mount other parts of the filesystem and just maps
everything to the original tree. For instance, I would mount /var on
/mnt/var, using myfs. Everything from /mnt/var is directly mapped to
/var.

The clue of this is that myfs *knows* about the notification, because it
has to send notification to userspace for *every* inode. So if anything
is written in /mnt/var, it can notify userspace. BTW for my app it
would be acceptable that direct changes in /var don't lead to any
events.

I haven't thought out the interface to userspace yet, but I think that
can be worked out. Let me know if I'm making any sense here.

Regards,
Jeroen mailto:[email protected]
--
Be the change that you want to see in the world -- Gandhi

2003-01-17 12:49:34

by Jon Burgess

[permalink] [raw]
Subject: Re: Detecting changes in a directory tree



There are a number of existing userland filesystems, try:

http://lufs.sourceforge.net/lufs/intro.html
"LUFS is a hybrid userspace filesystem framework supporting an indefinite number
of filesystems (localfs, sshfs, ftpfs, cardfs and cefs implemented so far)
transparently for any application."

http://uservfs.sourceforge.net/
"POrtable Dodgy Filesystems in Userland (hacK) version 2. Once upon a time,
there was project called podfuk. It used nfs, and nfs sucks. On one sunny night,
its author had nothing better to do, and he started creating fake cache manager
for coda. It worked in two days, and it worked pretty good. At least, ugly nfs
was gone."

http://hierfs.sourceforge.net/
"Welcome to the hierachical storage filesystem. This project aims to create a
simple way of managing a vast amount of data over multiple CD-R media. This is
done by creating a virtual filesystem simulating all files on the CDs as if they
were online on the harddisk. When a file is accessed, a dialog box asks for the
correct CD. So any program can be used to acces the data without needing to know
the files are on CD. "

http://vcfs.sourceforge.net/
"VCFS is the Virtual CVS FileSystem. VCFS provides a user-space NFS server that
allows local or remote CVS repositories to be mounted as a filesystem. It works
with existing CVS servers, including those used by SourceForge."

Jon