From owner-freebsd-questions@FreeBSD.ORG Wed Jul 14 14:48:51 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C1C9616A4CE for ; Wed, 14 Jul 2004 14:48:51 +0000 (GMT) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5804A43D39 for ; Wed, 14 Jul 2004 14:48:51 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.12.10/8.12.10) id i6EEmnuK087666; Wed, 14 Jul 2004 09:48:49 -0500 (CDT) (envelope-from dan) Date: Wed, 14 Jul 2004 09:48:49 -0500 From: Dan Nelson To: Matthew Seaman , Tyler Durdan , freebsd-questions@freebsd.org Message-ID: <20040714144848.GB8522@dan.emsphone.com> References: <20040714085040.12143.qmail@web52204.mail.yahoo.com> <20040714103114.GC71531@happy-idiot-talk.infracaninophile.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040714103114.GC71531@happy-idiot-talk.infracaninophile.co.uk> X-OS: FreeBSD 5.2-CURRENT X-message-flag: Outlook Error User-Agent: Mutt/1.5.6i Subject: Re: mmap()ed filenames? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Jul 2004 14:48:51 -0000 In the last episode (Jul 14), Matthew Seaman said: > On Wed, Jul 14, 2004 at 01:50:40AM -0700, Tyler Durdan wrote: > > Is there a way to get the filename of an mmap()ed file in the > > current process? For example, in Linux I can open /proc/self/maps > > and get the filenames right there. However, if I try to open > > /proc/getpid()/map on FBSD, the only mapping info is "vnode" or > > "default" on FBSD 4.10-BETA. > > > > Is there any way to convert this info into the filenames of mapped > > files? > > That's a generally hard problem -- given some sort of open file, find > the file name it was opened as. Most unixoid OSes don't record > filenames used on open(2) to go with file descriptors or areas of > mmapped data because it's a waste of space. And there's no reliable > way to work backwards from the open file to a file name. You can use the lsof command in ports, which will dig through the kernel's file name cache and print at least some names. FreeBSD 5.x's /proc/*/map does the same thing for you. If you use lsof, for any files missing filenames, you can try and find the name by running "find / -inum ####", where #### is the number in the NODE column. -- Dan Nelson dnelson@allantgroup.com