From owner-freebsd-hackers@freebsd.org Tue Nov 10 21:23:35 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E36D8A2C272 for ; Tue, 10 Nov 2015 21:23:35 +0000 (UTC) (envelope-from radovanovic@gmail.com) Received: from mail-wm0-x232.google.com (mail-wm0-x232.google.com [IPv6:2a00:1450:400c:c09::232]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 790FC138B for ; Tue, 10 Nov 2015 21:23:35 +0000 (UTC) (envelope-from radovanovic@gmail.com) Received: by wmdw130 with SMTP id w130so89061714wmd.0 for ; Tue, 10 Nov 2015 13:23:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=jWUKE/lll9o8jvKahn5UDq7n4S4UsTpAsibB32D58Is=; b=ZDfep9VcDPwvxjXcS7i4OGUXek/cS4hje4YsAt4z5hy1yp0SDzIvUYFQNhwBHOakqL x4XAGPD6LD+zSt1EIy+Dvc5DPfgDntjq2WoTM9BbI8BKoSem5PX54vvk0ELO1tO6GJhq hftZ2zOGMBEChdPCtoJ1/AypXJNXUf/ZSjxp07rxgO/xRxcBQ3Z6PF9vah4Wk/3lyKXN CMqRWSODnk7TV1FXB8k7QKi4I9/9VvP2XdkLKooqZE2O0OiUWCeoSN7j9y/PNVRptDtL OVPKAx0uGBeIiHtQ91TXzV6ToWsOqwFaJMj5MOVp2zLjtb9TRORuKUjmOUIAMoLMneXr lzkw== X-Received: by 10.194.133.233 with SMTP id pf9mr5377428wjb.71.1447190613871; Tue, 10 Nov 2015 13:23:33 -0800 (PST) Received: from zmaj.softwarehood.com (93-87-243-129.dynamic.isp.telekom.rs. [93.87.243.129]) by smtp.googlemail.com with ESMTPSA id j8sm5571303wjf.1.2015.11.10.13.23.32 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Nov 2015 13:23:33 -0800 (PST) Message-ID: <56426054.2070007@gmail.com> Date: Tue, 10 Nov 2015 22:23:32 +0100 From: Ivan Radovanovic User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:17.0) Gecko/20130812 Thunderbird/17.0.8 MIME-Version: 1.0 To: Konstantin Belousov CC: freebsd-hackers@FreeBSD.org Subject: Re: Detecting new file name after receiving kevent's NOTE_RENAME References: <5641A2A5.7070909@gmail.com> <20151110081421.GL2257@kib.kiev.ua> In-Reply-To: <20151110081421.GL2257@kib.kiev.ua> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Nov 2015 21:23:36 -0000 On 11/10/15 09:14, Konstantin Belousov napisa: >> >I am wondering is there some more clever way to get this new name >> >(kernel is obviously aware of it, otherwise it couldn't notify >> >descriptor about rename)? > > The most correct way is to use sysctl kern.proc.filedesc and look > for the path of the given file descriptor. This is inefficient since > kern.proc.filedesc returns information about all opened files for the > process. Unfortunately it seems that this method (at least using kinfo_getfile(3)) doesn't work - as soon as file is renamed kf_path returned contains only zeros. Shame, it sounded like perfect solution for the problem...