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 1oLMxY-0001YU-3c for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Aug 2022 10:59:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oLMxW-0002a6-Ex for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Aug 2022 10:59:38 +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 1oLMxV-0002Xr-UK for pgsql-hackers@lists.postgresql.org; Tue, 09 Aug 2022 10:59:38 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by magus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oLMxT-0000gr-5O for pgsql-hackers@postgresql.org; Tue, 09 Aug 2022 10:59:37 +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 271F821C57FF; Tue, 9 Aug 2022 13:59:34 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1660042774; bh=KrAL4qfaUS5z6HF1TCurJ0MGhJhnBjCQNbniWhiikRg=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=JvvtOweSzvytm/ayFWBiUIwNTkMPvqqeYzpn/8YwNOwU/LcEVEv/Y4id9HIdfFIz9 N+5GVS0QglPAtyOLa9VxFxCrSYipr9cw+7x4BJOHCCN7mLJToDQhqm1PvOCRURUHXz tl+piR0JsNRiTazmZw8oeb71QDXBXcSiqN1AhpqY= MIME-Version: 1.0 Date: Tue, 09 Aug 2022 17:59:33 +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: X-Sender: r.zharkov@postgrespro.ru Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2022-08-09 05:44, Thomas Munro wrote: > On Tue, Aug 9, 2022 at 8:30 AM Thomas Munro > wrote: >> On Mon, Aug 8, 2022 at 8:23 PM wrote: >> > "C:/HOME" is the junction point to the second volume on my hard drive - >> > "\??\Volume{GUID}\" which name pgreadlink() erroneously strips here: >> > https://github.com/postgres/postgres/blob/7e29a79a46d30dc236d097825ab849158929d977/src/port/dirmod.c#L357. > >> ... Would it >> be better to say: if it doesn't begin with "\??\X:", where X could be >> any letter, then don't modify it? > > Concretely, I wonder if this is a good fix at least in the short term. > Does this work for you, and do the logic and explanation make sense? Yes, this patch works well with my junction points. 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] After hours of reading the documentation and debugging, it seems to me we can use REPARSE_GUID_DATA_BUFFER structure instead of our REPARSE_JUNCTION_DATA_BUFFER [1]. DataBuffer doesn't contain any prefixes, so we don't need to strip them. But we still need to construct a correct volume name if a junction point is a volume mount point. Is it worth to check this idea? [1] https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-reparse_guid_data_buffer