File system operations. - Mailing list pgsql-hackers

From Anastasia Lubennikova
Subject File system operations.
Date
Msg-id 7c702f13-3270-863a-9874-69818aa2adbd@postgrespro.ru
Whole thread Raw
Responses Re: File system operations.  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
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
callingthe C library * routines (e.g., open(2) and fopen(3)) themselves.  Otherwise, we * may find ourselves short of
realfile descriptors anyway.
 

and even more in fd.h
 *    File {Close, Read, Write, Seek, Tell, Sync} *    {Path Name Open, Allocate, Free} File * * These are NOT JUST
RENAMINGSOF THE UNIX ROUTINES. * 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




pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Surprising behaviour of \set AUTOCOMMIT ON
Next
From: Tom Lane
Date:
Subject: Re: Printing bitmap objects in the debugger