In Unix v7 mkdir was not a system call. It was a setuid program implemented using mknod + link. That was racy so the mkdir(2) system call was added. But it could have been solved more generally (and more elegantly) by adding transactions.
Re:The trouble with symbolic links
by bhawks on Friday July 22, 2022 @07:59AM
(#32191006)
A general purpose transactional interface widene the error space to include cross process deadlocks / denial of service not to mention performance issues.
It could also solve the whole thing with ending up with zero-length files because you didn't use the right incantation to update a file atomically on ext4 (https://thunk.org/tytso/blog/2009/03/12/delayed-allocation-a...).