From owner-freebsd-questions@FreeBSD.ORG Fri Dec 14 11:09:23 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5F51465C for ; Fri, 14 Dec 2012 11:09:23 +0000 (UTC) (envelope-from freebsd@qeng-ho.org) Received: from blue.qeng-ho.org (blue.qeng-ho.org [217.155.128.241]) by mx1.freebsd.org (Postfix) with ESMTP id C634A8FC08 for ; Fri, 14 Dec 2012 11:09:22 +0000 (UTC) Received: from fileserver.home.qeng-ho.org (localhost [127.0.0.1]) by fileserver.home.qeng-ho.org (8.14.5/8.14.5) with ESMTP id qBEB8jqQ076740; Fri, 14 Dec 2012 11:08:46 GMT (envelope-from freebsd@qeng-ho.org) Message-ID: <50CB08BD.2060302@qeng-ho.org> Date: Fri, 14 Dec 2012 11:08:45 +0000 From: Arthur Chance User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Polytropon Subject: Re: Listen to file changes References: <1355478343.11175.YahooMailNeo@web160106.mail.bf1.yahoo.com> <20121214113457.970f6759.freebsd@edvax.de> In-Reply-To: <20121214113457.970f6759.freebsd@edvax.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: "freebsd-questions@freebsd.org" , Jack Mc Lauren X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Dec 2012 11:09:23 -0000 On 12/14/12 10:34, Polytropon wrote: > On Fri, 14 Dec 2012 01:45:43 -0800 (PST), Jack Mc Lauren wrote: >> Hi all >> I want to monitor files access and change time. How can I >> listen to specific file or directory to monitor ? I'm coding with c. > > If I remember correctly, what you're searching for does already > exist: FAM - the File Alteration Monitor. It's in the ports > collection (/usr/ports/devel/fam). There are also C++ and > Ruby bindings, maybe you can also interface with C... > > For C: Maybe using readdir() et al. could be useful? Also see > "man 5 inode", "man 5 dir" and "man 3 readdir" for more info. > And struct ufs2_dinode in /usr/include/ufs/ufs/dinode.h should > have the information you need to parse for; maybe also check > the FILE type in /usr/include/stdio.h for access flags. See also kevent(2) and the EVFILT_VNODE system filter.