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: https://github.com/nodejs/node/issues/25433
Fixes: https://github.com/libuv/libuv/issues/2147
PR-URL: https://github.com/libuv/libuv/pull/2148
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
6140507ba7
commit
91ca6788bb
@ -317,6 +317,18 @@ done:
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user