Anything faster than stat(S)? need to determine File or Dir

John F. Haugh II jfh at rpp386.cactus.org
Sun Nov 12 05:06:52 AEST 1989


In article <1989Nov11.154312.6675 at virtech.uucp> cpcahil at virtech.uucp (Conor P. Cahill) writes:
>So you want to replace a single call to stat() with multiple calls to 
>access().  That doesn't make any sense since the major overhead to both
>the stat and access system calls is that the path must be traversed and since
>you are calling access twice, you have to traverse the path twice.

The objective was to take advantage of path-name caching on BSD systems.

Of course, if you know "/path/name" exists, you only need -one- call
to access() with "/path/name/foo" and you save the mumbo-jumbo required
to get data from kernel to user space.

>stat() is the most effecient mechanism that can be used to obtain information
>about a file system entry since it just looks up an inode and copies
>the data to the user's data area.

Probably true.  Now, go off and actually run the benchmarks.  =Always=
question everything.  On some machines copies from system to user address
space are cheap.  On others it can be =very= difficult.  There is a big
difference between a Vax where the supervisor and user have separate
address spaces which can be directly addressed one from the other, and a
PDP-11 where the supervisor and user occupy the same address space and
have no [ MTPD and MFPD aren't implemented on all PDP-11 CPUs! ] easy
way of communicating short of mapping memory all over God's creation.

Anyway, it was only meant to stimulate discussion.  The only portable
and clean solution =is= to use stat().  I can't stand clever hacks,
unless I write them myself ;-)
-- 
John F. Haugh II                        +-Things you didn't want to know:------
VoiceNet: (512) 832-8832   Data: -8835  | The real meaning of EMACS is ...
InterNet: jfh at rpp386.cactus.org         |   ... EMACS makes a computer slow.
UUCPNet:  {texbell|bigtex}!rpp386!jfh   +--<><--<><--<><--<><--<><--<><--<><---



More information about the Comp.unix.wizards mailing list