Date: Fri, 14 Dec 2012 01:45:43 -0800 (PST) From: Jack Mc Lauren <jack.mclauren@yahoo.com> To: "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org> Subject: Listen to file changes Message-ID: <1355478343.11175.YahooMailNeo@web160106.mail.bf1.yahoo.com>
next in thread | raw e-mail | index | archive | help
Hi all=0AI want to monitor files access and change time. How can I listen t= o specific file or=A0directory to monitor ? I'm coding with c.=0A=0AThanks = In advance ... =A0=A0 From owner-freebsd-questions@FreeBSD.ORG Fri Dec 14 10:34:57 2012 Return-Path: <owner-freebsd-questions@FreeBSD.ORG> 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 7F2DAAA9 for <freebsd-questions@freebsd.org>; Fri, 14 Dec 2012 10:34:57 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx02.qsc.de (mx02.qsc.de [213.148.130.14]) by mx1.freebsd.org (Postfix) with ESMTP id 3B1A18FC08 for <freebsd-questions@freebsd.org>; Fri, 14 Dec 2012 10:34:57 +0000 (UTC) Received: from r56.edvax.de (port-92-195-51-39.dynamic.qsc.de [92.195.51.39]) by mx02.qsc.de (Postfix) with ESMTP id 09F0E25400; Fri, 14 Dec 2012 11:34:55 +0100 (CET) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id qBEAYvVd002723; Fri, 14 Dec 2012 11:34:57 +0100 (CET) (envelope-from freebsd@edvax.de) Date: Fri, 14 Dec 2012 11:34:57 +0100 From: Polytropon <freebsd@edvax.de> To: Jack Mc Lauren <jack.mclauren@yahoo.com> Subject: Re: Listen to file changes Message-Id: <20121214113457.970f6759.freebsd@edvax.de> In-Reply-To: <1355478343.11175.YahooMailNeo@web160106.mail.bf1.yahoo.com> References: <1355478343.11175.YahooMailNeo@web160106.mail.bf1.yahoo.com> Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org> X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Polytropon <freebsd@edvax.de> List-Id: User questions <freebsd-questions.freebsd.org> List-Unsubscribe: <http://lists.freebsd.org/mailman/options/freebsd-questions>, <mailto:freebsd-questions-request@freebsd.org?subject=unsubscribe> List-Archive: <http://lists.freebsd.org/pipermail/freebsd-questions> List-Post: <mailto:freebsd-questions@freebsd.org> List-Help: <mailto:freebsd-questions-request@freebsd.org?subject=help> List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-questions>, <mailto:freebsd-questions-request@freebsd.org?subject=subscribe> X-List-Received-Date: Fri, 14 Dec 2012 10:34:57 -0000 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=A0directory 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. --=20 Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1355478343.11175.YahooMailNeo>