Skip to content

Commit ab96e06

Browse files
authored
Merge pull request #2546 from spevans/pr_statx_enosys
2 parents e872f47 + c223d3c commit ab96e06

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Foundation/FileManager+POSIX.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -915,10 +915,14 @@ extension FileManager {
915915
let statxErrno = _stat_with_btime(fsRep, &statInfo, &btime)
916916
guard statxErrno == 0 else {
917917
switch statxErrno {
918-
case EPERM:
919-
return try _statxFallback(atPath: path, withFileSystemRepresentation: fsRep)
918+
case EPERM, ENOSYS:
919+
// statx() may be blocked by a security mechanism (eg libseccomp or Docker) even if the kernel verison is new enough. EPERM or ENONSYS may be reported.
920+
// Dont try to use it in future and fallthough to a normal lstat() call.
921+
supportsStatx = false
922+
return try _statxFallback(atPath: path, withFileSystemRepresentation: fsRep)
923+
920924
default:
921-
throw _NSErrorWithErrno(statxErrno, reading: true, path: path)
925+
throw _NSErrorWithErrno(statxErrno, reading: true, path: path)
922926
}
923927
}
924928

0 commit comments

Comments
 (0)