Hi, hackers!

Do we have any standard set of functions to operate with files?

I mean link(), copy(), rename(), unlink(), ftruncate() and so on.
Mostly I worry about the first two since they have different
implementation on Windows.
I found a couple of functions in src/backend/storage/file/copydir.c,
some more in src/bin/pg_upgrade/file.c along with a set of defines
in src/bin/pg_upgrade/pg_upgrade.h. Obviously md.c and fd.c contain
some functions.
Do we have any policy of using them? There is a comment in fd.c

 * For this scheme to work, most (if not all) routines throughout the
 * server should use these interfaces instead of calling the C library
 * routines (e.g., open(2) and fopen(3)) themselves.  Otherwise, we
 * may find ourselves short of real file descriptors anyway.

and even more in fd.h

 *    File {Close, Read, Write, Seek, Tell, Sync}
 *    {Path Name Open, Allocate, Free} File
 * Use them for all file activity...

but I see that, for example, pg_open_tzfile() and get_controlfile(), logfile_open() call open()/fopen() directly. Same behavior you can find for any C library function.
Am I missing something important or it is simply a legasy/overlooked code?

What do you think about moving stuff from pg_upgrade/file.c to storage/file/
to allow reuse of this code? I think it'll be really helpful for developers of contrib modules
like backup managers.

Anastasia Lubennikova
Postgres Professional:http://www.postgrespro.com
The Russian Postgres Company

Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:

Reply via email to