Skip to content
Snippets Groups Projects
Commit 7962cb62 authored by Henrik (Grubba) Grubbström's avatar Henrik (Grubba) Grubbström
Browse files

Fixed a few bugs in the POSIX readdir_r() handling.

Rev: src/modules/files/efuns.c:1.55
parent 01aaaff7
No related branches found
No related tags found
No related merge requests found
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include "file_machine.h" #include "file_machine.h"
#include "file.h" #include "file.h"
RCSID("$Id: efuns.c,v 1.54 1998/07/02 18:59:29 grubba Exp $"); RCSID("$Id: efuns.c,v 1.55 1998/07/02 19:49:59 grubba Exp $");
#ifdef HAVE_SYS_TYPES_H #ifdef HAVE_SYS_TYPES_H
#include <sys/types.h> #include <sys/types.h>
...@@ -456,7 +456,11 @@ void f_get_dir(INT32 args) ...@@ -456,7 +456,11 @@ void f_get_dir(INT32 args)
if (!d) { if (!d) {
/* Solaris readdir_r seems to set errno to ENOENT sometimes. /* Solaris readdir_r seems to set errno to ENOENT sometimes.
*/ */
err = (errno == ENOENT)?0:errno; if (errno == ENOENT) {
err = 0;
} else {
err = errno;
}
break; break;
} }
#elif defined(HAVE_HPUX_READDIR_R) #elif defined(HAVE_HPUX_READDIR_R)
...@@ -477,7 +481,16 @@ void f_get_dir(INT32 args) ...@@ -477,7 +481,16 @@ void f_get_dir(INT32 args)
/* POSIX readdir_r returns 0 on success, and ERRNO on failure. /* POSIX readdir_r returns 0 on success, and ERRNO on failure.
* at end of dir it sets the third arg to NULL. * at end of dir it sets the third arg to NULL.
*/ */
d = NULL;
if ((err = readdir_r(dir, tmp, &d)) || !d) { if ((err = readdir_r(dir, tmp, &d)) || !d) {
if (err == -1) {
err = errno;
}
/* Solaris readdir_r seems to set errno to ENOENT sometimes.
*/
if (err == ENOENT) {
err = 0;
}
break; break;
} }
#else #else
...@@ -498,7 +511,7 @@ void f_get_dir(INT32 args) ...@@ -498,7 +511,7 @@ void f_get_dir(INT32 args)
} }
THREADS_DISALLOW(); THREADS_DISALLOW();
if ((!d) && err) { if ((!d) && err) {
error("get_dir(): readdir_r() failed: %d\n", err); error("get_dir(): readdir_r(\"%s\") failed: %d\n", path, err);
} }
for(e=0;e<num_files;e++) for(e=0;e<num_files;e++)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment