Skip to content

Commit

Permalink
Fix broken readdir_r() and readdir_r64() functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
abh3 authored and ljanyst committed Oct 21, 2014
1 parent 30a5bff commit 3e1486a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/XrdPosix/XrdPosixXrootd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -689,10 +689,11 @@ struct dirent64* XrdPosixXrootd::Readdir64(DIR *dirp)
int XrdPosixXrootd::Readdir_r(DIR *dirp, struct dirent *entry,
struct dirent **result)
{
dirent64 *dp64;
dirent64 *dp64 = 0, d64ent;
int rc;

if ((rc = Readdir64_r(dirp, 0, &dp64)) <= 0) {*result = 0; return rc;}
if ((rc = Readdir64_r(dirp, &d64ent, &dp64)) || !dp64)
{*result = 0; return rc;}

entry->d_ino = dp64->d_ino;
#if !defined(__APPLE__) && !defined(__FreeBSD__)
Expand All @@ -715,13 +716,12 @@ int XrdPosixXrootd::Readdir64_r(DIR *dirp, struct dirent64 *entry,

// Find the object
//
if (!(dP = XrdPosixObject::Dir(fildes)))
{errno = EBADF; return 0;}
if (!(dP = XrdPosixObject::Dir(fildes))) return EBADF;

// Get the next entry
//
if (!(*result = dP->nextEntry(entry))) rc = dP->Status();
else rc = 0;
if (!(*result = dP->nextEntry(entry))) {rc = dP->Status(); *result = 0;}
else {rc = 0; *result = entry;}

// Return the appropriate result
//
Expand Down

0 comments on commit 3e1486a

Please sign in to comment.