feat: support and validate folder mount points in CLI mount commands - #162
Merged
Merged
Conversation
RamDisk/MountManager already handled directory-path mount points correctly (IsDriveLetter guards all the drive-letter-only logic), but nothing surfaced or validated that path outside of a raw WinFsp NTSTATUS failure. Extracts IsDriveLetter into a public MountPointValidator, adds a pre-mount directory existence/emptiness check on the CLI mount/mount-archive paths, and updates CLI help text accordingly. The WPF CreateDiskDialog still only offers drive letters; adding a directory picker there is left for a future batch.
Mounting a disk into a directory that lives inside another already-mounted RAM disk creates a fragile lifecycle dependency: the inner mount's backing directory vanishes the instant the outer disk is unmounted. Extends MountPointValidator.TryValidateDirectoryMountPoint to reject that case.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DiskOptions.MountPoint's doc comment claims support for "an empty NTFS directory path" as an alternative to a drive letter, andRamDisk/MountManagergenuinely handle that correctly today (drive-letter-only logic like cross-session symlink publishing,WaitForDriveVisible, and shell-drive-added notifications are all properly guarded by a privateIsDriveLettercheck) — but this was never surfaced or validated outside of Core, and a bad directory mount point would only surface as an opaque WinFsp NTSTATUS failure.RamDisk's privateIsDriveLetterinto a new publicManagedDrive.Core.Mounting.MountPointValidator, addingTryValidateDirectoryMountPointwhich gives a clear "directory does not exist" / "directory is not empty" error before ever attempting the mount.MainViewModel.MountImageAsync/MountArchiveAsync), and updatesmount/mount-archiveCLI help text andICliDiskControllerdocs to mention directory mount points explicitly.CreateDiskDialogstill only offers a drive-letter dropdown — adding a directory picker there is a separate, larger UI/UX change left for a future batch.Test plan
dotnet build -c Release— 0 warnings, 0 errorsdotnet test tests/ManagedDrive.Tests -c Release— 363/363 passed, including newMountPointValidatorTests.csdotnet format --verify-no-changes --no-restore— cleanmdrive mount <image.mdr> C:\Temp\SomeEmptyDirmounts successfully; mounting onto a non-existent or non-empty directory returns a clear error instead of a raw NTSTATUS failure