Skip to content

path_filestat_get failure. #4869

Open
Open
@Userzxcvbvnm

Description

@Userzxcvbvnm

Describe the bug

Read bytes bug.

Steps to reproduce

(1)The test case is :


#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <stdlib.h>


void path_filestat_get_00001_1d3ff(const char *filename) {
    printf("Enter function path_filestat_get_00001_1d3ff\n");

    struct stat file_stat;
    if (stat(filename, &file_stat) == -1) {
        printf("Error getting file status.\n");
        return;
    }

    printf("File Size: %lld bytes\n", (long long)file_stat.st_size);
    printf("File Permissions: %o\n", file_stat.st_mode & 0777);
    printf("File Owner ID: %d\n", file_stat.st_uid);
    printf("File Group ID: %d\n", file_stat.st_gid);
    printf("Last Access Time: %lld\n", (long long)file_stat.st_atime);
    printf("Last Modification Time: %lld\n", (long long)file_stat.st_mtime);
    printf("Last Status Change Time: %lld\n", (long long)file_stat.st_ctime);

    printf("Leave path_filestat_get_00001.\n");
}

int main() {
    printf("Enter function main\n");
    path_filestat_get_00001_1d3ff("subdir_1");
    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, directory subdir_1 exists.)
wasmer run --dir=. test.wasm

Expected behavior

print:

Enter function main
Enter function path_filestat_get_00001_1d3ff
File Size: 4096 bytes
File Permissions: 0
File Owner ID: 0
File Group ID: 0
Last Access Time: 1718787347
Last Modification Time: 1718787347
Last Status Change Time: 1718787347
Leave path_filestat_get_00001.

And this is what WAMR, wasmtime and WasmEdge do.

Actual behavior

wasmer print:

Enter function main
Enter function path_filestat_get_00001_1d3ff
Error getting file status.

Additional context

Ubuntu 20.04
x86_64
wasmer-4.3.1

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpriority-highHigh priority issue📦 lib-vfsAbout wasmer-vfs

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions