From owner-freebsd-questions@FreeBSD.ORG Mon Jan 23 19:37:38 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CBFCF106566C for ; Mon, 23 Jan 2012 19:37:38 +0000 (UTC) (envelope-from pieter@degoeje.nl) Received: from mx.utwente.nl (mx3.utsp.utwente.nl [130.89.2.14]) by mx1.freebsd.org (Postfix) with ESMTP id F1C768FC19 for ; Mon, 23 Jan 2012 19:37:37 +0000 (UTC) Received: from [130.89.165.91] (nox.student.utwente.nl [130.89.165.91]) by mx.utwente.nl (8.12.10/SuSE Linux 0.7) with ESMTP id q0NJCZZB007803; Mon, 23 Jan 2012 20:12:35 +0100 Message-ID: <4F1DB120.3030103@degoeje.nl> Date: Mon, 23 Jan 2012 20:12:32 +0100 From: Pieter de Goeje User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 MIME-Version: 1.0 To: Info References: <4F1D3BE5.9030607@o-notation.org> In-Reply-To: <4F1D3BE5.9030607@o-notation.org> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-UTwente-MailScanner-Information: Scanned by MailScanner. Contact icts.servicedesk@utwente.nl for more information. X-UTwente-MailScanner: Found to be clean X-UTwente-MailScanner-SpamScore: s X-UTwente-MailScanner-From: pieter@degoeje.nl X-Spam-Status: No Cc: freebsd-questions@freebsd.org Subject: Re: kqueue and filenames X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Jan 2012 19:37:38 -0000 On 23-1-2012 11:52, Info wrote: > I'm using kqueue for detecting file-events; for additional information > I add a struct to udata, when registering an event with kevent. > When I delete an event, will be udata deleted too, or do I have to > manage the memory for the structs with an own implementation? It is up to you to free udata. > kevent is triggered when a file is renamed. How do I get the new name? > Is there an extra function? In the moment, I see only the possibility > by searching the filesystem(folder) for a new name. A good question to which I unfortunately do not have the answer to. I think in principle it is impossible to get the file name by file descriptor alone (it could have multiple names). In practice I would just treat NOTE_RENAME as a sequence of unlink/link. I believe tools like lsof use the system name cache to map fds to names, but that is not very reliable. If you need more help with kqueue you might try the hackers@ mailing list, more technical people read that list. Regards, Pieter de Goeje