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 1oLMU0-0008Te-IM for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Aug 2022 10:29:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oLMTy-0002Zc-Q0 for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Aug 2022 10:29:06 +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 1oLMTy-0002Wb-Aa for pgsql-hackers@lists.postgresql.org; Tue, 09 Aug 2022 10:29:06 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by magus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oLMTv-0000Qr-Hw for pgsql-hackers@postgresql.org; Tue, 09 Aug 2022 10:29:05 +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 BCE2721C5BB5; Tue, 9 Aug 2022 13:29:01 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1660040941; bh=00rEELOxBlvQTvx1pqw1dGOwGk8kU6QwQGgCu2DLssc=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=XCn9L3j6SZLNhi9KiKpWos3bvlgGrH8Gju5EKz3kr3U4iYq+ne40hgmyIEcWJsobp k78TYDWM4DdYiWlAeLGH8eUKzMKUmr2QF6ySZBsch/T3+Hv0yvIrz6vs6u5ix4NSDe APQym+qJ1CK4CEbVNV5VXIQbnhil906Z6H6yqKss= MIME-Version: 1.0 Date: Tue, 09 Aug 2022 17:29:00 +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: <4c47f84a18696e3cc252709eaf48ab72@postgrespro.ru> 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 03:30, Thomas Munro wrote: > Then our readlink() emulation removes it again, but in the case of > your \??\Volume{GUID} path, created by you, not our symlink() > emulation, removing "\??\" apparently makes it unopenable with > CreateFile() (I guess that's what fails? What's the error?). So your > patch just says: don't strip "\??\" if it's followed by "Volume". Sorry, I thought wrong that everyone sees the backtrace on my screen. Failes the CreateFile() function with fileName = "Volume{GUID}\" at [1]. And the GetLastError() returnes 2 (ERROR_FILE_NOT_FOUND). Call Stack: initdb.exe!pgwin32_open_handle(const char * fileName, ...) Line 111 C initdb.exe!_pglstat64(const char * name, stat * buf) Line 128 C initdb.exe!_pgstat64(const char * name, stat * buf) Line 221 C initdb.exe!pg_mkdir_p(char * path, int omode) Line 123 C initdb.exe!create_data_directory() Line 2537 C initdb.exe!initialize_data_directory() Line 2696 C initdb.exe!main(int argc, char * * argv) Line 3102 C > I don't understand all the kinds of DOS, Windows and NT paths (let me > take a moment to say how much I love Unix), but here's a guess: could > it be that NT "\??\C:\foo" = DOS "C:\foo", but NT "\??\Volume..." = > DOS "\Volume..."? In other words, if it hasn't got a drive letter, > maybe it still needs an initial "\" (or if not that, then *something* > special, because otherwise it looks like a relative path). It seems to me, when we call CreateFile() Windows Object Manager searches DOS devices (drive letters in our case) in DOS Device namespaces. But it doesn't search the "Volume{GUID}" devices which must be named as "\\?\Volume{GUID}\" [2]. > Would it be better to say: if it doesn't begin with "\??\X:", where X > could be any letter, then don't modify it? > I think it will be better. [1] https://github.com/postgres/postgres/blob/7e29a79a46d30dc236d097825ab849158929d977/src/port/open.c#L86 [2] https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-volume