From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 2650 invoked from network); 2 Jun 1998 15:07:48 -0000 Received: from ellpspace.math.ualberta.ca (michal@129.128.88.19) by mail2.redhat.com with SMTP; 2 Jun 1998 15:07:48 -0000 Received: (from michal@localhost) by ellpspace.math.ualberta.ca (8.8.8/8.8.8) id JAA15390 for axp-list@redhat.com; Tue, 2 Jun 1998 09:07:45 -0600 From: Michal Jaegermann Message-Id: <199806021507.JAA15390@ellpspace.math.ualberta.ca> Subject: Re: stat() broken under RH 5.0?? To: axp-list@redhat.com Date: Tue, 2 Jun 1998 09:07:45 -0600 (MDT) In-Reply-To: from "Bill Roman" at Jun 2, 98 06:20:13 am Content-Type: text Bill Roman wrote: > > Quant-X Alpha Linux Support wrote: > > > > > > #include > > #include > > #include > > #include > > > > main() > > { > > struct stat *buf; > > /* blah */ > > buf = malloc(sizeof(buf)); > > stat("teststat.c", buf); > > printf("%d\n",buf->st_mode); > > free(buf); > > /*blah*/ > > } > > > > and it should work (untested, but may work if stat isn't broken ;-}). > > Almost right! But you wanted sizeof *buf; sizeof buf is the size of a > *pointer* to struct stat, not of a struct stat. Double sigh! What about simply that: #include #include #include int main() { struct stat buf; stat("teststat.c", &buf); printf("%o\n",buf.st_mode & 0xfff); return 0; } People who compile without -Wall, especially on Alpha, get what they deserve. And yes, this does work on Alpha with Red Hat 5.0 (big surprise :-). --mj