Open Userzxcvbvnm opened 1 week ago
The fcntl
function can only affect the file status flags, but O_TRUNC
or O_CREAT
is also an opening flag. O_CREAT
is used when a file is initially opened to create the file if it does not already exist and O_TRUNC
truncates the file to zero length, the file size should be zero when checked right after opening the file. They are not part of the file status flags that can be modified or retrieved using fcntl
.
If you try a modifiable flag like O_APPEND, it will be set successfully:
Get file descriptor of file subfile_3 succeed!
Access mode: Write Only
Enter function fd_fdstat_set_flags_00006_ZJtyU
Setting flags succeed!
After setting flags
Access mode: Write Only
Access mode: O_APPEND
Subject of the issue
In this situation, wamr fail to print O_TRUNC and O_CREAT. I'm not sure whether this is a bug.
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 subfile_3 exists, and file size is 26.) iwasm --dir=. test.wasm
Expected behavior
prints:
Actual behavior
WAMR prints: