Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oM5cX-0007g2-TR for pgsql-hackers@arkaria.postgresql.org; Thu, 11 Aug 2022 10:40:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oM5cW-0004OF-QR for pgsql-hackers@arkaria.postgresql.org; Thu, 11 Aug 2022 10:40:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oM5cW-0004KS-A9 for pgsql-hackers@lists.postgresql.org; Thu, 11 Aug 2022 10:40:56 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by magus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oM5cU-0002yd-2O for pgsql-hackers@postgresql.org; Thu, 11 Aug 2022 10:40:55 +0000 Received: from mail.postgrespro.ru (cyclops.postgrespro.ru [93.174.131.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id 859C821C2640; Thu, 11 Aug 2022 13:40:52 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1660214452; bh=Nw1AlA7BT37OFfKSqloSZ4cr8R1+ULULqANbCgqj1gI=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=gdo8F+FiE8FiRzLGXCE1H1+ycE2ent5bAotLdifahH/3boLRjKa49C2B1Dkyv0xsY gMzjXJ3+si6h6e6t7ohsXWOtUzIlmnLhCyleUgsbCQ55sXfS17OVYck3g4K1T+vdJO /Mu2OCC3aKwYn1a93I0Vq4zspm0XiyF6bDfmbMnE= MIME-Version: 1.0 Date: Thu, 11 Aug 2022 17:40:52 +0700 From: r.zharkov@postgrespro.ru To: Thomas Munro Cc: Andrew Dunstan , Michael Paquier , pgsql-hackers Subject: Re: Checking pgwin32_is_junction() errors In-Reply-To: References: <205d5e64-6e0a-dede-5128-a55b54f4356f@dunslane.net> <4590c37927d7b8ee84f9855d83229018@postgrespro.ru> User-Agent: Roundcube Webmail/1.4.11 Message-ID: <1f4749dbfb9163bd2215021aa0ece514@postgrespro.ru> X-Sender: r.zharkov@postgrespro.ru Content-Type: multipart/mixed; boundary="=_cfb711263cb4d7333769645a0db2e8dc" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --=_cfb711263cb4d7333769645a0db2e8dc Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed On 2022-08-11 07:55, Thomas Munro wrote: >> I checked a few variants: >> >> 21.07.2022 15:11 HOME [\??\Volume{GUID}\] >> 09.08.2022 15:06 Test1 [\\?\Volume{GUID}\] >> 09.08.2022 15:06 Test2 [\\.\Volume{GUID}\] >> 09.08.2022 15:17 Test3 [\??\Volume{GUID}\] >> 09.08.2022 15:27 Test4 [C:\temp\1] >> 09.08.2022 15:28 Test5 [C:\HOME\Temp\1] > > One more thing I wondered about, now that we're following junctions > outside PGDATA: can a junction point to another junction? If so, I > didn't allow for that: stat() gives up after one hop, because I > figured that was enough for the stuff we expect inside PGDATA and I > couldn't find any evidence in the man pages that referred to chains. > But if you *are* allowed to create a junction "c:\huey" that points to > junction "c:\dewey" that points to "c:\louie", and then you do initdb > -D c:\huey\pgdata, then I guess it would fail. Would you mind > checking if that is a real possibility, and if so, testing this > chain-following patch to see if it fixes it? I made some junctions and rechecked both patches. 11.08.2022 16:11 donald [C:\huey] 11.08.2022 13:23 huey [C:\dewey] 11.08.2022 13:23 dewey [C:\louie] 11.08.2022 16:57 louie With the small attached patch initdb succeeded in any of these "directories". If the junction chain is too long, initdb fails with "could not create directory" as expected. initdb -D huey/pgdata ... Success. initdb -N -D donald ... Success. 11.08.2022 17:32 1 11.08.2022 17:32 2 [C:\1] 11.08.2022 17:32 3 [C:\2] 11.08.2022 17:32 4 [C:\3] 11.08.2022 17:32 5 [C:\4] 11.08.2022 17:32 6 [C:\5] 11.08.2022 17:32 7 [C:\6] 11.08.2022 17:32 8 [C:\7] 11.08.2022 17:32 9 [C:\8] 11.08.2022 17:32 10 [C:\9] initdb -D 10/pgdata ... creating directory 10/pgdata ... initdb: error: could not create directory "10": File exists initdb -D 9/pgdata ... Success. --=_cfb711263cb4d7333769645a0db2e8dc Content-Transfer-Encoding: base64 Content-Type: text/x-diff; name=win32stat.diff Content-Disposition: attachment; filename=win32stat.diff; size=777 LS0tIHdpbjMyc3RhdC5jLmJhawkyMDIyLTA4LTExIDE3OjE1OjEwLjc3NTQxMjYwMCArMDcwMAor Kysgd2luMzJzdGF0LmMJMjAyMi0wOC0xMSAxNjo0Nzo0MS45OTI4MDU3MDAgKzA3MDAKQEAgLTE4 Niw5ICsxODYsMTIgQEAKIHsNCiAJaW50CQkJbG9vcHMgPSAwOw0KIAlpbnQJCQlyZXQ7DQorCWNo YXIJCWN1cnJbTUFYUEdQQVRIXTsNCiANCiAJcmV0ID0gX3BnbHN0YXQ2NChuYW1lLCBidWYpOw0K IA0KKwlzdHJsY3B5KGN1cnIsIG5hbWUsIE1BWFBHUEFUSCk7DQorDQogCS8qIERvIHdlIG5lZWQg dG8gZm9sbG93IGEgc3ltbGluayAoanVuY3Rpb24gcG9pbnQpPyAqLw0KIAl3aGlsZSAocmV0ID09 IDAgJiYgU19JU0xOSyhidWYtPnN0X21vZGUpKQ0KIAl7DQpAQCAtMjExLDcgKzIxNCw3IEBACiAJ CSAqIFRoYXQgY291bGQgYmUgb3B0aW1pemVkLCBidXQgc3RhdCgpIG9uIHN5bWxpbmtzIGlzIHBy b2JhYmx5IHJhcmUNCiAJCSAqIGFuZCB0aGlzIHdheSBpcyBzaW1wbGUuDQogCQkgKi8NCi0JCXNp emUgPSBy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