Skip to content

Make readlink system call not resolve the link #23000

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

Merged
merged 3 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/library_fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ FS.staticInit();
if (!link.node_ops.readlink) {
throw new FS.ErrnoError({{{ cDefs.EINVAL }}});
}
return PATH_FS.resolve(FS.getPath(link.parent), link.node_ops.readlink(link));
return link.node_ops.readlink(link);
},
stat(path, dontFollow) {
var lookup = FS.lookupPath(path, { follow: !dontFollow });
Expand Down
16 changes: 0 additions & 16 deletions test/unistd/links.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,7 @@ void test_reading_existing_symlinks() {
continue;
}

// WASMFS behaves the same as Linux (and as best as I can tell, the spec),
// seeing the symlink as a string. The old JS FS instead normalizes it and
// returns something modified.
// The same happens in the assertions below.
#if !defined(__EMSCRIPTEN__) || defined(WASMFS)
assert(strcmp(buffer, "../test/../there!") == 0);
#else
assert(strcmp(buffer, "/there!") == 0);
#endif
assert(strlen(buffer) == rtn);
errno = 0;
}
Expand All @@ -111,11 +103,7 @@ void test_creating_symlink() {
char buffer[256] = {0};
rtn = readlink("directory/link", buffer, 256);
assert(errno == 0);
#if !defined(__EMSCRIPTEN__) || defined(WASMFS)
assert(strcmp(buffer, "new-nonexistent-path") == 0);
#else
assert(strcmp(buffer, "/working/directory/new-nonexistent-path") == 0);
#endif
assert(strlen(buffer) == rtn);
errno = 0;
}
Expand All @@ -127,11 +115,7 @@ void test_reading_shortened_symlink() {
int rtn = readlink("link", buffer, 4);
assert(errno == 0);
assert(rtn == 4);
#if !defined(__EMSCRIPTEN__) || defined(WASMFS)
assert(strcmp(buffer, "../t**nexistent-path") == 0);
#else
assert(strcmp(buffer, "/the**ng/directory/new-nonexistent-path") == 0);
#endif
errno = 0;
}

Expand Down