Open
Description
Describe the bug
Fail to delete the file, I'm not sure whether this is a bug.
Steps to reproduce
(1)The test case is :
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
int get_fd(const char *filename, int flags) {
int fd = open(filename, flags);
if (fd == -1) {
printf("Get file descriptor of file %s failed!\n", filename);
return -1;
} else {
printf("Get file descriptor of file %s succeed!\n", filename);
return fd;
}
}
void closebyfd(int fd) {
if (close(fd) == -1) {
printf("Close the file %d by descriptor failed!\n", fd);
}
}
void path_unlink_file_00001_ggOQt() {
printf("Enter function path_unlink_file_00001_ggOQt\n");
if (unlinkat(AT_FDCWD, "subdir_3/subfile_1", 0) == -1) {
printf("Unlink file failed!\n");
return;
}
printf("File unlinked successfully\n");
}
int main() {
path_unlink_file_00001_ggOQt();
return 0;
}
(2)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
(3)Running wasm:
(Before run the Wasm file, subdir_3/subfile_1 exists .)
wasmer run --dir=. test.wasm
Expected behavior
print:
Enter function path_unlink_file_00001_ggOQt
File unlinked successfully
This is what wasmtime, WAMR and WasmEdge do.
Actual behavior
wasmer also print:
Enter function path_unlink_file_00001_ggOQt
Unlink file failed!
Additional context
Ubuntu 20.04
x86_64
wasmer-4.3.1