Re: pg_tablespace_location() failure with allow_in_place_tablespaces - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: pg_tablespace_location() failure with allow_in_place_tablespaces
Date
Msg-id Yj6lurTGNFGg5hEo@paquier.xyz
Whole thread Raw
In response to Re: pg_tablespace_location() failure with allow_in_place_tablespaces  (Thomas Munro <thomas.munro@gmail.com>)
Responses Re: pg_tablespace_location() failure with allow_in_place_tablespaces  (Thomas Munro <thomas.munro@gmail.com>)
List pgsql-hackers
On Thu, Mar 24, 2022 at 04:41:30PM +1300, Thomas Munro wrote:
> As mentioned, I was unhappy with the lack of error checking for that
> interface, and I've started a new thread about that, but then I
> started wondering if we missed a trick here: get_dirent_type() contain
> code that wants to return PGFILETYPE_LNK for reparse points.  Clearly
> it's not working, based on results reported in this thread.  Is that
> explained by your comment above, "junction points _are_ directories",
> and we're testing the attribute flags in the wrong order here?
>
>     if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
>         d->ret.d_type = DT_DIR;
>     /* For reparse points dwReserved0 field will contain the ReparseTag */
>     else if ((fd.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0 &&
>              (fd.dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT))
>         d->ret.d_type = DT_LNK;
>     else
>         d->ret.d_type = DT_REG;

Ah, good point.  I have not tested on Windows so I am not 100% sure,
but indeed it would make sense to reverse both conditions if a
junction point happens to be marked as both FILE_ATTRIBUTE_DIRECTORY
and FILE_ATTRIBUTE_REPARSE_POINT when scanning a directory.  Based on
a read of the the upstream docs, I guess that this is the case:
https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/ca28ec38-f155-4768-81d6-4bfeb8586fc9

Note the "A file or directory that has an associated reparse point."
for the description of FILE_ATTRIBUTE_REPARSE_POINT.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Bharath Rupireddy
Date:
Subject: Remove an unused function GetWalRcvWriteRecPtr
Next
From: Bharath Rupireddy
Date:
Subject: Re: Accommodate startup process in a separate ProcState array slot instead of in MaxBackends slots.