Conversation
|
Tagging subscribers to this area: @dotnet/area-system-io |
|
|
||
| // this method works only for `fullPath` returned by Path.GetFullPath | ||
| // currently we don't have interest in supporting relative paths | ||
| internal static void DosToNtPath(ReadOnlySpan<char> fullPath, ref ValueStringBuilder vsb) |
There was a problem hiding this comment.
I assume for the opposite, translate NT to DOS, a helper like this should be needed, right?
For context #54253 (comment) , a Symlinks API uses DeviceIoControl which returns an NT path that I need to translate to DOS.
This is my silly attempt on doing it:
https://github.com/dotnet/runtime/blob/908530a70613af1172138e48d041d6c5d710d866/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Windows.cs#L513-L518
Also, I think I mixed the names (DOS and NT) in the comments.
There was a problem hiding this comment.
@jozkee You could use RtlNtPathNameToDosPathName, but the problem is that it's internal and not documented, so we should not be using that.
The mapping that you have pointed to seems to be missing a few translations:
\??\UNC\to\\(files located on a remote machine)\??\to\\.\for devices like names pipes:\\.\pipe\$pipeName
But the question is: are they valid in this context? Can someone create a link to a named pipe or a file located on a network share?
FWIW the best doc about the paths I've found so far: https://googleprojectzero.blogspot.com/2016/02/the-definitive-guide-on-win32-to-nt.html
There was a problem hiding this comment.
Symbolic links to files on network shares are possible; fsutil behavior set symlinkevaluation can enable or disable them. I don't know about symbolic links to named pipes.
There was a problem hiding this comment.
The mapping that you have pointed to seems to be missing a few translations:
The first example you pointed should still work, as far as I know: Converting \??\UNC\ to \\?\UNC, should be equivalent. The difference is that you do not want to pass a path prefixed with \??\ to the user, and should always translate it to \\?\.
Regarding the second example: Have you seen cases where Windows gives you a path prefixed with \??\ but you were expecting it to start with \\.\? And how would you know this?
…ping DOS to NT paths
| { | ||
| uint ntStatus; | ||
| IntPtr fileHandle; | ||
| Interop.Kernel32.SECURITY_ATTRIBUTES secAttrs = default; |
There was a problem hiding this comment.
default isn't really needed, right?
| // probably be consistent w/ every other directory. | ||
| int errorCode = Marshal.GetLastPInvokeError(); | ||
|
|
||
| if (errorCode == Interop.Errors.ERROR_PATH_NOT_FOUND && fullPath!.Length == PathInternal.GetRootLength(fullPath)) |
There was a problem hiding this comment.
| if (errorCode == Interop.Errors.ERROR_PATH_NOT_FOUND && fullPath!.Length == PathInternal.GetRootLength(fullPath)) | |
| if (errorCode == Interop.Errors.ERROR_PATH_NOT_FOUND && fullPath.Length == PathInternal.GetRootLength(fullPath)) |
commented
Jun 23, 2021
|
/backport to release/6.0-preview6 |
commented
Jun 23, 2021
|
Started backporting to release/6.0-preview6: https://github.com/dotnet/runtime/actions/runs/963422709 |
Fixes #54474
Fixes #54475
Fixes #54337