From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 17492 invoked from network); 1 Jun 1998 21:47:11 -0000 Received: from stefan.sime.com (193.228.80.247) by mail2.redhat.com with SMTP; 1 Jun 1998 21:47:11 -0000 Received: (from stefan@localhost) by stefan.sime.com (8.8.7/8.8.7) id XAA01256; Mon, 1 Jun 1998 23:45:43 +0200 Date: Mon, 1 Jun 1998 23:45:43 +0200 Message-Id: <199806012145.XAA01256@stefan.sime.com> From: Quant-X Alpha Linux Support To: axp-list@redhat.com CC: joeyen@alpha.nmrlab.hscsyr.edu In-reply-to: <199806011552.LAA07657@alpha.nmrlab.hscsyr.edu> (message from Mike on Mon, 1 Jun 1998 11:52:37 -0400) Subject: Re: stat() broken under RH 5.0?? MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: Quant-X Alpha Linux Support Reply-To: Quant-X Alpha Linux Support Organization: Quant-X Service & Consulting Ges.m.b.H. X-Mailer: GNU Emacs 20.2.1 C-x m (X11 ; I; Linux 2.0.32 i586) References: <199806011552.LAA07657@alpha.nmrlab.hscsyr.edu> 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. > #include > #include > #include > > main() > { > struct stat *buf; > stat("teststat.c",buf); > printf("%d\n",buf->st_mode); > } This cannot work, because you must allocate buf ! try something like: #include #include #include main() { struct stat buf; stat("teststat.c", &buf); printf("%d\n",buf.st_mode); } 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 ;-}). BTW, what you really want is maybe: printf("%o\n",buf->st_mode & ~S_IFMT); -- Quant-X Service & Ph: (+43) 4212 6004-0 Consulting Ges.m.b.H. Fax: (+43) 4212 600420 http://www.quant-x.com Email: support@quant-x.com