Skip to content

Emscripten returns ENOENT instead of ENOTDIR when opening file in nonexistent directory #22991

@hoodmane

Description

@hoodmane

a.c:

#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>

int main(void) {
    open("directory-that-does-not-exist/b", O_RDWR | O_CREAT | O_EXCL);
    printf("Error %d: %s\n", errno, strerror(errno));
}

Run it

$ gcc a.c
$ ./a.out
Error 20: Not a directory
$ emcc a.c
$ node a.out.js
Error 44: No such file or directory

Desired behavior

Emscripten should return ENOTDIR not ENOENT

Version of emscripten/emsdk:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.72 (437140d)
clang version 20.0.0git (https:/github.com/llvm/llvm-project 1c4caece05f1885ba6ed80755d6b5de1b9f99579)
Target: wasm32-unknown-emscripten
Thread model: posix

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions