Open Userzxcvbvnm opened 2 weeks ago
IIUC, you have two questions:
I am just going to answer the second one 😄 .
According to manual,
The function posix_fallocate() ensures that disk space is allocated for the file referred to by the file descriptor fd for the bytes. ... If the size of the file is less than offset+len, then the file is increased to this size; otherwise the file size is left unchanged.
It is not going to increase the file size if there is enough space. In this case, the file size is 26, and offset+len
is 7. So, the file size is left unchanged.
And for sure, you'll see a file size change if use a bigger len
, like
int result = posix_fallocate(fd, 1, 70);
why wasmtime failed but wamr pass
because wasmtime has deprecated fd_allocate while ago, it always fails.
this doesn't seem like a bug in wamr.
Subject of the issue
In this situation, wamr fails to allocate space which is expected ,however, wamr prints success.
Test case
The test case is:
Your environment
Ubuntu 20.04 x86_64 WAMR 1.3.2 and WAMR 1.2.3
Steps to reproduce
(1)compile to wasm:./wasi-sdk-21.0/bin/clang --target=wasm32-unkown-wasi --sysroot=./wasi-sdk-21.0/share/wasi-sysroot test.c -o test.wasm
(2)Running wasm: (Before run the Wasm file, file subdir_2/subfile_1 exists, and file size is 26.) iwasm --dir=. test.wasm
Expected behavior
prints:
This is what wasmtime does.
Actual behavior
WAMR prints:
Extra Info
Anything else you'd like to add?