Skip to content

Hard link creation successful print but the file do not exist. #4904

Open
@Userzxcvbvnm

Description

@Userzxcvbvnm

Describe the bug

Hard link creation successful print but the file do not exist.
Related to #4870

Steps to reproduce

(1)The test case is :


#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.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_link_00002_Nan21() {

    printf("Enter function path_link_00002_Nan21\n");
    
    
    
    int result = linkat(AT_FDCWD, "subdir_2/subdir_1/subfile_3", AT_FDCWD, "HARDLINKFILE", AT_SYMLINK_NOFOLLOW);
    
    if (result == -1) {
        printf("linkat failed");
    } else {
        printf("Hard link creation successful\n");
    }

    
}

int main() {
    printf("Enter function main\n");
   
    path_link_00002_Nan21();

    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, file subdir_2/subdir_1/subfile_3 exists.)
wasmer run --dir=. test.wasm

Expected behavior

Successfully create the link file and print:

Enter function main
Enter function path_link_00002_Nan21
Hard link creation successful

And this is what WAMR, wasmtime and WasmEdge do.

Actual behavior

wasmer print:

Enter function main
Enter function path_link_00002_Nan21
Hard link creation successful

But the file HARDLINKFILE does not exist checking by command line, which is different from wasmtime, WAMR and WasmEdge.

Additional context

Ubuntu 20.04
x86_64
wasmer-4.2.2

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