Mapping pfiles output to files


While I was analyzing the performance characteristics of one of my Solaris 9 Oracle database servers, I needed to map a file descriptor listed in the pfiles output to the actual file name on the file system (Solaris 10 provides this information in the pfiles output, which is yet another reason to run Solaris 10). When you run pfiles on a process or core file, it gives you the type (e.g., socket, fifo, regular file, etc) of file that the file descriptor references, and the inode number associated with the file:

$ pfiles 12345

[ ..... ]

269: S_IFREG mode:0660 dev:228,119007 ino:61 uid:102 gid:315 size:10729046016
O_RDWR|O_DSYNC|O_LARGEFILE FD_CLOEXEC
[ ..... ]

To map the inode listed after the “ino:” field to the file name, I first used the “dev:” identifier to locate the device the file was located on:

$ cd /dev/vx/dsk/foodg

$ ls -la

total 4
drwxr-xr-x 2 root root 512 Sep 18 2005 .
drwxr-xr-x 5 root root 512 Sep 18 2005 ..
brw------- 1 root root 228,119000 Sep 18 2005 u16
brw------- 1 root root 228,119001 Sep 18 2005 u17
brw------- 1 root root 228,119002 Sep 18 2005 u18
brw------- 1 root root 228,119003 Sep 18 2005 u19
brw------- 1 root root 228,119004 Sep 18 2005 u20
brw------- 1 root root 228,119005 Sep 18 2005 u57
brw------- 1 root root 228,119006 Sep 18 2005 u58
brw------- 1 root root 228,119007 Sep 18 2005 u59
brw------- 1 root root 228,119008 Sep 18 2005 u60
brw------- 1 root root 228,119009 Sep 18 2005 u61
brw------- 1 root root 228,119010 Sep 18 2005 u62
brw------- 1 root root 228,119011 Sep 18 2005 u63
brw------- 1 root root 228,119012 Sep 18 2005 u64
brw------- 1 root root 228,119013 Sep 18 2005 u65
brw------- 1 root root 228,119014 Sep 18 2005 u66

Once I had the device name and associated mount point, I used the trusty old find utility to locate the file by it’s inode number:

$ find /u59 -inum 61 -ls

61 10477592 -rw-rw---- 1 oracle dba 10729046016 Sep 18 13:15 /u59/oradata/blatch/data01.dbf

Some folks might be wondering why I didn’t use lsof. Well, unfortunately the version of lsof available in various package repositories isn’t able to interpret the VxFS metadata, and I would have spent more time building the new package than analayzing the problem I was trying to solve. Viva la Solaris!

This article was posted by Matty on 2006-09-22 08:55:00 -0400 -0400