Re: Checking pgwin32_is_junction() errors
Thomas Munro <thomas.munro@gmail.com>
From: Thomas Munro <thomas.munro@gmail.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2022-07-28T09:31:44Z
Lists: pgsql-hackers
Attachments
- 0001-Added-Windows-with-MinGW-environment-in-Cirrus-CI.patch (text/x-patch) patch 0001
- 0002-Provide-lstat-for-Windows.patch (text/x-patch) patch 0002
- 0003-Remove-pgwin32_is_junction.patch (text/x-patch) patch 0003
Here's a better idea, now that I'm emboldened by having working CI for Windows frankenbuilds, and since I broke some stuff in this area on MSYS[1], which caused me to look more closely at this area. Why don't we just nuke pgwin32_is_junction() from orbit, and teach Windows how to lstat()? We're already defining our own replacement stat() used in both MSVC and MSYS builds along with our own junction point-based symlink() and readlink() functions, and lstat() was already suggested in a comment in win32stat.c. There's one curious change in the draft patch attached: you can't unlink() a junction point, you have to rmdir() it. Previously, things that traverse directories without ever calling pgwin32_is_junction() would see junction points as S_ISDIR() and call rmdir(), which was OK, but now they see S_ISLNK() and call unlink(). So I taught unlink() to try both things. Which is kinda weird, and not beautiful, especially when combined with the existing looping weirdness. 0001 is a copy of v2 of Melih Mutlu's CI patch[2] to show cfbot how to test this on MSYS (alongside the normal MSVC result), but that's not part of this submission. [1] https://www.postgresql.org/message-id/flat/b9ddf605-6b36-f90d-7c30-7b3e95c46276%40dunslane.net [2] https://www.postgresql.org/message-id/flat/CAGPVpCSKS9E0An4%3De7ZDnme%2By%3DWOcQFJYJegKO8kE9%3Dgh8NJKQ%40mail.gmail.com
Commits
-
Fix readlink() for non-PostgreSQL junction points on Windows.
- f71007fbb3b8 16.0 landed
-
Fix stat() for recursive junction points on Windows.
- 4517358ee782 16.0 landed
-
aix: fix misreading of condition in 8f12a4e7add
- 7e29a79a46d3 16.0 cited
-
Make unlink() work for junction points on Windows.
- f357233c9db8 16.0 landed
-
Replace pgwin32_is_junction() with lstat().
- 5fc88c5d53e4 16.0 landed
-
Provide lstat() for Windows.
- c5cb8f3b770c 16.0 landed