-
Couldn't load subscription status.
- Fork 3.4k
Fix path resolution for symlinks #23072
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
Changes from 1 commit
e9c074a
56d7c49
0002b3a
5d35316
4c0bd88
0f2713d
24a1a98
67959c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,7 +38,10 @@ var SyscallsLibrary = { | |
| } | ||
| return dir; | ||
| } | ||
| return PATH.join2(dir, path); | ||
| if (!dir.endsWith("/")) { | ||
| dir += "/" | ||
| } | ||
| return dir + path; | ||
|
||
| }, | ||
|
|
||
| doStat(func, path, buf) { | ||
|
|
@@ -826,7 +829,6 @@ var SyscallsLibrary = { | |
| path = SYSCALLS.calculateAt(dirfd, path); | ||
| // remove a trailing slash, if one - /a/b/ has basename of '', but | ||
| // we want to create b in the context of this function | ||
| path = PATH.normalize(path); | ||
| if (path[path.length-1] === '/') path = path.substr(0, path.length-1); | ||
hoodmane marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| FS.mkdir(path, mode, 0); | ||
| return 0; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| #include <unistd.h> | ||
| #include <fcntl.h> | ||
| #include <fcntl.h> | ||
| #include <unistd.h> | ||
| #include <sys/stat.h> | ||
| #include <assert.h> | ||
| #include <stdio.h> | ||
| #include <string.h> | ||
| #if defined(__EMSCRIPTEN__) | ||
| #include "emscripten.h" | ||
| #endif | ||
|
|
||
| void makedir(const char *dir) { | ||
| int rtn = mkdir(dir, 0777); | ||
| assert(rtn == 0); | ||
| } | ||
|
|
||
| void changedir(const char *dir) { | ||
| int rtn = chdir(dir); | ||
| assert(rtn == 0); | ||
| } | ||
|
|
||
| static void create_file(const char *path) { | ||
| printf("creating: %s\n", path); | ||
| int fd = open(path, O_WRONLY | O_CREAT | O_EXCL, 0777); | ||
| assert(fd >= 0); | ||
|
|
||
| close(fd); | ||
| } | ||
|
|
||
| void setup() { | ||
| #if defined(__EMSCRIPTEN__) && defined(NODEFS) | ||
| makedir("working"); | ||
| EM_ASM(FS.mount(NODEFS, { root: '.' }, 'working')); | ||
| changedir("working"); | ||
| #endif | ||
| makedir("a"); | ||
| makedir("b"); | ||
| makedir("b/c"); | ||
| symlink("../b/c", "a/link"); | ||
| } | ||
|
|
||
|
|
||
| int main() { | ||
| setup(); | ||
| create_file("a/link/../x.txt"); | ||
| struct stat statBuf; | ||
| assert(stat("a/link/../x.txt", &statBuf) == 0); | ||
| assert(stat("b/x.txt", &statBuf) == 0); | ||
| makedir("a/link/../d"); | ||
| assert(stat("a/link/../d", &statBuf) == 0); | ||
| assert(stat("b/d", &statBuf) == 0); | ||
|
|
||
| assert(truncate("a/link/../x.txt", 0) == 0); | ||
| assert(chmod("a/link/../x.txt", 0777) == 0); | ||
| printf("success\n"); | ||
hoodmane marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.