Re: Checking pgwin32_is_junction() errors

Поиск
Список
Период
Сортировка
От r.zharkov@postgrespro.ru
Тема Re: Checking pgwin32_is_junction() errors
Дата
Msg-id 4c47f84a18696e3cc252709eaf48ab72@postgrespro.ru
обсуждение исходный текст
Ответ на Re: Checking pgwin32_is_junction() errors  (Thomas Munro <thomas.munro@gmail.com>)
Список pgsql-hackers
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



В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Drouvot, Bertrand"
Дата:
Сообщение: Re: shared-memory based stats collector - v70
Следующее
От: "Drouvot, Bertrand"
Дата:
Сообщение: Re: [PATCH] Expose port->authn_id to extensions and triggers