Make safeguard against incorrect flags for fsync more portable.
authorTom Lane <[email protected]>
Tue, 1 Jul 2025 16:08:20 +0000 (12:08 -0400)
committerTom Lane <[email protected]>
Tue, 1 Jul 2025 16:08:57 +0000 (12:08 -0400)
commit0fb496c704fce0daeb01cb3736a827ec009f382e
tree56d8b988a19690a03fa8b4f415770e9e5c19d3c6
parent8f456630ce9354a96f20c00a1339a59f33da2930
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 <[email protected]>
Co-authored-by: Samuel Thibault
Reviewed-by: Tom Lane <[email protected]>
Discussion: https://postgr.es/m/6862e8d1.050a0220[email protected]
Discussion: https://postgr.es/m/68480868.5d0a0220[email protected]
Backpatch-through: 13
src/backend/storage/file/fd.c