Fix stat() for recursive junction points on Windows.
authorThomas Munro <[email protected]>
Tue, 25 Oct 2022 02:24:41 +0000 (15:24 +1300)
committerAndrew Dunstan <[email protected]>
Sat, 18 Jan 2025 14:33:43 +0000 (09:33 -0500)
commitfbf8efbda88ce3cac6b135cbba93d4ee7c80dde8
treecf97192ffdc4313343406ef7f78391d366ad12a2
parent4d6d7bdc064201076d2cf361c779b0a3dd4fafa9
Fix stat() for recursive junction points on Windows.

Commit c5cb8f3b supposed that we'd only ever have to follow one junction
point in stat(), because we don't construct longer chains of them ourselves.
When examining a parent directory supplied by the user, we should really be
able to cope with longer chains, just in case someone has their system
set up that way.  Choose an arbitrary cap of 8, to match the minimum
acceptable value of SYMLOOP_MAX in POSIX.

Previously I'd avoided reporting ELOOP thinking Windows didn't have it,
but it turns out that it does, so we can use the proper error number.

Reviewed-by: Roman Zharkov <[email protected]>
Discussion: https://postgr.es/m/CA%2BhUKGJ7JDGWYFt9%3D-TyJiRRy5q9TtPfqeKkneWDr1XPU1%2Biqw%40mail.gmail.com
Discussion: https://postgr.es/m/CA%2BhUKG%2BajSQ_8eu2AogTncOnZ5me2D-Cn66iN_-wZnRjLN%2Bicg%40mail.gmail.com

Backpatched commit 4517358e as above by Thomas Munro into releases 13 thru 15

Discussion: https://postgr.es/m/CA+hUKGLbnv+pe3q1fYOVkLD3pMra7GuihfMxUN-1831YH9RYQg@mail.gmail.com
src/port/win32stat.c