Subject: bug#77589: More information

From: dino chiesa <[email-masked]>
Date: Mon, 7 Apr 2025 00:10:33 +0000

>From the Win32 File I/O documentation
https://learn.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants

The bit for a Reparse Point, which includes SymbolicLinks as well as Junctions, is: 

FILE_ATTRIBUTE_REPARSE_POINT
1024 (0x00000400)

After brief inspection, it seems like dired.c file_attributes is relying on s_ISLNK to determine if the file is a symlink. I am not sure what S_ISLNK does  for Windows Junctions or if it even makes sense for a POSIX API to do something special for Windows Junctions. 

In my tests the Attributes surfaced at the powershell layer use that REPARSE_POINT bit, whether it is a symlink (file) or a Junction (directory). 

PS C:\test>  Get-Item -Path regular-file.txt | Select-Object FullName, @{Name='AttributesHex'; Expression={ '0x{0:X}' -f [int]$_.Attributes }} | fl

FullName      : C:\test\regular-file.txt
AttributesHex : 0x20

PS C:\test>  Get-Item -Path "valid-symlink.txt" | Select-Object FullName, @{Name='AttributesHex'; Expression={ '0x{0:X}' -f [int]$_.Attributes }} | fl

FullName      : C:\test\valid-symlink.txt
AttributesHex : 0x420

PS C:\test>  Get-Item -Path "this-is-a-directory" | Select-Object FullName, @{Name='AttributesHex'; Expression={ '0x{0:X}' -f [int]$_.Attributes }} | fl

FullName      : C:\test\this-is-a-directory
AttributesHex : 0x10

PS C:\test>  Get-Item -Path "this-is-a-directory-junction" | Select-Object FullName, @{Name='AttributesHex'; Expression={ '0x{0:X}' -f [int]$_.Attributes }} | fl

FullName      : C:\test\this-is-a-directory-junction
AttributesHex : 0x410