Skip to content

Commit 76670d2

Browse files
committed
Add ifdef for AIX/MVS
1 parent 267039f commit 76670d2

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

llvm/lib/Support/Unix/Path.inc

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,13 +1024,17 @@ std::error_code openFile(const Twine &Name, int &ResultFD,
10241024
auto Open = [&]() { return ::open(P.begin(), OpenFlags, Mode); };
10251025
if ((ResultFD = sys::RetryAfterSignal(-1, Open)) < 0)
10261026
return errnoAsErrorCode();
1027-
if (Access == FA_Read) {
1028-
struct stat Status;
1029-
if (fstat(ResultFD, &Status) == -1)
1030-
return errnoAsErrorCode();
1031-
if (S_ISDIR(Status.st_mode))
1032-
return make_error_code(errc::is_a_directory);
1033-
}
1027+
// The underlying operation on these platforms allow opening directories
1028+
// for reading in more cases than other platforms.
1029+
#if defined(__MVS__) || defined(_AIX)
1030+
if (Access == FA_Read) {
1031+
struct stat Status;
1032+
if (fstat(ResultFD, &Status) == -1)
1033+
return errnoAsErrorCode();
1034+
if (S_ISDIR(Status.st_mode))
1035+
return make_error_code(errc::is_a_directory);
1036+
}
1037+
#endif
10341038
#ifndef O_CLOEXEC
10351039
if (!(Flags & OF_ChildInherit)) {
10361040
int r = fcntl(ResultFD, F_SETFD, FD_CLOEXEC);

0 commit comments

Comments
 (0)