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: libuv#2147
PR-URL: libuv#2148
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
  • Loading branch information
kadler authored and njlr committed Apr 5, 2019
1 parent d04aef9 commit d2b4400
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/unix/fs.c
Original file line number Diff line number Diff line change
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 d2b4400

Please sign in to comment.