Re: pg_tablespace_location() failure with allow_in_place_tablespaces
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Thomas Munro <thomas.munro@gmail.com>
Cc: Kyotaro Horiguchi <horikyota.ntt@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2022-03-26T05:33:46Z
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
Commits
-
Remove unnecessary Windows-specific basebackup code.
- 202b56ba91cb 15.0 landed
- 5344723755bd 16.0 landed
-
Fix get_dirent_type() for Windows junction points.
- fee0165fc1cf 14.5 landed
- 6d306ab73168 15.0 landed
- 9d3444dcce4d 16.0 landed
-
doc: Remove mention to in-place tablespaces for pg_tablespace_location()
- 7a7cd84893e0 15.0 landed
-
Fix pg_tablespace_location() with in-place tablespaces
- f6f0db4d6240 15.0 landed
-
Fix pg_basebackup with in-place tablespaces.
- c6f2f01611d4 15.0 landed