#382·duf

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

Author: MathjkCreated Sep 29, 2026Updated Sep 29, 2026

On Windows, duf silently prints an empty table (exit code 0) when given a verbatim path (\\?\...) as an argument, instead of showing the usage table for that path's mount point.

Repro

duf.exe D:\wisp-port              -> correct 1-device table
duf.exe "\\?\D:\wisp-port"        -> no output at all, exit 0   (expected: same table)
duf.exe "\\?\D:\"                 -> no output at all, exit 0
duf.exe "\\?\UNC\localhost\D$\wisp-port"
    -> CreateFile \\?\UNC\localhost: The specified path is invalid.   (exit 1)

Root cause

In filesystems.go, findMounts canonicalizes the argument with filepath.Abs + filepath.EvalSymlinks and then matches it against the mount table with strings.HasPrefix(path, v.Mountpoint).

On Windows both filepath.Abs and filepath.EvalSymlinks preserve the \\?\ verbatim prefix, while mount points are enumerated in their canonical, non-verbatim form (D:\). So HasPrefix("\\?\D:\wisp-port", "D:\") is false for every mount, findMounts returns an empty list and a nil error, and duf renders nothing with exit code 0 — a silent wrong result, which is especially confusing for scripts that check the exit status.

For the \\?\UNC\host\share form it fails even earlier: filepath.EvalSymlinks returns CreateFile \\?\UNC\localhost: The specified path is invalid — the error names a truncated path rather than the argument that was passed.

Fix

Strip the verbatim prefix before resolving the argument:

  • \\?\X:\foo -> X:\foo
  • \\?\UNC\host\share -> \\host\share

Other verbatim forms (\\?\Volume{GUID}\) are left untouched. With this, verbatim arguments behave identically to their canonical equivalents, and non-Windows platforms are unaffected.

Verified on Windows: duf "\\?\D:\wisp-port" now prints the same table as duf D:\wisp-port, and duf "\\?\UNC\localhost\D$\wisp-port" now resolves (and behaves) exactly like duf "\\localhost\D$\wisp-port" instead of producing the truncated EvalSymlinks error.