Skip to content

Commit 91ca678

Browse files
kadlercjihrig
authored andcommitted
ibmi: return EISDIR on read from directory fd
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 <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 6140507 commit 91ca678

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/unix/fs.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,18 @@ static ssize_t uv__fs_read(uv_fs_t* req) {
317317
req->bufs = NULL;
318318
req->nbufs = 0;
319319

320+
#ifdef __PASE__
321+
/* PASE returns EOPNOTSUPP when reading a directory, convert to EISDIR */
322+
if (result == -1 && errno == EOPNOTSUPP) {
323+
struct stat buf;
324+
ssize_t rc;
325+
rc = fstat(req->file, &buf);
326+
if (rc == 0 && S_ISDIR(buf.st_mode)) {
327+
errno = EISDIR;
328+
}
329+
}
330+
#endif
331+
320332
return result;
321333
}
322334

0 commit comments

Comments
 (0)