Re: BUG #15858: could not stat file - over 4GB
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Juan José Santamaría Flecha <juanjo.santamaria@gmail.com>, Emil Iggland <emil@iggland.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2020-10-12T01:01:08Z
Lists: pgsql-bugs, pgsql-hackers
On Sat, Oct 10, 2020 at 08:34:48PM -0400, Tom Lane wrote:
> Nah, I fixed that hours ago (961e07b8c). jacana must not have run again
> yet.
Indeed, thanks. I have missed one sync here.
+ hFile = CreateFile(name,
+ GENERIC_READ,
+ (FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE),
+ &sa,
+ OPEN_EXISTING,
+ (FILE_FLAG_NO_BUFFERING | FILE_FLAG_BACKUP_SEMANTICS |
+ FILE_FLAG_OVERLAPPED),
+ NULL);
+ if (hFile == INVALID_HANDLE_VALUE)
+ {
+ CloseHandle(hFile);
+ errno = ENOENT;
+ return -1;
+ }
Why are we forcing errno=ENOENT here? Wouldn't it be correct to use
_dosmaperr(GetLastError()) to get the correct errno? This code would
for example consider as non-existing a file even if we fail getting it
because of ERROR_SHARING_VIOLATION, which should map to EACCES. This
case can happen with virus scanners taking a non-share handle on files
being looked at in parallel of this code path.
--
Michael
Commits
-
Minor cleanup for win32stat.c.
- fcd11329db5b 14.0 landed
- 961e07b8ccb5 14.0 landed
- c94cfb38c32a 14.0 landed
-
plperl.h should #undef fstat along with stat and lstat.
- ed30b1a60dad 14.0 cited
-
Fix our Windows stat() emulation to handle file sizes > 4GB.
- bed90759fcbc 14.0 landed