From owner-freebsd-hackers Sun Jan 28 15:31:41 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id PAA10304 for hackers-outgoing; Sun, 28 Jan 1996 15:31:41 -0800 (PST) Received: from irz301.inf.tu-dresden.de (irz301.inf.tu-dresden.de [141.76.1.11]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id PAA10297 for ; Sun, 28 Jan 1996 15:31:37 -0800 (PST) Received: from sax.sax.de by irz301.inf.tu-dresden.de (8.6.12/8.6.12-s1) with ESMTP id AAA26105 for ; Mon, 29 Jan 1996 00:31:30 +0100 Received: by sax.sax.de (8.6.11/8.6.12-s1) with UUCP id AAA12447 for freebsd-hackers@freebsd.org; Mon, 29 Jan 1996 00:31:30 +0100 Received: (from j@localhost) by uriah.heep.sax.de (8.7.3/8.6.9) id XAA03630 for freebsd-hackers@freebsd.org; Sun, 28 Jan 1996 23:26:38 +0100 (MET) From: J Wunsch Message-Id: <199601282226.XAA03630@uriah.heep.sax.de> Subject: Re: sysexits.h. which EX_ to use To: freebsd-hackers@freebsd.org (FreeBSD hackers) Date: Sun, 28 Jan 1996 23:26:37 +0100 (MET) Reply-To: joerg_wunsch@uriah.heep.sax.de (Joerg Wunsch) In-Reply-To: <199601281744.EAA18411@godzilla.zeta.org.au> from "Bruce Evans" at Jan 29, 96 04:44:52 am X-Phone: +49-351-2012 669 X-Mailer: ELM [version 2.4 PL23] MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-hackers@freebsd.org Precedence: bulk As Bruce Evans wrote: > > > EX_OSERR for fstat (stat'ing should always be possible if the > > file exists) > > stat() usually fails because the file doesn't exist. The file for fstat() should always exist as long fd is a valid file descriptor: j@uriah 643% cat > foo.c #include #include #include #include #include int main(void) { struct stat s; int fd; fd = open("foobar", O_CREAT, 0666); unlink("foobar"); if(fstat(fd, &s) == -1) { perror("fstat()"); return 1; } else { printf("fstat() result: mode 0%o, inode %d\n", s.st_mode, s.st_ino); } return 0; } j@uriah 644% cc foo.c j@uriah 645% ./a.out fstat() result: mode 0100644, inode 324 -- cheers, J"org joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE Never trust an operating system you don't have sources for. ;-)