Date: Wed, 14 Jul 2004 09:48:49 -0500 From: Dan Nelson <dnelson@allantgroup.com> To: Matthew Seaman <m.seaman@infracaninophile.co.uk>, Tyler Durdan <ewemasq@yahoo.com>, freebsd-questions@freebsd.org Subject: Re: mmap()ed filenames? Message-ID: <20040714144848.GB8522@dan.emsphone.com> In-Reply-To: <20040714103114.GC71531@happy-idiot-talk.infracaninophile.co.uk> References: <20040714085040.12143.qmail@web52204.mail.yahoo.com> <20040714103114.GC71531@happy-idiot-talk.infracaninophile.co.uk>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040714144848.GB8522>