Skip to content

windows.GetFinalPathNameByHandle: Support volumes mounted as paths#19738

Merged
andrewrk merged 1 commit intoziglang:masterfrom
squeek502:mountmgr-volume-path
Apr 24, 2024
Merged

windows.GetFinalPathNameByHandle: Support volumes mounted as paths#19738
andrewrk merged 1 commit intoziglang:masterfrom
squeek502:mountmgr-volume-path

Conversation

@squeek502
Copy link
Member

@squeek502 squeek502 commented Apr 22, 2024

A volume can be mounted as a NTFS path, e.g. as C:\Mnt\Foo. In that case, IOCTL_MOUNTMGR_QUERY_POINTS gives us a mount point with a symlink value something like \??\Volume{383da0b0-717f-41b6-8c36-00500992b58d}. In order to get the C:\Mnt\Foo path, we can query the mountmgr again using IOCTL_MOUNTMGR_QUERY_DOS_VOLUME_PATH.

Fixes #19731


Zig installed to a VHD mounted as a path:

Before:

> zig test test.zig
error: unable to find zig self exe path: FileNotFound

After:

> zig test test.zig
All 1 tests passed.

Note: It's also possible for a volume to be mounted to multiple paths. This PR will currently always just return the first one--unsure how something like GetVolumePathNameW compares, need to test that.

A volume can be mounted as a NTFS path, e.g. as C:\Mnt\Foo. In that case, IOCTL_MOUNTMGR_QUERY_POINTS gives us a mount point with a symlink value something like `\??\Volume{383da0b0-717f-41b6-8c36-00500992b58d}`. In order to get the `C:\Mnt\Foo` path, we can query the mountmgr again using IOCTL_MOUNTMGR_QUERY_DOS_VOLUME_PATH.

Fixes ziglang#19731
@squeek502 squeek502 force-pushed the mountmgr-volume-path branch from a94ce7f to 94145bb Compare April 23, 2024 04:33
@andrewrk andrewrk merged commit a0f1825 into ziglang:master Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

On a mounted VHD without a drive letter: error: unable to find zig self exe path: FileNotFound

2 participants