Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an equivalent of O_TMPFILE for directories?

Tags:

c

linux

posix

Ideally, I want to have a directory that is not visible in the filesystem and that will be automatically removed when it's last open file descriptor is closed. It's contents would only be accessible through openat(), fstatat(), etc.

For regular files, this behaviour is achieved by giving the O_TMPFILE flag to open(). However, mkdir() doesnt have a flags parameter.

Assuming I have the latest linux kernel available, is this possible?

like image 827
Benno Avatar asked Aug 13 '15 14:08

Benno


1 Answers

I'm not aware of any way to do this, and don't expect it to be possible. Unlike files, which can have zero or more pathnames (due to hard links and unlinked files), directories have exactly one pathname, and it would probably break some valid application usage if the OS did not meet this expectation.

like image 66
R.. GitHub STOP HELPING ICE Avatar answered Oct 30 '22 00:10

R.. GitHub STOP HELPING ICE