Filesystem monitoring question

Dan Nelson dnelson at
Fri Nov 18 17:03:07 GMT 2005

In the last episode (Nov 18), Cornelis Swanepoel said:
> When they have completed a write operation I need to trigger some
> code that will act upon the file just written. This code generates a
> unique id for the file, stats the file, compresses the file(if over
> set limit), generates a preview of the file and stores some info
> about the file and its owner in a MySQL db and a log on a seperate
> machine. It then moves the file to a different location on the same
> machine (which is inaccesible to the NFS and SMB clients) and renames
> it as its unique identifier.

Are you sure you need to hook into the kernel?  Why not just have a
userland process scan the directory every 10 seconds or so for new

Note that NFS has no concept of "file close", just reads and writes, so
you will need to be able to determine whether a file has completed. 
This could be either timestamp based (file not modified in 60 seconds
== done), or if you know the file format, you may be able to validate
the contents (check for zipfile end-of-file marker, etc).

	Dan Nelson
	dnelson at

More information about the freebsd-hackers mailing list