Skip to content

Handle EPERM as permissionDenied in open syscall error mapping#3560

Merged
glbrntt merged 1 commit intoapple:mainfrom
queelius:fix/3559-eperm-handling
Mar 25, 2026
Merged

Handle EPERM as permissionDenied in open syscall error mapping#3560
glbrntt merged 1 commit intoapple:mainfrom
queelius:fix/3559-eperm-handling

Conversation

@queelius
Copy link
Copy Markdown
Contributor

Summary

  • NIOFileSystem's open syscall error mapping only handled EACCES (.permissionDenied) but not EPERM (.notPermitted), causing EPERM errors (e.g., on network volumes) to be classified as "unknown" instead of permissionDenied
  • Added .notPermitted alongside .permissionDenied in the open() switch case in FileSystemError+Syscall.swift (both NIOFS and _NIOFileSystem modules)
  • Added corresponding test expectation for the new errno mapping

Motivation

Other syscall handlers in the same file (remove, symlink, unlink, futimens) already correctly handle both .permissionDenied and .notPermitted as permissionDenied. The open handler was missing this treatment.

Fixes #3559

Test plan

  • Updated testErrnoMapping_open to verify .notPermitted maps to .permissionDenied
  • CI will validate on all supported Swift versions

🤖 Generated with Claude Code

… 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>
Copilot AI review requested due to automatic review settings March 25, 2026 09:47
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.notPermitted alongside Errno.permissionDenied to FileSystemError.Code.permissionDenied for open.
  • Apply the mapping change in both NIOFS and _NIOFileSystem variants of FileSystemError+Syscall.swift.
  • Extend testErrnoMapping_open to 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.

@glbrntt glbrntt added the 🔨 semver/patch No public API change. label Mar 25, 2026
Copy link
Copy Markdown
Contributor

@glbrntt glbrntt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@glbrntt glbrntt merged commit 98f8824 into apple:main Mar 25, 2026
57 of 58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NIOFileSystem classifies EPERM (errno 1) as "unknown"

3 participants