From owner-freebsd-hackers@FreeBSD.ORG Mon Nov 12 22:05:37 2007 Return-Path: Delivered-To: freebsd-hackers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 294F216A417 for ; Mon, 12 Nov 2007 22:05:37 +0000 (UTC) (envelope-from yuri@rawbw.com) Received: from mail0.rawbw.com (mail0.rawbw.com [198.144.192.41]) by mx1.freebsd.org (Postfix) with ESMTP id 1153F13C48E for ; Mon, 12 Nov 2007 22:05:36 +0000 (UTC) (envelope-from yuri@rawbw.com) Received: from mail0.rawbw.com (localhost [127.0.0.1]) by mail0.rawbw.com (8.13.8/8.13.8) with ESMTP id lACM5Pcw011596; Mon, 12 Nov 2007 14:05:25 -0800 (PST) Received: (from www@localhost) by mail0.rawbw.com (8.13.8/8.13.8/Submit) id lACM5PpZ011593; Mon, 12 Nov 2007 14:05:25 -0800 (PST) X-Authentication-Warning: mail0.rawbw.com: www set sender to yuri@rawbw.com using -f Received: from sj-webwasher.Cadence.COM (sj-webwasher.Cadence.COM [158.140.1.25]) by webmail.rawbw.com (IMP) with HTTP for ; Mon, 12 Nov 2007 14:05:25 -0800 Message-ID: <1194905125.4738ce25a968c@webmail.rawbw.com> Date: Mon, 12 Nov 2007 14:05:25 -0800 From: Yuri To: Robert Watson References: <1194896018.4738aa922f776@webmail.rawbw.com> <20071112214243.Y81124@fledge.watson.org> In-Reply-To: <20071112214243.Y81124@fledge.watson.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.2.1 X-Originating-IP: 158.140.1.25 X-Mailman-Approved-At: Mon, 12 Nov 2007 22:07:10 +0000 Cc: freebsd-hackers@FreeBSD.org Subject: Re: How to get filename of an open file descriptor X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Nov 2007 22:05:37 -0000 Robert, Thank you for your response. I attempted to compile procstat but procstat.h seems to be missing in tgz. Yuri Quoting Robert Watson : > On Mon, 12 Nov 2007, Yuri wrote: > > > I am looking for functionality similar to Linux's /proc//fd/. I > > need to know what is the file name of an open file descriptor. > > > > /proc//fd is missing on FreeBSD. > > > > There's something called 'fdescfs'. In /dev/fd/ it shows the list of file > > > descriptors. But they don't seem to be symbolic links to open files. And > > also it only shows FDs of the current process. > > > > So why there's no /proc//fd in FreeBSD? And how do I work around this? > > > Or should I just invest time and write a kernel patch implementing > > /proc//fd/? > > You can give these patches a try: > > http://www.watson.org/~robert/freebsd/20071112-procstat.tgz > > They reflect a work-in-progress procstat(1) tool, which inspects process > state > in various ways. They are developed against 8-CURRENT, but likely still > apply > fairly easily to 7-STABLE. They suffer various deficiencies, such as relying > > on the name cache in-kernel to generate file paths for mapped files and open > > file descriptors, so don't currently work with devfs nodes (for example). > However, they may do what you need. Any feedback would be most welcome. > > Robert N M Watson > Computer Laboratory > University of Cambridge > --