Skip to content
Snippets Groups Projects
Commit f131a71f authored by Fredrik Hübinette (Hubbe)'s avatar Fredrik Hübinette (Hubbe)
Browse files

readdir_r fixed?

Rev: src/modules/files/efuns.c:1.14
parent 93673591
No related branches found
No related tags found
No related merge requests found
...@@ -162,6 +162,12 @@ void f_mkdir(INT32 args) ...@@ -162,6 +162,12 @@ void f_mkdir(INT32 args)
push_int(i); push_int(i);
} }
#undef HAVE_REDDIR_R
#if defined(HAVE_SOLARIS_READDIR_R) || defined(HAVE_SOLARIS_HPUX_R) || \
defined(HAVE_POSIX_R)
#define HAVE_READDIR_R
#endif
void f_get_dir(INT32 args) void f_get_dir(INT32 args)
{ {
struct svalue *save_sp=sp; struct svalue *save_sp=sp;
...@@ -172,7 +178,7 @@ void f_get_dir(INT32 args) ...@@ -172,7 +178,7 @@ void f_get_dir(INT32 args)
get_all_args("get_dir",args,"%s",&path); get_all_args("get_dir",args,"%s",&path);
#if defined(_REENTRANT) && ( defined(HAVE_SOLARIS_READDIR_R) || defined(HAVE_HPUX_READDIR_R) || defined(HAVE_POSIX_READDIR_R)) #if defined(_REENTRANT) && defined(HAVE_READDIR_R)
THREADS_ALLOW(); THREADS_ALLOW();
dir=opendir(path); dir=opendir(path);
THREADS_DISALLOW(); THREADS_DISALLOW();
...@@ -205,6 +211,7 @@ void f_get_dir(INT32 args) ...@@ -205,6 +211,7 @@ void f_get_dir(INT32 args)
/* Solaris readdir_r returns the second arg on success, /* Solaris readdir_r returns the second arg on success,
* and returns NULL on error or at end of dir. * and returns NULL on error or at end of dir.
*/ */
errno=0;
do { do {
d=readdir_r(dir, tmp); d=readdir_r(dir, tmp);
} while ((!d) && ((errno == EAGAIN)||(errno == EINTR))); } while ((!d) && ((errno == EAGAIN)||(errno == EINTR)));
...@@ -220,6 +227,7 @@ void f_get_dir(INT32 args) ...@@ -220,6 +227,7 @@ void f_get_dir(INT32 args)
* 0 - Successfull operation. * 0 - Successfull operation.
* -1 - End of directory or encountered an error (sets errno). * -1 - End of directory or encountered an error (sets errno).
*/ */
errno=0;
if (readdir_r(dir, tmp)) { if (readdir_r(dir, tmp)) {
d = NULL; d = NULL;
err = errno; err = errno;
......
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