The curious case of O_DIRECTORY|O_CREAT
The curious case of O_DIRECTORY|O_CREAT
Posted Mar 29, 2023 5:37 UTC (Wed) by NYKevin (subscriber, #129325)In reply to: The curious case of O_DIRECTORY|O_CREAT by interalia
Parent article: The curious case of O_DIRECTORY|O_CREAT
It is possible for A to use unlinkat(2) to remove the directory immediately after creating it (with AT_REMOVEDIR). In principle, I imagine that you might be able to continue using other fooat syscalls on the unlinked directory until you close it, thus creating a "true" temporary directory, but I have not tried it.
That still doesn't work because you race against someone else opening the directory before you can unlink it, but it's a neat party trick (if it works).
