[comp.unix.questions] faster fopen

phd_ivo@gsbacd.uchicago.edu (06/19/89)

I have a set of files which never change on my harddisk. I would like
to index them, so that a program can open any of these files without
having to first read the directory entry. Is there a way I can open
files by some other obtained information (e.g. an inode?) and not
waste time with a directory access?

Which function(s) would I use to construct such an index? My Unix
version is Mach (a BSD 4.3 clone in many ways). Help is appreciated.

Thanks.

/ivo

mjs@mentor.cc.purdue.edu (Michael J Spitzer) (06/20/89)

In article <3941@tank.uchicago.edu> phd_ivo@gsbacd.uchicago.edu writes:
>I have a set of files which never change on my harddisk. I would like
>to index them, so that a program can open any of these files without
>having to first read the directory entry. Is there a way I can open
>files by some other obtained information (e.g. an inode?) and not
>waste time with a directory access?

There is no efficent way to access a file from user level given only
its inode number.  The 4.3BSD namei already maintains a name-cache for
name -> inode translations, so you generally won't be "wasting time"
doing a directory lookup if the file has already been referenced.

		-mjs
--
Michael J. Spitzer		Purdue University Computing Center
mjs@mentor.cc.purdue.edu	pur-ee!mentor.cc.purdue.edu!mjs