Re: [patch] pg_copy - a command for reliable WAL archiving
От | Alvaro Herrera |
---|---|
Тема | Re: [patch] pg_copy - a command for reliable WAL archiving |
Дата | |
Msg-id | 20140820132736.GA7648@eldon.alvh.no-ip.org обсуждение исходный текст |
Ответ на | Re: [patch] pg_copy - a command for reliable WAL archiving (Greg Stark <stark@mit.edu>) |
Ответы |
Re: [patch] pg_copy - a command for reliable WAL archiving
|
Список | pgsql-hackers |
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
В списке pgsql-hackers по дате отправления: