SUMMARY: inode -> filename mapping

From: Stuart Whitby <>
Date: Fri Jun 28 2002 - 12:10:35 EDT
Don't recognise the subject?  Probably because I didn't
ask the question.  However, Tristan Ball followed up my
previous summary about how lsof queries the kernel for
the open files, and since it's excellent information, I 
figured I'd share it.  Thanks Tristan :)

Inside the solaris kernel there is a structure for each CPU, and a 
linked list of process structures which are scheduled for that CPU. 
Linked to each process structure is a list of vnodes, including the in 
memory representations of the inodes that the process has open. All lsof 
does is loop through the CPU structures, finding processes, and 
therefore the attached inodes. (open files).

Seperate to that, is the DNLC cache, a hashed cache. When lsof finds a 
vnode which maps to an on disk inode, it uses that inode as a key to the 
DNLC to find a name. If it's not in the DNLC, lsof would have to search 
the entire filesystem to find the correct inode, and therefore it's name.

The key point to remember is that to the OS, the FS is an inode based 
database. Finenames and directories are a seperate index into that 
database, purely for the convinience of those of us too lazy to memorise 
inode numbers.


sunmanagers mailing list
Received on Fri Jun 28 12:12:26 2002

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:42:47 EST