Re: stat() on Windows might cause error if target file is larger than 4GB

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Higuchi, Daisuke" <higuchi(dot)daisuke(at)jp(dot)fujitsu(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: stat() on Windows might cause error if target file is larger than 4GB
Date: 2018-09-13 00:09:11
Message-ID: 20180913000911.GC1387@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Sep 12, 2018 at 12:47:31PM +0900, Michael Paquier wrote:
> That's exactly what I would like to do and what I meant two paragraphs
> above as that's the only solution I think would be clean, and this would
> take care of st_size nicely. I have not tested (yet), but some tweaks
> in win32_port.h could be enough before mapping lstat to stat?

FWIW, I have been digging into this one and as "struct stat" is already
an existing structure when it comes to MSVC, enforcing a mapping of
__stat64 to that is proving to be tedious in one of the port headers.
Another solution would be to modify pgwin32_safestat so as it directly
uses _stat64, and then fill in the results from __stat64 directly to
_stat field by field. One thing which would be bad is that
_stat.st_size is 4 bytes, which would cause the eight high bytes of
__stat64.st_size to be lost, hence if working on a file larger than 4GB
we would send an incorrect size back to the caller, which is worse than
the OVERFLOW we have now. We had better be careful with MinGW as well,
and cygwin does not take this path. Perhaps somebody has a smart idea?
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2018-09-13 00:17:05 Re: stat() on Windows might cause error if target file is larger than 4GB
Previous Message Tom Lane 2018-09-12 23:20:33 Re: [HACKERS] Cutting initdb's runtime (Perl question embedded)