Handle EPERM as permissionDenied in open syscall error mapping#3560
Merged
glbrntt merged 1 commit intoapple:mainfrom Mar 25, 2026
Merged
Handle EPERM as permissionDenied in open syscall error mapping#3560glbrntt merged 1 commit intoapple:mainfrom
glbrntt merged 1 commit intoapple:mainfrom
Conversation
… mapping Motivation: NIOFileSystem only handled EACCES (.permissionDenied) for permission errors in the open syscall error mapping, but not EPERM (.notPermitted). On network volumes and certain filesystem configurations, the kernel returns EPERM instead of EACCES, causing NIOFileSystem to classify the error as "unknown" rather than "permissionDenied." Modifications: Added .notPermitted alongside .permissionDenied in the open() error mapping in FileSystemError+Syscall.swift (both NIOFS and _NIOFileSystem modules). Added corresponding test expectation for .notPermitted -> .permissionDenied in the open errno mapping test. Result: EPERM errors from open syscalls are now correctly classified as permissionDenied instead of unknown, consistent with how other syscall handlers (remove, symlink, unlink, futimens) already handle EPERM. Fixes apple#3559 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes syscall errno mapping for open so that EPERM (Errno.notPermitted) is classified as .permissionDenied rather than falling back to .unknown, aligning open with other syscall mappings in the same file.
Changes:
- Map
Errno.notPermittedalongsideErrno.permissionDeniedtoFileSystemError.Code.permissionDeniedforopen. - Apply the mapping change in both
NIOFSand_NIOFileSystemvariants ofFileSystemError+Syscall.swift. - Extend
testErrnoMapping_opento assert the new mapping behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Tests/NIOFSTests/FileSystemErrorTests.swift | Adds test coverage to ensure .notPermitted maps to .permissionDenied for open. |
| Sources/_NIOFileSystem/FileSystemError+Syscall.swift | Updates open errno switch to treat .notPermitted as .permissionDenied. |
| Sources/NIOFS/FileSystemError+Syscall.swift | Updates open errno switch to treat .notPermitted as .permissionDenied. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
opensyscall error mapping only handledEACCES(.permissionDenied) but notEPERM(.notPermitted), causing EPERM errors (e.g., on network volumes) to be classified as "unknown" instead ofpermissionDenied.notPermittedalongside.permissionDeniedin theopen()switch case inFileSystemError+Syscall.swift(bothNIOFSand_NIOFileSystemmodules)Motivation
Other syscall handlers in the same file (
remove,symlink,unlink,futimens) already correctly handle both.permissionDeniedand.notPermittedaspermissionDenied. Theopenhandler was missing this treatment.Fixes #3559
Test plan
testErrnoMapping_opento verify.notPermittedmaps to.permissionDenied🤖 Generated with Claude Code