#include <stat.h> question answered

Victor Lee vtl at stolaf.UUCP
Sat Nov 5 09:37:35 AEST 1983


It looks like the "<stat.h>" peculiarity only exists in 4.1BSD.
The problem with the documentation (the reference to <stat.h>)
seems to have made it into 4.2BSD, though I have only checked
one system.

Thanks to Guy Harris, Geoff Collyer, Bill Shannon and Doug Gwyn for the
"best" answers.

Victor Lee -- St. Olaf College, Northfield MN -- ihnp4!stolaf!vtl
					      -- decvax!stolaf!vtl

The following is a summary of the responses:
------
Looking at a V7 "/usr", an S3 "/usr" and a 4.2BSD "/usr" we have online,
there doesn't seem to be a "stat.h" in "/usr/include", only in
"/usr/include/sys".  I'd vote for '#include <sys/stat.h>'.  I suspect there
was a typo in the V7 manual when it said <stat.h>, somebody at Berkeley took it
seriously, and when it didn't work instead of correcting their code they
put a copy of "stat.h" in "/usr/include".

------
<stat.h> is a hang-over from PWB (System I) where there was no
/usr/include/sys; Berkeley has propagated this stupidity.  There's no
great mystery.

------
<stat.h> was a mistake that crept into the Berkeley system at some
point.  The correct file is <sys/stat.h>.  This has been fixed in
4.2bsd.  A similar thing happened to several other files, most
notably <sys/dir.h>.

------
There should not be any /usr/include/stat.h.  The correct location
for the file is /usr/include/sys/stat.h (you must include
/usr/include/sys/types.h before <sys/stat.h> to properly define the
data types).

I have no idea when Berkeley screwed this up, but other UNIXes have
<sys/stat.h> in the right place.

------



More information about the Comp.unix.wizards mailing list