From: kunst AT prl DOT philips DOT nl Subject: stat() is broken! (dj112m1) To: stevew AT landau DOT conductus DOT com (Stephen R. Whiteley) Date: Thu, 1 Sep 1994 13:31:55 +0100 (METDST) Cc: djgpp AT sun DOT soe DOT clarkson DOT edu (DJGPP users list) Stephen R. Whiteley writes: > Tried the new libc.a in dj112m1.zip, however found that the tempnam() > function returns NULL (noticed this in make-3.71/job.c). Put back > the 111m5 libc.a and everything was cool. I had the same problem (with tmpnam()), and I'm busy tracking the error. I think the problem is located in stat(). stat() doesn't return ENOENT when called with a non-existent path. I've included a small test program below. Regards, Pieter Kunst (kunst AT prl DOT philips DOT nl) ============================================================================== #define _INCLUDE_POSIX_SOURCE #include #include #include #include int main() { struct stat sbuf; char path[100]; int rv; extern int errno; strcpy (path, "/nonexist"); /* non-existing filename */ rv = stat(path, &sbuf); printf ("path = %s, rv = %d\n", path, rv); printf ("errno = %d\n", errno); switch (errno) { case ENOENT: /* 2 */ printf ("%d = No such file or directory\n", errno); break; #ifdef ENMFILE case ENMFILE: printf ("%d = No more files\n", errno); break; #endif } return 0; } ============================================================================== Output of the program above on HP-UX system: ============================================================================== path = /nonexist, rv = -1 errno = 2 2 = No such file or directory ============================================================================== Output of the program above with DJ112M1: ============================================================================== path = /nonexist, rv = -1 errno = 18 18 = No more files ==============================================================================