pgsql: Refactor new file permission handling

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Refactor new file permission handling
Date: 2017-09-23 14:22:05
Message-ID: E1dvlJl-0002zO-Px@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Refactor new file permission handling

The file handling functions from fd.c were called with a diverse mix of
notations for the file permissions when they were opening new files.
Almost all files created by the server should have the same permissions
set. So change the API so that e.g. OpenTransientFile() automatically
uses the standard permissions set, and OpenTransientFilePerm() is a new
function that takes an explicit permissions set for the few cases where
it is needed. This also saves an unnecessary argument for call sites
that are just opening an existing file.

While we're reviewing these APIs, get rid of the FileName typedef and
use the standard const char * for the file name and mode_t for the file
mode. This makes these functions match other file handling functions
and removes an unnecessary layer of mysteriousness. We can also get rid
of a few casts that way.

Author: David Steele <david(at)pgmasters(dot)net>

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/0c5803b450e0cc29b3527df3f352e6f18a038cc6

Modified Files
--------------
contrib/pg_stat_statements/pg_stat_statements.c | 5 +-
src/backend/access/heap/rewriteheap.c | 8 ++-
src/backend/access/transam/slru.c | 7 ++-
src/backend/access/transam/timeline.c | 8 ++-
src/backend/access/transam/twophase.c | 5 +-
src/backend/access/transam/xlog.c | 28 ++++------
src/backend/access/transam/xlogutils.c | 2 +-
src/backend/catalog/catalog.c | 2 +-
src/backend/libpq/be-fsstubs.c | 6 +--
src/backend/replication/logical/origin.c | 7 ++-
src/backend/replication/logical/reorderbuffer.c | 7 ++-
src/backend/replication/logical/snapbuild.c | 5 +-
src/backend/replication/slot.c | 6 +--
src/backend/replication/walsender.c | 4 +-
src/backend/storage/file/copydir.c | 5 +-
src/backend/storage/file/fd.c | 68 ++++++++++++++++++-------
src/backend/storage/ipc/dsm_impl.c | 2 +-
src/backend/storage/smgr/md.c | 12 ++---
src/backend/utils/cache/relmapper.c | 7 +--
src/backend/utils/misc/guc.c | 3 +-
src/include/storage/fd.h | 15 +++---
21 files changed, 110 insertions(+), 102 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2017-09-23 17:02:36 pgsql: Ten-second timeout in 013_crash_restart.pl is not enough, let's
Previous Message Peter Eisentraut 2017-09-23 14:17:26 Re: pgsql: Fix saving and restoring umask