fs: fix mkdirp return UV_EROFS on read-only fs#48105
fs: fix mkdirp return UV_EROFS on read-only fs#48105hiimjako wants to merge 4 commits intonodejs:mainfrom
Conversation
3d14ad9 to
b4a60a3
Compare
|
Hey @hiimjako, thank you for considering to contribute. Your commit (b4a60a3) is pointing at an invalid user, make sure you've configured Git to point to you so that you would be shown as a contributor after your changes are accepted and merged. A commit pointing to an invalid user can generally be caused by it being committed by the incorrect email address, make sure the $ git config --global user.email "<primary email>"(Replace You can check the Git getting started guide for more information. After all that, force-push the commit to make it point to you. |
b4a60a3 to
237b429
Compare
|
Hi @VoltrexKeyva, Thanks for the suggestion, I was using another email for other things and I forgot to change it :) Now it should be right |
|
Can we simulate a readonly environment and add a test for this? I don't feel comfortable merging this without any tests, unless someone more knowledgable on this matter reviews and approves this PR. |
RafaelGSS
left a comment
There was a problem hiding this comment.
Thanks for the PR. Please include a test
test: add test for mkdir running in read-only filesystem
|
Hi @RafaelGSS, |
|
Hey @RafaelGSS, any chance you'll be able to take a look at this PR soon? 🤞 |
| } | ||
|
|
||
| // mkdirpSync when interacting with read-only filesystem. | ||
| if (common.isLinux && process.getuid() === 0) // Mounting filesystem requires root privilege. |
There was a problem hiding this comment.
Do we have a test environment that would enter into this clause? @nodejs/build
mkdirSync with { recursive: true } on a read-only filesystem throws
ENOENT instead of the expected EROFS. This test demonstrates the bug
by mounting a read-only tmpfs via sudo and verifying the error code.
Refs: nodejs#47098
Refs: nodejs#48105
Signed-off-by: Kenny Yeo <kenny@yeoyou.net>
mkdirSync with { recursive: true } on a read-only filesystem
incorrectly throws ENOENT instead of the expected EROFS error.
This test demonstrates the bug by mounting a read-only tmpfs
via sudo and verifying the error code.
The test requires passwordless sudo to mount a read-only tmpfs.
In environments without this capability (such as ci.nodejs.org),
the test is skipped with a warning message explaining why.
Refs: nodejs#47098
Refs: nodejs#48105
Signed-off-by: Kenny Yeo <kenny@yeoyou.net>
Add UV_EROFS to the list of errors that should be returned immediately in MKDirpSync and MKDirpAsync, preventing it from being incorrectly converted to ENOENT when mkdir is called with the recursive option on a read-only filesystem. Based on the original fix by Alberto Moretti (@hiimjako) in nodejs#48105. Refs: nodejs#47098 Refs: nodejs#48105 Co-authored-by: Alberto Moretti <moretti919@gmail.com> Signed-off-by: Kenny Yeo <kenny@yeoyou.net>
Add UV_EROFS to the list of errors that should be returned immediately in MKDirpSync and MKDirpAsync, preventing it from being incorrectly converted to ENOENT when mkdir is called with the recursive option on a read-only filesystem. Based on the original fix by Alberto Moretti (@hiimjako) in nodejs#48105. Refs: nodejs#47098 Refs: nodejs#48105 Co-authored-by: Alberto Moretti <moretti919@gmail.com> Signed-off-by: Kenny Yeo <kenny@yeoyou.net>
Add UV_EROFS to the list of errors that should be returned immediately in MKDirpSync and MKDirpAsync, preventing it from being incorrectly converted to ENOENT when mkdir is called with the recursive option on a read-only filesystem. Based on the original fix by Alberto Moretti (@hiimjako) in nodejs#48105. Refs: nodejs#47098 Refs: nodejs#48105 Co-authored-by: Alberto Moretti <moretti919@gmail.com> Signed-off-by: Kenny Yeo <kenny@yeoyou.net>
mkdirSync with { recursive: true } on a read-only filesystem
incorrectly throws ENOENT instead of the expected EROFS error.
This test demonstrates the bug by mounting a read-only tmpfs
via sudo and verifying the error code.
The test requires passwordless sudo to mount a read-only tmpfs.
In environments without this capability (such as ci.nodejs.org),
the test is skipped with a warning message explaining why.
Refs: nodejs#47098
Refs: nodejs#48105
Signed-off-by: Kenny Yeo <kenny@yeoyou.net>
Add UV_EROFS to the list of errors that should be returned immediately in MKDirpSync and MKDirpAsync, preventing it from being incorrectly converted to ENOENT when mkdir is called with the recursive option on a read-only filesystem. Based on the original fix by Alberto Moretti (@hiimjako) in nodejs#48105. Refs: nodejs#47098 Refs: nodejs#48105 Co-authored-by: Alberto Moretti <moretti919@gmail.com> Signed-off-by: Kenny Yeo <kenny@yeoyou.net>
|
Hi, I have tried the same fix with a test validated on Github Actions. one commit for failure and the other is fix (from @hiimjako). My approach for testing is to just skip testing when sudo access failed. (maybe same approach with @kwaszczuk) @RafaelGSS @hiimjako Can I open a new PR? at least there is no conflict. |
|
Hi @kennyhyun! |
mkdirSync with { recursive: true } on a read-only filesystem
incorrectly throws ENOENT instead of the expected EROFS error.
Two test cases are included:
- On Linux with passwordless sudo, mounts a real read-only tmpfs to
verify the error code against the actual kernel behavior.
- Uses internalBinding to mock binding.mkdir and simulate EROFS,
ensuring the error propagates correctly without requiring root.
Refs: nodejs#47098
Refs: nodejs#48105
Signed-off-by: Kenny Yeo <kenny@yeoyou.net>
Add UV_EROFS to the list of errors that should be returned immediately in MKDirpSync and MKDirpAsync, preventing it from being incorrectly converted to ENOENT when mkdir is called with the recursive option on a read-only filesystem. Based on the original fix by Alberto Moretti (@hiimjako) in nodejs#48105. Refs: nodejs#47098 Refs: nodejs#48105 Co-authored-by: Alberto Moretti <moretti919@gmail.com> Signed-off-by: Kenny Yeo <kenny@yeoyou.net>
mkdirSync with { recursive: true } on a read-only filesystem
incorrectly throws ENOENT instead of the expected EROFS error.
Two test cases are included:
- On Linux with passwordless sudo, mounts a real read-only tmpfs to
verify the error code against the actual kernel behavior.
- Uses internalBinding to mock binding.mkdir and simulate EROFS,
ensuring the error propagates correctly without requiring root.
Refs: nodejs#47098
Refs: nodejs#48105
Signed-off-by: Kenny Yeo <kenny@yeoyou.net>
Add UV_EROFS to the list of errors that should be returned immediately in MKDirpSync and MKDirpAsync, preventing it from being incorrectly converted to ENOENT when mkdir is called with the recursive option on a read-only filesystem. Based on the original fix by Alberto Moretti (@hiimjako) in nodejs#48105. Refs: nodejs#47098 Refs: nodejs#48105 Co-authored-by: Alberto Moretti <moretti919@gmail.com> Signed-off-by: Kenny Yeo <kenny@yeoyou.net>
|
Thanks @hiimjako, I ended up with adding a mock test case as well. Let me create a new PR. Thanks! |
Fixes: #47098
I tested the changes manually by mounting a read-only fs and trying to create a new folder inside it.
I honestly wouldn't know how to write tests on these changes without mounting a RO file systems during test sets, and I don't know if this is the best solution. If anyone has advice on how to do this, it is welcome