From owner-freebsd-hackers@FreeBSD.ORG Fri Nov 18 17:03:07 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org 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 2157116A41F for ; Fri, 18 Nov 2005 17:03:07 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id B4BF043D76 for ; Fri, 18 Nov 2005 17:03:06 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.13.1/8.13.3) id jAIH35W4059783; Fri, 18 Nov 2005 11:03:05 -0600 (CST) (envelope-from dan) Date: Fri, 18 Nov 2005 11:03:05 -0600 From: Dan Nelson To: Cornelis Swanepoel Message-ID: <20051118170304.GI62141@dan.emsphone.com> References: <20051118120039.BB3EE16A421@hub.freebsd.org> <20051118094225.E72964@bowser.eecs.harvard.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-OS: FreeBSD 5.4-STABLE X-message-flag: Outlook Error User-Agent: Mutt/1.5.11 Cc: freebsd-hackers@freebsd.org, Daniel Ellard Subject: Re: Filesystem monitoring question X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Nov 2005 17:03:07 -0000 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 files? 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@allantgroup.com