From: Michal Jaegermann <michal@ellpspace.math.ualberta.ca>
To: axp-list@redhat.com
Subject: Re: stat() broken under RH 5.0??
Date: Tue, 2 Jun 1998 09:07:45 -0600 (MDT) [thread overview]
Message-ID: <199806021507.JAA15390@ellpspace.math.ualberta.ca> (raw)
In-Reply-To: <m0ygqz8-0000aLC@songdog> from "Bill Roman" at Jun 2, 98 06:20:13 am
Bill Roman wrote:
>
> Quant-X Alpha Linux Support wrote:
> >
> >
> > #include <stdlib.h>
> > #include <sys/stat.h>
> > #include <dirent.h>
> > #include <unistd.h>
> >
> > 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 <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
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
next prev parent reply other threads:[~1998-06-02 15:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-06-01 15:52 stat() broken under RH 5.0?? Mike
1998-06-01 21:45 ` Quant-X Alpha Linux Support
1998-06-02 13:20 ` Bill Roman
1998-06-02 15:07 ` Michal Jaegermann [this message]
[not found] <Pine.SOL.3.96.980601182010.13382A-100000@tarkovsky.npac.syr.edu>
1998-06-02 0:37 ` Quant-X Alpha Linux Support
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox