From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 2014 invoked from network); 2 Jun 1998 13:30:24 -0000 Received: from eskinews.eskimo.com (root@204.122.16.44) by mail2.redhat.com with SMTP; 2 Jun 1998 13:30:24 -0000 Received: from songdog.UUCP (uucp@localhost) by eskinews.eskimo.com (8.8.8/8.8.8) with UUCP id GAA02521 for redhat.com!axp-list; Tue, 2 Jun 1998 06:25:30 -0700 Received: by songdog id m0ygqz8-0000aLC (Debian /\oo/\ Smail3.1.29.1 #29.37); Tue, 2 Jun 98 06:20 PDT Message-Id: From: roman@songdog.eskimo.com (Bill Roman) Subject: Re: stat() broken under RH 5.0?? To: axp-list@redhat.com Date: Tue, 2 Jun 1998 06:20:13 -0700 (PDT) In-Reply-To: <199806012145.XAA01256@stefan.sime.com> from "Quant-X Alpha Linux Support" at Jun 1, 98 11:45:43 pm X-Mailer: ELM [version 2.4 PL25 PGP2] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Quant-X Alpha Linux Support wrote: > > Hi ! > > > We cannot get stat (in a C program, not the shell command) to work > > correctly under RedHat 5.0 running on an alpha (kernel 2.0.30). Any help > > Ouups, your example is simply broken; it can't work. >> [original code deleted] > This cannot work, because you must allocate buf ! > try something like: > > [working example deleted] > > or > > #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. -- Bill Roman (roman@songdog.eskimo.com / roman@songdog.uucp) running linux