Greg Stark wrote: > char path[PATH_MAX]; > fd = open("/path/to/dir", O_TMPFILE | O_RDWR, > S_IRUSR | S_IWUSR); > > /* File I/O on 'fd'... */ > > snprintf(path, PATH_MAX, "/proc/self/fd/%d", fd); > linkat(AT_FDCWD, path, AT_FDCWD, "/path/for/file", > AT_SYMLINK_FOLLOW);
Hmm, the real trick here is linkat(... "/proc/self/foobar"), not the O_TMPFILE: you can have an open file descriptor to an "invisible" file simply by creating a normal file and unlinking it. I looked at linkat() yesterday but the idea of using /proc/self didn't occur to me. Nasty trick :-( It seems linkat() is quite a bit more portable than O_TMPFILE, fortunately ... -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers