Date: Sun, 28 Jan 1996 23:26:37 +0100 (MET) From: J Wunsch <j@uriah.heep.sax.de> To: freebsd-hackers@freebsd.org (FreeBSD hackers) Subject: Re: sysexits.h. which EX_ to use Message-ID: <199601282226.XAA03630@uriah.heep.sax.de> In-Reply-To: <199601281744.EAA18411@godzilla.zeta.org.au> from "Bruce Evans" at Jan 29, 96 04:44:52 am
next in thread | previous in thread | raw e-mail | index | archive | help
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 <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <stdio.h> #include <fcntl.h> 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. ;-)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199601282226.XAA03630>