We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
fd_fdstat_set_flags
Describe the bug If a file is opened with oflags::trunc, a call to fd_fdstat_set_flags will truncate the file.
oflags::trunc
To Reproduce
Compile this snippet with wasi-sdk and run it:
wasi-sdk
clang wazero-write.c mkdir -p tmp wazero run -mount tmp a.out stat tmp/a
#include <fcntl.h> #include <string.h> #include <stdio.h> #include <unistd.h> int main(void) { int fd = open("tmp/a", O_RDWR | O_CREAT | O_TRUNC); if (fd == -1) { perror("open"); return 1; } char * buf = "abc"; int written = write(fd, buf, 3); printf("written %d\n", written); int fcntl_ret = fcntl(fd, F_SETFL, 0); if (fcntl_ret != 0) { perror("fcntl"); return 1; } return 0; }
Expected behavior The file should be size 3 because we wrote 3 bytes to it. But it is size 0.
Environment (please complete the relevant information):
5796897f37852bf2042cd63959ce4ff673c4366e
Additional context Compiling the same snippet with native clang or gcc and running it will produce a 3-byte file as expected.
The text was updated successfully, but these errors were encountered:
confirmed that even with other runtimes the byte size is still 3 after stat
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
Describe the bug
If a file is opened with
oflags::trunc
, a call tofd_fdstat_set_flags
will truncate the file.To Reproduce
Compile this snippet with
wasi-sdk
and run it:Expected behavior
The file should be size 3 because we wrote 3 bytes to it. But it is size 0.
Environment (please complete the relevant information):
5796897f37852bf2042cd63959ce4ff673c4366e
Additional context
Compiling the same snippet with native clang or gcc and running it will produce a 3-byte file as expected.
The text was updated successfully, but these errors were encountered: