-
Notifications
You must be signed in to change notification settings - Fork 924
Closed
Labels
bugSomething isn't workingSomething isn't workingpriority-mediumMedium priority issueMedium priority issue🏚 staleInactive issues or PRInactive issues or PR📦 lib-vfsAbout wasmer-vfsAbout wasmer-vfs
Milestone
Description
Steps to Reproduce
(1) The cfile is :
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
int path_readlink(int dir_fd, const char* new_link) {
printf("Enter path_readlink.\n");
char target_path[100];
ssize_t len = readlinkat(dir_fd, new_link, target_path, sizeof(target_path) - 1);
if (len == -1) {
perror("Error reading new_link");
close(dir_fd);
return 1;
}
target_path[len] = '\0';
printf("The target of '%s' is: %s\n", new_link, target_path);
printf("Leave path_readlink.\n");
return dir_fd;
}
int snapshot(int myfd){
printf("Enter snapshot\n");
struct stat file_info;
if (fstat(myfd, &file_info) == -1) {
perror("Error getting file attributes");
close(myfd);
return 1;
}
printf("File Size: %lld bytes \n", (long long)file_info.st_size);
if (close(myfd) == -1) {
perror("Error closing file");
return 1;
}
printf("Leave snapshot\n");
return 0;
}
int get_fd(const char* file_name, int open_style){
int fd = open(file_name, open_style);
if (fd == -1) {
perror("Failed to open the file");
return 1;
}
return fd;
}
int path_readlink08qXkTnrh5(int fd) {
const char* new_link = "hello_softlink.txt";
return path_readlink(fd, new_link);
}
int main() {
const char* file_name = "Data/link";
int open_style=O_RDONLY;
int fd = get_fd(file_name, open_style);
path_readlink08qXkTnrh5(fd);
snapshot(fd);
return 0;
}
(2)compile the c file into wasm: ./wasi-sdk-16.0/bin/clang --target=wasm32-unkown-wasi --sysroot=./wasi-sdk-16.0/share/wasi-sysroot read.c -o read.wasm
(3)exeute read.wasm
wasmer run --dir=./Data read.wasm
Expected Results
wasmtime,wamr,wasmedge,wazero executing read.wasm file print:
Enter path_readlink.
The target of 'hello_softlink.txt' is: ./hello.txt
Leave path_readlink.
Enter snapshot
File Size: 4096 bytes
Leave snapshot
And using gcc read.c -o read and execute ./read also prints the above result.
Actual Results
wasmer prints:
Enter path_readlink.
Error reading new_link: Permission denied
Enter snapshot
Error getting file attributes: Bad file descriptor
Versions and Environment
wasmer 4.2.2
Operating system: Ubuntu 20.04
Architecture: x86_64
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingpriority-mediumMedium priority issueMedium priority issue🏚 staleInactive issues or PRInactive issues or PR📦 lib-vfsAbout wasmer-vfsAbout wasmer-vfs