Eryk Sun <eryk...@gmail.com> added the comment:

> perfectly valid redirected paths (winfsp ram drives for example)

I mounted a WinFsp MEMFS filesystem on a directory, which set a mountpoint that 
targets the root path of a volume device in the native "\Device" object 
directory. It didn't create a volume GUID name, which means the mountpoint 
manager isn't supported in this configuration.

The error code ERROR_UNRECOGNIZED_VOLUME (1005) is meaningless in this case. 
The mountpoint manager queries a volume with IOCTLs such as 
IOCTL_MOUNTDEV_QUERY_DEVICE_NAME, which the WinFsp virtual volume (in the above 
configuration) doesn't support. Weirdly, it returns the error code 
STATUS_UNRECOGNIZED_VOLUME instead of STATUS_INVALID_DEVICE_REQUEST. It does 
this as a lazy workaround for various IOCTLs it receives from filesystem 
drivers while the volume is in the process of being mounted [1][2]. The side 
effect is that it returns STATUS_UNRECOGNIZED_VOLUME for unhandled IOCTLs even 
when it's not getting mounted. This behavior should have been restricted to 
when the volume parameter block (VPB) is unmounted. Otherwise it should return 
the expected error code STATUS_INVALID_DEVICE_REQUEST (i.e. 
ERROR_INVALID_FUNCTION) instead of confusing users with a meaningless error.

WinFsp does support the mountpoint manager, in a restricted fashion. The mount 
target has to be a drive device name in the form "\\.\X:". This gets registered 
with the mountpoint manager as the canonical DOS name of the volume. Since it's 
a global name, administrator access is required. It also creates a GUID volume 
name. Run mountvol.exe without arguments to find the volume name that's 
associated with the drive letter. Then run it again as `mountvol <path> 
<volume_name>`, where <path> is an empty directory on which to mount the 
volume. Note that Python's os.path.realpath() will resolve the volume to the 
canonical drive name, even if the path traverses a directory mountpoint for the 
volume.

A new issue should be created to ignore ERROR_UNRECOGNIZED_VOLUME in 3.10+, for 
which Path.resolve() was updated to call os.path.realpath(). For 3.9, fixing 
Path.resolve() is still possible. There are 3 remaining bug releases planned: 
3.9.9: (2022-01-03), 3.9.10 (2022-02-28), and 3.9.11 (2022-05-02).

---
[1] https://github.com/billziss-gh/winfsp/blob/v1.9/src/sys/devctl.c#L49
[2] https://github.com/billziss-gh/winfsp/issues/177

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue31842>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to