-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Fix std::remove on folders #4440
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
Conversation
|
Original change has been done according to: http://man7.org/linux/man-pages/man2/unlink.2.html like @inolen wrote. From the other side we use musl for standard lib implementation what explicitly says: "musl - an implementation of the standard library for Linux-based systems" Going back in history I found a place where this line was added: a9fb60e This is how I tested it:
I had to remove test_scons due error:
It failed on the new test, what was expected.
It found 1 error:
https://github.com/kripken/emscripten/blob/master/tests/unistd/unlink.c#L82-L86 It's a little bit complicated test flow, but I wasn't able to hook my fork to SDK in order to use it. Possible ways to solve it:
diff --git a/tests/unistd/unlink.c b/tests/unistd/unlink.c
index 2e51214..ca81828 100644
--- a/tests/unistd/unlink.c
+++ b/tests/unistd/unlink.c
@@ -79,7 +79,7 @@ void test() {
err = unlink("dir-readonly");
assert(err == -1);
-#ifdef __linux__
+#if defined(__linux__) || defined(__EMSCRIPTEN__)
assert(errno == EISDIR);
#else
assert(errno == EPERM);
Do you you have any ideas or recommendations? |
|
Thank you for the detailed investigation! Ok, if I understand correctly, this does in fact look like a linux/posix difference. And therefore musl does what it does (as a linux libc), and also therefore if we change that unistd test to make it handle emscripten like linux, then it would work. That sounds good to me. In general when in doubt, we've done what linux does. |
| var node = FS.lookupNode(parent, name); | ||
| var err = FS.mayDelete(parent, name, false); | ||
| if (err) { | ||
| // POSIX says unlink should set EPERM, not EISDIR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please leave a comment here, that if we were POSIX compliant we would do [..], but we instead do the same thing that linux does.
|
Done, I added a proper comment to |
|
Great, thanks! Squashed and merged to incoming. |
std::removeexpectsEISDIRif it has been called on a directory: https://github.com/kripken/emscripten/blob/master/system/lib/libc/musl/src/stdio/remove.cThis fix removes mapping from
EISDIRtoEPERMonunlink, it has been added long time ago: #1388CC:
@inolen
@kripken
I wasn't able about C++ test, I did my best.