0001-Fix-get_dirent_type-for-Windows-junction-points.patch
text/x-patch
Filename: 0001-Fix-get_dirent_type-for-Windows-junction-points.patch
Type: text/x-patch
Part: 0
Patch
Format: format-patch
Series: patch 0001
Subject: Fix get_dirent_type() for Windows junction points.
| File | + | − |
|---|---|---|
| src/port/dirent.c | 4 | 4 |
From 68883f29d86b7cbbc9120e0c42a9f5bd8146645f Mon Sep 17 00:00:00 2001 From: Thomas Munro <thomas.munro@gmail.com> Date: Wed, 30 Mar 2022 17:34:43 +1300 Subject: [PATCH 1/2] Fix get_dirent_type() for Windows junction points. Commit 87e6ed7c8 included code that purported to report Windows "junction" points as DT_LNK (ie the same way we report symlinks on Unix). Windows junction points are also directories according to the Windows attributes API, and we were reporting them as as DT_DIR. Change the order we check the attribute flags, to prioritize DT_LNK. If at some point we start using Windows' recently added real symlinks and need to distinguish them from junction points, we may need to rethink this, but for now this continues the tradition of wrapper functions that treat junction points as symlinks. Back-patch to 14, where get_dirent_type() landed. Discussion: https://postgr.es/m/CA%2BhUKGLzLK4PUPx0_AwXEWXOYAejU%3D7XpxnYE55Y%2Be7hB2N3FA%40mail.gmail.com --- src/port/dirent.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/port/dirent.c b/src/port/dirent.c index f67bbf7f71..b5a66ca93c 100644 --- a/src/port/dirent.c +++ b/src/port/dirent.c @@ -107,12 +107,12 @@ readdir(DIR *d) strcpy(d->ret.d_name, fd.cFileName); /* Both strings are MAX_PATH long */ d->ret.d_namlen = strlen(d->ret.d_name); /* The only identified types are: directory, regular file or symbolic link */ - 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)) + if ((fd.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0 && + (fd.dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT)) d->ret.d_type = DT_LNK; + else if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0) + d->ret.d_type = DT_DIR; else d->ret.d_type = DT_REG; -- 2.35.1