Skip to content

fix: resolve Windows verbatim paths (\\\\?\\ and \\\\?\\UNC\\) - #383

Open
Mathjk wants to merge 1 commit into
muesli:masterfrom
Mathjk:fix/windows-verbatim-paths
Open

Mathjk wants to merge 1 commit into
muesli:masterfrom
Mathjk:fix/windows-verbatim-paths

Conversation

@Mathjk

@Mathjk Mathjk commented Sep 29, 2026

Copy link
Copy Markdown

Fixes #382.

Bug

On Windows, duf silently prints an empty table (exit 0) for verbatim path arguments:

  • duf "\\?\D:\some\path" → empty output — filepath.Abs/filepath.EvalSymlinks preserve the \\?\ prefix, so the path never prefix-matches any canonically-reported mount point (D:\).
  • duf "\\?\UNC\host\share" → misleading truncated error CreateFile \\?\UNC\host: The specified path is invalid — EvalSymlinks itself fails mid-walk.

Fix

New stripVerbatimPrefix() in filesystems.go (guarded by runtime.GOOS == "windows"): \\?\X:\… → X:\… (drive-letter only) and \\?\UNC\host\share → \\host\share. Applied before filepath.Abs (so EvalSymlinks never sees the crashing UNC-verbatim form) and again after it (covers symlinks resolving to verbatim targets). \\?\Volume{GUID} and other non-drive/UNC forms pass through untouched.

Verified on real Windows

Arg Before After
\\?\D:\wisp-port empty, exit 0 D:\ table, identical to D:\wisp-port
\\?\UNC\localhost\D$\… truncated-path error real output, same as plain \\localhost\D$\…
\\?\UNC\nonexist\share truncated error \\nonexist\share: network path not found (real path)
\\?\Volume{guid}\, relative, multi-arg, no-arg — unchanged

go build / go vet / go test ./... green; GOOS=windows build green.

duf silently printed an empty table for verbatim path arguments like
"\\?\D:\path": filepath.Abs and filepath.EvalSymlinks preserve the
verbatim prefix, so the path never matched a non-verbatim mount point.
For "\\?\UNC\host\share", EvalSymlinks additionally failed with a
truncated "CreateFile \\?\UNC\host: The specified path is invalid".

Strip the verbatim prefix from drive-letter (\\?\X:\ -> X:\) and UNC
(\\?\UNC\ -> \\) arguments before resolving them, so verbatim paths
behave exactly like their canonical equivalents.
@muesli

muesli commented Nov 6, 2026

Copy link
Copy Markdown
Owner

Yikes. Things like this make me want to drop Windows support altogether. We should at least try to move the code to a place that only gets compiled & included on Windows.

@muesli muesli added the bug Something isn't working label Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: verbatim paths (\\?\...) silently return empty output

2 participants