Hiya! I'm looking into the mkdirat and openat syscalls, and I noticed that there's no means of implementing TOCTOU (time-of-check to time-of-use, a technique for preventing race conditions) on directory creation. To create a directory and obtain a dirfd for it, you have to (1) mkdirat, then (2) openat with O_DIRECTORY, and if the directory is removed in between, the latter will fail. One possibly straightforward solution is to support openat with the O_DIRECTORY and O_CREAT flags specified. The present behavior of this flag combination is to create a file and return ENOTDIR. The appropriate behavior is probably to create a directory as proposed, or, at a minimum, to return EINVAL and not create the file.