wasmi icon indicating copy to clipboard operation
wasmi copied to clipboard

WASI: Can't open a file with both truncate and append flags

Open yagehu opened this issue 1 year ago • 4 comments

Compile this snippet with wasi-sdk and run it with wasmi will generate an invalid argument error. It does NOT error on other runtimes like Wasmtime or on native Linux.

$ clang wasmi-creat.c
$ wasmi_cli --dir . a.out
executing File("a.out")::_start() ...
open: Invalid argument
#include <fcntl.h>
#include <stdio.h>

int main(void) {
  int fd = open("a", O_CREAT | O_WRONLY | O_APPEND | O_TRUNC);
  if (fd == -1) {
    perror("open");
    return 1;
  }

  return 0;
}

yagehu avatar Dec 21 '23 04:12 yagehu