[mod.computers.apollo] Bug in "struct stat"

holtz%cascade.carleton.cdn%ubc.CSNET@CSNET-RELAY.ARPA (Neal Holtz) (12/28/85)

A warning, though I suspect its been discovered many times.
The header file <sys/stat.h> that we got with Aegis SR9 CC is
wrong.  stat(3)  (BSD4.2 version) returns a few more words
of data than the header file leaves room for.  Nasty.  The
correct version seems to be (as in the CLIB manual, page 3-72 BSD4.2):

/*  stat.h, /usr/include, 06/19/85
    stat structure and related flags

    Changes:
        06/19/85 jrw  original coding.  */


/*  stat buffer -- returned from stat(2):  */

struct  stat {
        dev_t   st_dev;         /* device id */
        ino_t   st_ino;         /* inode number */
        ushort  st_mode;        /* mode (see below) */
        short   st_nlink;       /* # links */
        ushort  st_uid;         /* uid of owner */
        ushort  st_gid;         /* gid of owner */
        dev_t   st_rdev;        /* dev id for b/c spec files */
        off_t   st_size;        /* file size, in bytes */
        time_t  st_atime;       /* data access time */
        time_t  st_mtime;       /* data mod time */
        time_t  st_ctime;       /* attribute mod time */
};


/*  st_mode word definition:  */

#define S_IFMT  0170000         /* format mask: */
#define         S_IFDIR 0040000     /* directory */
#define         S_IFCHR 0020000     /* character special */
#define         S_IFBLK 0060000     /* block special */
#define         S_IFREG 0100000     /* regular */
#define         S_IFIFO 0010000     /* pipe (fifo) */

#define S_ISUID  04000          /* set user id on execution */
#define S_ISGID  02000          /* set group id on execution */
#define S_ISVTX  01000          /* save pure text (sticky bit; unimplemented) */
#define S_IREAD  00400          /* read  (owner) */
#define S_IWRITE 00200          /* write  (owner) */
#define S_IEXEC  00100          /* execute (file) | search (dir) (owner) */

apollo@ucbvax.UUCP (12/30/85)

    A warning, though I suspect its been discovered many times.
    The header file <sys/stat.h> that we got with Aegis SR9 CC is
    wrong.  stat(3)  (BSD4.2 version) returns a few more words
    of data than the header file leaves room for.  Nasty.

This does seem to be a point of confusion.  The problem here is that
the sysV and bsd4.2 versions of stat() return two different structs.

In general, you have to use the right set of include files when you
compile your program.  This will happen automatically unless your
/usr/include has been corrupted.  In your case, I suspect that you
installed domain/ix first, then later installed the C product, which
wiped out your include files.  The correct order is C first, then
domain/ix.  This ought to be spelled out in the release notes.
-------

apollo@ucbvax.UUCP (01/04/86)

WOW.  Jim Ward lives on !!!!
-- 
Bob Ollerton; Celerity Computing; 
9692 Via Excelencia; San Diego, Ca 92126; (619) 271 9940
{decvax || ucbvax || ihnp4}!sdcsvax!celerity!bobbyo
                              akgua!celerity!bobbyo