emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.92k stars 3.32k forks source link

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

Closed hoodmane closed 1 week ago

hoodmane commented 1 week ago

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 (437140d149d9c977ffc8b09dbaf9b0f5a02db190) clang version 20.0.0git (https:/github.com/llvm/llvm-project 1c4caece05f1885ba6ed80755d6b5de1b9f99579) Target: wasm32-unknown-emscripten Thread model: posix

hoodmane commented 1 week ago

Okay well now I'm trying it again and getting Error 2: No such file or directory with gcc.