Skip to content

Commit c1cfa16

Browse files
committed
Make readlink system call not resolve the link
Readlink in linux does not resolve the link, it returns the exact link contents.
1 parent b3edd4c commit c1cfa16

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/library_fs.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ FS.staticInit();
895895
}
896896
#endif
897897
},
898-
readlink(path) {
898+
readlink(path, opts = {}) {
899899
var lookup = FS.lookupPath(path);
900900
var link = lookup.node;
901901
if (!link) {
@@ -904,7 +904,11 @@ FS.staticInit();
904904
if (!link.node_ops.readlink) {
905905
throw new FS.ErrnoError({{{ cDefs.EINVAL }}});
906906
}
907-
return PATH_FS.resolve(FS.getPath(link.parent), link.node_ops.readlink(link));
907+
const target = link.node_ops.readlink(link);
908+
if (opts.noResolve) {
909+
return target;
910+
}
911+
return PATH_FS.resolve(FS.getPath(link.parent), target);
908912
},
909913
stat(path, dontFollow) {
910914
var lookup = FS.lookupPath(path, { follow: !dontFollow });

0 commit comments

Comments
 (0)