Skip to content

Fail to rename a file. #4875

Open
Open
@Userzxcvbvnm

Description

@Userzxcvbvnm

Describe the bug

Fail to write the array content into the file, although print success.

Steps to reproduce

(1)The test case is :


#include <stdio.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_rename_00001_gApN2() {
    printf("Enter function path_rename_00001_gApN2\n");
    
    
    if(renameat(AT_FDCWD, "subdir_3/subfile_2", AT_FDCWD, "NEWNAME") == 0) {
        printf("File or directory renamed successfully.\n");
    } else {
        printf("Error renaming file or directory.\n");
    }
}

int main() {
    
    
    path_rename_00001_gApN2();
    
    
    
    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_2 exists.)
wasmer run --dir=. test.wasm

Expected behavior

print:

Enter function path_rename_00001_gApN2
File or directory renamed successfully.

This is what wasmtime, WAMR and WasmEdge do.

Actual behavior

wasmer print:

Enter function path_rename_00001_gApN2
Error renaming file or directory.

Additional context

Ubuntu 20.04
x86_64
wasmer-4.3.1 and 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