Version of emscripten/emsdk:
POSIX says a trailing slash implies directory access: open("file/", O_RDONLY) must fail with ENOTDIR when file is a regular file. Under MEMFS the call succeeds and returns a valid fd.
Failing command line in full:
$ emcc -O0 -Wall trailing.c -o a.out.js
$ node a.out.js
open(file/): fd=3 errno=0
The same program on native Linux prints open(file/): fd=-1 errno=20.
Example code snippet:
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <stdio.h>
#include <errno.h>
int main(void) {
mkdir("/tmp/xsv_test", 0755);
int fd = open("/tmp/xsv_test/file.txt", O_WRONLY | O_CREAT | O_TRUNC, 0644);
write(fd, "hello", 5); close(fd);
errno = 0;
fd = open("/tmp/xsv_test/file.txt/", O_RDONLY); // trailing slash
printf("open(file/): fd=%d errno=%d\n", fd, errno);
return (fd < 0) ? 0 : 1;
}
Version of emscripten/emsdk:
POSIX says a trailing slash implies directory access:
open("file/", O_RDONLY)must fail withENOTDIRwhenfileis a regular file. Under MEMFS the call succeeds and returns a valid fd.Failing command line in full:
The same program on native Linux prints
open(file/): fd=-1 errno=20.Example code snippet: