Skip to content

Commit

Permalink
ibmi: return EISDIR on read from directory fd
Browse files Browse the repository at this point in the history
On IBM i PASE, EOPNOTSUPP is returned when reading a directory instead
of EISDIR, like (seemingly) every other platform which doesn't support
reading directories. To ensure compatibility with software expecting
EISDIR, we map the EOPNOTSUPP to EISDIR when the fd passed in was a
directory.

This is a partial revert of 25a3894, but scoped to PASE and the fstat
call is moved to the end so it's out of the fast path.

Refs: nodejs/node#25433
Fixes: #2147
PR-URL: #2148
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
kadler authored and cjihrig committed Jan 17, 2019
1 parent 6140507 commit 91ca678
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/unix/fs.c
Expand Up @@ -317,6 +317,18 @@ static ssize_t uv__fs_read(uv_fs_t* req) {
req->bufs = NULL;
req->nbufs = 0;

#ifdef __PASE__
/* PASE returns EOPNOTSUPP when reading a directory, convert to EISDIR */
if (result == -1 && errno == EOPNOTSUPP) {
struct stat buf;
ssize_t rc;
rc = fstat(req->file, &buf);
if (rc == 0 && S_ISDIR(buf.st_mode)) {
errno = EISDIR;
}
}
#endif

return result;
}

Expand Down

0 comments on commit 91ca678

Please sign in to comment.