Re: pg_tablespace_location() failure with allow_in_place_tablespaces

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Cc: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_tablespace_location() failure with allow_in_place_tablespaces
Date: 2022-03-26 05:33:46
Message-ID: Yj6lurTGNFGg5hEo@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2022-03-26 05:44:43 Re: Accommodate startup process in a separate ProcState array slot instead of in MaxBackends slots.
Previous Message Bharath Rupireddy 2022-03-26 05:21:15 Remove an unused function GetWalRcvWriteRecPtr