Skip to content

--no-cross could work on windows #441

@mailinglists35

Description

@mailinglists35

Is your feature request related to a problem? Please describe.
I'm always frustrated when gdu dies on me on windows with "Error: loading mount points: Only Linux platform is supported for listing mount points" if "--no-cross" is passed.

Describe the solution you'd like
On windows platforms it should obtain file/directory type and if is one of SymbolicLink/Junction for directories or HardLink for files, they should not be further examined.

Describe alternatives you've considered
--ignore-dirs after knowing exactly which ones are the ones crossing into another mount / hardlinked files

Additional context
there is also "Mount Point" type for some, like "Documents and Settings":

PS C:\> fsutil reparsepoint query "Documents and Settings"
Reparse Tag Value : 0xa0000003
Tag value: Microsoft
Tag value: Name Surrogate
Tag value: Mount Point
Substitue Name offset: 0
Substitue Name length: 24
Print Name offset:     26
Print Name Length:     16
Substitute Name:       \??\C:\Users
Print Name:            C:\Users

Reparse Data Length: 0x34
Reparse Data:
0000:  00 00 18 00 1a 00 10 00  5c 00 3f 00 3f 00 5c 00  ........\.?.?.\.
0010:  43 00 3a 00 5c 00 55 00  73 00 65 00 72 00 73 00  C.:.\.U.s.e.r.s.
0020:  00 00 43 00 3a 00 5c 00  55 00 73 00 65 00 72 00  ..C.:.\.U.s.e.r.
0030:  73 00 00 00                                       s...

or via powershell,

PS C:\> Get-Item .\netshare\ | Format-List FullName,LinkType


FullName : C:\netshare\
LinkType : SymbolicLink

ms copilot LLM notes that "On Windows, symlinks and junctions are all reparse points.
To properly detect them you need to call DeviceIoControl with FSCTL_GET_REPARSE_POINT
and parse the REPARSE_DATA_BUFFER to see if it's a symlink, junction, or mount point.

Hardlinks are different: they are not reparse points.
You can detect them by checking nNumberOfLinks from GetFileInformationByHandle.
If >1, the file has hardlinks. To enumerate all paths, use FindFirstFileNameW / FindNextFileNameW.

In Go this means using golang.org/x/sys/windows and wrapping those Win32 APIs.
That way gdu can report all link types correctly on Windows"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions