Windows#

The Windows backend communicates with the Windows NVMe driver StorNVMe.sys via IOCTLs. The backend relies on the NVMe pass-through through IOCTLs to submit admin, IO and arbitrary user-defined commands.

Currently Windows backend will work only with the inbox NVMe driver.

Toolchain Support:

Run the below mention batch file to install listed packages:

@echo off
@setlocal enableextensions enabledelayedexpansion

net session >nul: 2>&1
if errorlevel 1 (
	echo %0 must be run with Administrator privileges
	goto :eof
)

:: Use PowerShell to install Chocolatey
set "PATH=%ALLUSERSPROFILE%\chocolatey\bin;%PATH%"
echo [1/6] Install: Chocolatey Manager
powershell -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))"
where /q choco
if errorlevel 1 (
	echo [1/6] Install: Chocolatey = FAIL
	goto :eof
)
echo [1/6] Install: Chocolatey = PASS

:: Use Chocolatey to install msys2
echo [2/6] Install: MSYS2
set "PATH=%SystemDrive%\msys64;%PATH%"
choco install msys2 -y -r --params "/NoUpdate /InstallDir:C:\msys64"
where /q msys2
if errorlevel 1 (
	echo [2/6] Install: MSYS2 = FAIL
	goto :eof
)
echo [2/6] Install: MSYS2 = PASS

echo [3/6] Install: Git
choco install git -y -r
echo [3/6] Install: Git = PASS

echo [4/6] Install: dos2unix
choco install dos2unix
echo [4/6] Install: dos2unix = PASS

:: Use MSYS2/pacman to install gcc and clang toolchain
set MSYS2=call msys2_shell -no-start -here -use-full-path -defterm

echo [5/6] Install: MinGW Toolchain via msys2/pacman
set "PATH=%SystemDrive%\msys64\mingw64\bin;%PATH%"
%MSYS2% -c "pacman --noconfirm -Syy --needed base-devel mingw-w64-x86_64-toolchain"
where /q gcc
if errorlevel 1 (
	echo [5/6] Install: MinGW Toolchain via msys2/pacman = FAIL
	goto :eof
)
echo [5/6] Install: MinGW Toolchain via msys2/pacman = PASS

echo [6/6] Install: MinGW/meson via msys2/pacman
%MSYS2% -c "pacman --noconfirm -Syy mingw-w64-x86_64-meson"
echo [6/6] Install: MinGW/meson via msys2/pacman = OK

xNVMe can be build by using given build.bat,

# build: auto-configure xNVMe, build third-party libraries, and xNVMe itself
build.bat

# config: only configure xNVMe
build.bat config

# config: debug only configure xNVMe
build.bat config-debug

# install xNVMe
build.bat install

# uninstall xNVMe
# build.bat uninstall

Windows support two schemas dev and file. * dev: uses NVMe pass-through IOCTLs * file uses Windows Read/Write file

# Use the IOCTL implementation or fail xnvme info \.PhysicalDrive1

# Use the file implementation or fail xnvme info \.PhysicalDrive1

Note on Errors#

Some commands may be issued through ioctl that are invalid. While most commands will still be issued to the drive and the error relayed back to the user, some violations may be picked up by the kernel cause the ioctl to fail with -1 and GetLastError() set to Invalid Argument.

In this case, the backend will transform such errors into the NVMe equivalent. See the documentation on xnvme_cmd_ctx.