From owner-freebsd-questions@FreeBSD.ORG Fri Dec 14 11:32:33 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 DDF66A91 for ; Fri, 14 Dec 2012 11:32:33 +0000 (UTC) (envelope-from cpghost@cordula.ws) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com [209.85.215.54]) by mx1.freebsd.org (Postfix) with ESMTP id 5AAA48FC21 for ; Fri, 14 Dec 2012 11:32:32 +0000 (UTC) Received: by mail-la0-f54.google.com with SMTP id j13so2675793lah.13 for ; Fri, 14 Dec 2012 03:32:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-originating-ip:in-reply-to:references:date :message-id:subject:from:to:cc:content-type:x-gm-message-state; bh=Men1UD5jwS326hzep9eBjUW5SO+dqDdL5KMt4Uel1HI=; b=mv/KC/y4M9b0H8wy6NynZnC04qm3LxQNQ2Q7E1vgfi7l3t3+OyVgg+llGilBXxCtfy tM3XLvUoODD8lgcI3UlfMJLckqALq4uy7CqgFkjn/Xep0jJX+7E7dm1oxPtvAyKwhrYj /JE1xMCMUOAHagSukt/tr9TIrSVlr9fmKFetU7Q7EZKWpOC2quXnjxFWvlr0OTYloMy/ oyXFA/vzBYbyAMn2z8ClBLD5tfVJEkCbe0+gSd3C82gYlfqVLAjaypN1q3pLKrdoX2Zr MPXcA4akCxOPqYR6umCS+M1lsK4oD3q5U0Kbb0JGTs1XOOn0Q/tkr67uyP1f0XBh1kMN 1WBA== MIME-Version: 1.0 Received: by 10.152.122.39 with SMTP id lp7mr2253055lab.0.1355484751659; Fri, 14 Dec 2012 03:32:31 -0800 (PST) Received: by 10.112.7.232 with HTTP; Fri, 14 Dec 2012 03:32:31 -0800 (PST) X-Originating-IP: [93.221.167.38] In-Reply-To: <50CB08BD.2060302@qeng-ho.org> References: <1355478343.11175.YahooMailNeo@web160106.mail.bf1.yahoo.com> <20121214113457.970f6759.freebsd@edvax.de> <50CB08BD.2060302@qeng-ho.org> Date: Fri, 14 Dec 2012 12:32:31 +0100 Message-ID: Subject: Re: Listen to file changes From: "C. P. Ghost" To: freebsd-questions@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQkVOmWMj1rfsF0EtJqmrYtrVdLLndSMhISASD3VI0EulFkJw0VxT0YWa0T8keXh4GKSygfn Cc: 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:32:33 -0000 On Fri, Dec 14, 2012 at 12:08 PM, Arthur Chance wrote: > 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. Exactly. Check out how "tail -f" works in /usr/src/usr.bin/tail/forward.c -cpghost. -- Cordula's Web. http://www.cordula.ws/