pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: r.zharkov@postgrespro.ru
To: Thomas Munro <thomas.munro@gmail.com>
Cc: Andrew Dunstan <andrew@dunslane.net>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: Checking pgwin32_is_junction() errors
Date: Tue, 09 Aug 2022 17:29:00 +0700
Message-ID: <4c47f84a18696e3cc252709eaf48ab72@postgrespro.ru> (raw)
In-Reply-To: <CA+hUKG+AZOyOoQx11PLF7Kk+SzMz98Hp_RyY-qqSQdM_NsB4PA@mail.gmail.com>
References: <CA+hUKGLfOOeyZpm5ByVcAt7x5Pn-=xGRNCvgiUPVVzjFLtnY0w@mail.gmail.com>
	<YmEOJwmmKPugH41o@paquier.xyz>
	<CA+hUKG+ntyS1CDxf5z9qNS41uYasqCQf+o44X3ALD9XnUmmqRA@mail.gmail.com>
	<CA+hUKGL97TZhXcaey8Vm0uKt6CTzyXDDQEvffHh6ZkkmAXvjcQ@mail.gmail.com>
	<e516eed3-3555-cdad-663e-e59e4a2b0355@dunslane.net>
	<205d5e64-6e0a-dede-5128-a55b54f4356f@dunslane.net>
	<CA+hUKGKn7Krpdx1+Wy5jMzKBZBP7hUX8igyMYXRRrDiQy_rPZw@mail.gmail.com>
	<CA+hUKGKWR3=B_=qg_+bmX=pjtQ5Zk_3Agco7xg8GgpvZBafJ7w@mail.gmail.com>
	<CA+hUKGK+V61MRXsjUEO5GnhmpveoL6v5Ud7by2DFwVTeZuUBeg@mail.gmail.com>
	<4590c37927d7b8ee84f9855d83229018@postgrespro.ru>
	<CA+hUKG+AZOyOoQx11PLF7Kk+SzMz98Hp_RyY-qqSQdM_NsB4PA@mail.gmail.com>

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#L...
[2] 
https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-volume





view thread (17+ messages)  latest in thread

Message-ID: <4c47f84a18696e3cc252709eaf48ab72@postgrespro.ru>
Permalink:  ../4c47f84a18696e3cc252709eaf48ab72@postgrespro.ru/
Also on:    postgresql.org/message-id/4c47f84a18696e3cc252709eaf48ab72@postgrespro.ru

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: r.zharkov@postgrespro.ru, thomas.munro@gmail.com, andrew@dunslane.net, michael@paquier.xyz
  Subject: Re: Checking pgwin32_is_junction() errors
  In-Reply-To: <4c47f84a18696e3cc252709eaf48ab72@postgrespro.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox