Fix our Windows stat() emulation to handle file sizes > 4GB.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 9 Oct 2020 20:20:12 +0000 (16:20 -0400)
committerAndrew Dunstan <andrew@dunslane.net>
Thu, 7 Nov 2024 23:10:48 +0000 (09:40 +1030)
commita9beed67670e680edeadd2a3cf7557a3c9808adf
treef16f3d0529c1dfd67ed66c86a2390c8ff39cab05
parentf534e38914eb89b86fca8294c03d21ff72fd0719
Fix our Windows stat() emulation to handle file sizes > 4GB.

Hack things so that our idea of "struct stat" is equivalent to Windows'
struct __stat64, allowing it to have a wide enough st_size field.

Instead of relying on native stat(), use GetFileInformationByHandle().
This avoids a number of issues with Microsoft's multiple and rather
slipshod emulations of stat().  We still need to jump through hoops
to deal with ERROR_DELETE_PENDING, though :-(

Pull the relevant support code out of dirmod.c and put it into
its own file, win32stat.c.

Still TODO: do we need to do something different with lstat(),
rather than treating it identically to stat()?

Juan JosΓ© SantamarΓ­a Flecha, reviewed by Emil Iggland;
based on prior work by Michael Paquier, Sergey Zubkovsky, and others

Discussion: https://postgr.es/m/1803D792815FC24D871C00D17AE95905CF5099@g01jpexmbkw24
Discussion: https://postgr.es/m/15858-9572469fd3b73263@postgresql.org
(cherry picked from commit bed90759fcbcd72d4d06969eebab81e47326f9a2)

Author: Alexandra Wang <alexandra.wang.oss@gmail.com>
configure
configure.in
src/include/port/win32_port.h
src/port/dirmod.c
src/port/win32stat.c [new file with mode: 0644]
src/tools/msvc/Mkvcbuild.pm