Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!cs.utexas.edu!uunet!virtech!cpcahil From: cpcahil@virtech.UUCP (Conor P. Cahill) Newsgroups: comp.unix.wizards Subject: Re: stat of i-node Message-ID: <1120@virtech.UUCP> Date: 2 Sep 89 15:19:37 GMT References: <172@bmers58.UUCP> <19362@mimsy.UUCP> <179@bmers58.UUCP> Organization: Virtual Technologies Inc Lines: 32 In article <179@bmers58.UUCP>, davem@bmers58.UUCP (Dave Mielke) writes: > The problem with fstat is that it requires an open which also does a > name lookup. This proves to be very slow when the directories get > large. I need a way to get the information that stat would return > without the expense of a name lookup. The i-node is the obvious key to > the data, but I am unaware of any primitive that gives an application > program direct access to the data via its actual key. I would > appreciate any assistence that anyone can offer. There is no system call primitive that gives you the capability to access a file based upon it's inode number. In fact one of the *true* blessings of UNIX is it's concept of accessing everyting (including devices) through the same namespace. (Of course they broke this with the system V IPC implementations) If your problem is that it is taking too long to search a really big directory, you probably should change the software that is maintaining that directory so that it uses some sub-directories. I worked on a project that had the same problem with mail message attachments. These attachments were put into a single attachment directory on the system. Over time, this directory would grow to have thousands of entries which caused access time to be outragously high. The solution was to change the software to use a series of sub-directories (100 of them) which resulted in a significant performace gain. message attachments -- +-----------------------------------------------------------------------+ | Conor P. Cahill uunet!virtech!cpcahil 703-430-9247 ! | Virtual Technologies Inc., P. O. Box 876, Sterling, VA 22170 | +-----------------------------------------------------------------------+