Closed pchickey closed 1 year ago
Looking at POSIX, all the *at
functions fail with ENOTDIR
when the dirfd is not a dir. Would it make sense to add a get_base_dir
accessor to Descriptor
which fails with ENOTDIR
and then use that in all the *at
functions?
I believe the *at
functions from linux are the path_*
functions in WASI. Yes, we could switch them to return NOTDIR for files and BADF when the table entry is neither a dir nor a file. I believe this will require updating the test suite to expect that error in a bunch of other spots, though.
@sunfishcode updated, with a test that shows every relevant failure gives NOTDIR
Looks good!
All preview1
path_
apis, as well asfd_readdir
, now fail with NOTDIR if they are passed a file (non-directory) fd.This behavior satisfies the
path_open_dirfd
test, but that only specifies the behavior ofpath_open
when passed a non-dir.This behavior comes from way back in https://github.com/CraneStation/wasi-misc-tests/pull/41 which expected NOTDIR to be the error for all *at-style functions.