Skip to content

feat: support and validate folder mount points in CLI mount commands - #162

Merged
coldhighsun merged 2 commits into
mainfrom
feature/folder-mountpoint-cli
Sep 16, 2026
Merged

coldhighsun merged 2 commits into
mainfrom
feature/folder-mountpoint-cli

Conversation

@coldhighsun

Copy link
Copy Markdown
Owner

Summary

  • DiskOptions.MountPoint's doc comment claims support for "an empty NTFS directory path" as an alternative to a drive letter, and RamDisk/MountManager genuinely 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 private IsDriveLetter check) — 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.
  • Extracts RamDisk's private IsDriveLetter into a new public ManagedDrive.Core.Mounting.MountPointValidator, adding TryValidateDirectoryMountPoint which gives a clear "directory does not exist" / "directory is not empty" error before ever attempting the mount.
  • Wires that validation into the CLI's non-interactive mount paths (MainViewModel.MountImageAsync/MountArchiveAsync), and updates mount/mount-archive CLI help text and ICliDiskController docs to mention directory mount points explicitly.
  • The WPF CreateDiskDialog still 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 errors
  • dotnet test tests/ManagedDrive.Tests -c Release — 363/363 passed, including new MountPointValidatorTests.cs
  • dotnet format --verify-no-changes --no-restore — clean
  • Manual smoke test on a real machine (needs the WinFsp driver + admin, not available in this dev environment): mdrive mount <image.mdr> C:\Temp\SomeEmptyDir mounts successfully; mounting onto a non-existent or non-empty directory returns a clear error instead of a raw NTSTATUS failure

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.
@coldhighsun
coldhighsun merged commit 8f5b830 into main Sep 16, 2026
3 checks passed
@coldhighsun
coldhighsun deleted the feature/folder-mountpoint-cli branch September 16, 2026 09:28
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.

1 participant