Open
Description
Describe the bug
readdir()
can't return absolute symlinks.
$ wasmer -vV; rustc -vV
wasmer 4.4.0 (b2fa4b1 2024-10-05)
binary: wasmer-cli
commit-hash: b2fa4b19ff24f2facbe878b256c76d8e4bd6b25a
commit-date: 2024-10-05
host: aarch64-unknown-linux-gnu
compiler: singlepass,cranelift
rustc 1.81.0 (eeb90cda1 2024-09-04)
binary: rustc
commit-hash: eeb90cda1969383f56a2637cbd3037bdf598841c
commit-date: 2024-09-04
host: aarch64-unknown-linux-gnu
release: 1.81.0
LLVM version: 18.1.7
Steps to reproduce
cargo new readdir-test
cd readdir-test
cargo add libc
- Edit
src/main.rs
use libc::{opendir, readdir}; use std::ffi::CStr; fn main() { unsafe { let dp = opendir(b"/tmp/test\x00" as *const u8 as *const i8); assert!(!dp.is_null()); loop { let ent = readdir(dp); if ent.is_null() { break; } let name = CStr::from_ptr((*ent).d_name.as_ptr()); println!("{:?}", name); } } }
mkdir /tmp/test
touch /tmp/test/a
touch /tmp/test/b
ln -s /tmp/test/b /tmp/test/c
cargo build --target wasm32-wasip1
(before that, you need to runrustup target add wasm32-wasip1
)wasmer run --mapdir /tmp/test:/tmp/test target/wasm32-wasip1/debug/readdir-test.wasm
Expected behavior
"."
".."
"a"
"b"
"c"
Actual behavior
"."
".."
"a"
"b"