pgsql: Make safeguard against incorrect flags for fsync more portable.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Make safeguard against incorrect flags for fsync more portable.
Date: 2025-07-01 16:09:12
Message-ID: E1uWdXk-004DHo-0B@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Make safeguard against incorrect flags for fsync more portable.

The existing code assumed that O_RDONLY is defined as 0, but this is
not required by POSIX and is not true on GNU Hurd. We can avoid
the assumption by relying on O_ACCMODE to mask the fcntl() result.
(Hopefully, all supported platforms define that.)

Author: Michael Banck <mbanck(at)gmx(dot)net>
Co-authored-by: Samuel Thibault
Reviewed-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://postgr.es/m/6862e8d1.050a0220.194b8d.76fa@mx.google.com
Discussion: https://postgr.es/m/68480868.5d0a0220.1e214d.68a6@mx.google.com
Backpatch-through: 13

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/3a2617e4f0be734f58f7219986c323469b502921

Modified Files
--------------
src/backend/storage/file/fd.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2025-07-01 16:40:44 pgsql: Make sure IOV_MAX is defined.
Previous Message Nathan Bossart 2025-07-01 15:37:52 pgsql: Document age(xid) and mxid_age(xid).