-
Notifications
You must be signed in to change notification settings - Fork 30.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent error codes across platforms when writing to read-only (444) files #16596
Comments
In Linux and MAC where I tested, I see no issues with the error - it is just a reflection of the low level error came from the system, and it is prudent to keep them as such for clarity and ease on diagnosis.
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <stdlib.h>
int main() {
int fd = open("./00000", O_RDWR);
if(fd == -1) {
fprintf(stderr, "error: %d\n", errno);
exit(1);
}
}
And this perfectly makes sense: In windows also I see EACCES is present and better represent the error at hand, however, looks like it took a different route and ended up in EPERM. /cc @nodejs/platform-windows |
Just to clarify, I don't see any issues with the error codes currently used, the only problem I have is that they are inconsistent between Linux and Windows. |
sure, but I see an issue with
So for the current context, EACCES is the most apt one. So it is worth looking into it to see whether EPERM is coming from Win32 system itself, or from some wrappers, and in either case, the rational of doing so. |
and, that may probably also lead to an answer why this disparity |
PR to fix this: libuv/libuv#1612 |
Why was this autoclosed? |
@seishun GitHub does that when a commit with a |
@seishun - should this remain open? |
This should remain open until libuv is upgraded to 2.x. |
Given that it's not clear if and when (if ever) libuv will move to 2.x, and given that there's been zero activity on this in over 2 years, I recommend closing as there's no action we can reasonably take here. |
Linux peter-XPS-15 4.13.0-16-generic #19-Ubuntu SMP Wed Oct 11 18:35:14 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Attempting to write to a read-only file will result in:
EACCES
error on Linux systemsEPERM
error on Windows systemsIs this expected behavior? If so, it should be documented as such. The only mention of
EPERM
is with relation to hidden files.You can reproduce this by executing the following snippet on machines of the two different platforms.
https://gist.github.com/pitaj/047faae18463835a8b7697e2964a341e
The text was updated successfully, but these errors were encountered: