Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[wasm] Fallback to emulated realpath on wasi-libc realpath ENOTSUP #13124

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
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
8 changes: 6 additions & 2 deletions file.c
Original file line number Diff line number Diff line change
Expand Up @@ -4574,12 +4574,16 @@ rb_check_realpath_internal(VALUE basedir, VALUE path, rb_encoding *origenc, enum
if (origenc) unresolved_path = TO_OSPATH(unresolved_path);

if ((resolved_ptr = realpath(RSTRING_PTR(unresolved_path), resolved_buffer)) == NULL) {
/* glibc realpath(3) does not allow /path/to/file.rb/../other_file.rb,
/*
wasi-libc 22 and later support realpath(3) but return ENOTSUP
when the underlying host syscall returns it.
glibc realpath(3) does not allow /path/to/file.rb/../other_file.rb,
returning ENOTDIR in that case.
glibc realpath(3) can also return ENOENT for paths that exist,
such as /dev/fd/5.
Fallback to the emulated approach in either of those cases. */
if (errno == ENOTDIR ||
if (errno == ENOTSUP ||
errno == ENOTDIR ||
(errno == ENOENT && rb_file_exist_p(0, unresolved_path))) {
return rb_check_realpath_emulate(basedir, path, origenc, mode);

Expand Down
Loading