From owner-freebsd-hackers@FreeBSD.ORG Tue Nov 28 15:47:27 2006 Return-Path: X-Original-To: freebsd-hackers@FreeBSD.ORG Delivered-To: freebsd-hackers@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5C7F016A407; Tue, 28 Nov 2006 15:47:27 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (lurza.secnetix.de [83.120.8.8]) by mx1.FreeBSD.org (Postfix) with ESMTP id AAFB043C9F; Tue, 28 Nov 2006 15:46:25 +0000 (GMT) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (cxinax@localhost [127.0.0.1]) by lurza.secnetix.de (8.13.4/8.13.4) with ESMTP id kASFkKMF009716; Tue, 28 Nov 2006 16:46:26 +0100 (CET) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.13.4/8.13.1/Submit) id kASFkKFj009715; Tue, 28 Nov 2006 16:46:20 +0100 (CET) (envelope-from olli) Date: Tue, 28 Nov 2006 16:46:20 +0100 (CET) Message-Id: <200611281546.kASFkKFj009715@lurza.secnetix.de> From: Oliver Fromme To: freebsd-hackers@FreeBSD.ORG, quetzal@zone3000.net, rwatson@FreeBSD.ORG In-Reply-To: <20061128122407.B27930@fledge.watson.org> X-Newsgroups: list.freebsd-hackers User-Agent: tin/1.8.2-20060425 ("Shillay") (UNIX) (FreeBSD/4.11-STABLE (i386)) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.1.2 (lurza.secnetix.de [127.0.0.1]); Tue, 28 Nov 2006 16:46:26 +0100 (CET) Cc: Subject: Re: vn_fullpath question. X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: freebsd-hackers@FreeBSD.ORG, quetzal@zone3000.net, rwatson@FreeBSD.ORG List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Nov 2006 15:47:27 -0000 Robert Watson wrote: > Nikolay Pavlov wrote: > > > Hi. I am trying to extend fstat utility, so that it can use name cache to > > recreate full path at least for text. I have found vn_fullpath function > > usefull in this case. I am newbe in C, so it could be stupid question, but > > could someone explaine what is "struct thread *td" in argument list of this > > function. Is this the thread which opened the vnode initially or it is the > > thread which searches for the vnode? i.e. fstat thread. In any case how i > > can get this *td structure? > > vn_fullpath(9) is a kernel API, not a user API, so can only be invoked from > kernel space. There are unimplemented, undocumented prototypes in the system > call table for __getpath_fromfd() and __getpath_fromaddr(), which are > presumably intended (with adequate permissions) to allow converting file > descriptor indexes into paths, etc. I think Peter dropped them in, but I'm > not sure if he's posted patches. Nikolay, you might want to have a look at the source code of the "lsof" utility (ports/sysutils/lsof). It is able to display path names for file descriptors. Maybe you can borrow an idea from it. It might also be worth mentioning that our friends from the DragonFly BSD project (derived from FreeBSD 4) have added the ability to display path names to their version of the fstat utility. You can look at their cvsweb here: http://www.dragonflybsd.org/cvsweb/src/usr.bin/fstat/ However, I suspect that they have also made modifications to the kernel interfaces in order to support the fstat utility, so their improvements to that utility might not be applicable to FreeBSD. Best regards Oliver -- Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd Any opinions expressed in this message may be personal to the author and may not necessarily reflect the opinions of secnetix in any way. "That's what I love about GUIs: They make simple tasks easier, and complex tasks impossible." -- John William Chambless