Repository navigation
fs: report EROFS from recursive mkdir() - #67500
Open
yohannesjoya wants to merge 1 commit into
Open
yohannesjoya wants to merge 1 commit into
yohannesjoya wants to merge 1 commit into
Conversation
A recursive mkdir() that hits a read-only file system treated EROFS like any unknown error: it stat()ed the missing path and reported the ENOENT from that instead. Return EROFS straight away, as mkdir() already does for EACCES, ENOSPC, ENOTDIR and EPERM. The test uses a read-only file system that is already mounted (listed in /proc/self/mounts on Linux, the system volume on macOS) and skips when there is none, since mounting one needs root. Fixes: nodejs#47098 Refs: nodejs#48105 Refs: nodejs#62725 Co-authored-by: Alberto Moretti <moretti919@gmail.com> Signed-off-by: Yohannes Desta <yohannesdestagebru10@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #67500 +/- ##
==========================================
- Coverage 92.99% 90.67% -2.32%
==========================================
Files 428 799 +371
Lines 195633 280243 +84610
Branches 30281 54119 +23838
==========================================
+ Hits 181937 254123 +72186
- Misses 13369 16241 +2872
- Partials 327 9879 +9552
🚀 New features to boost your workflow:
|
jasnell
approved these changes
Nov 16, 2026
Collaborator
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.
fs.mkdir()withrecursive: trueon a read-only file system reportsENOENT.EROFSisn't in the list of errorsMKDirpSync/MKDirpAsyncreturn directly, so it falls into the default branch, which stats the missing path and reports thatENOENTinstead. Reproduced on main withfs.mkdirSync('/snap/core/current/x/y', { recursive: true })on Ubuntu (EROFSwithoutrecursive,ENOENTwith it).This adds
EROFSnext toEACCES,ENOSPC,ENOTDIRandEPERMin both switches. The change is the one @hiimjako proposed in #48105 (carried withCo-authored-by); that PR and @kennyhyun's #62725 stalled because their tests neededsudo mount. The test here uses a read-only file system that is already mounted — on Linux anyroentry in/proc/self/mounts(e.g./sysin a container), on macOS the system volume — verified with a plainmkdirthat must fail withEROFS, and skips if none is available. It fails on main withENOENTand passes with the fix.Fixes: #47098
Refs: #48105
Refs: #62725
AI disclosure: I used a coding agent to help search the issue history and draft the test. I reproduced the bug on main, reviewed the change line by line, and ran the fs tests locally.