Skip to main content

Module probe

Module probe 

Source
Expand description

Selecting a distribution and asking it the five questions that decide whether the product may manage it.

§One invocation shape, and only one

Every Linux command this adapter runs is

wsl.exe --distribution <NAME> --user <USER> --exec <PROGRAM> [ARG ...]

as an argument vectorLinuxCommand::wsl_arguments builds it, and it is the only thing that does. --exec is what makes that true end to end: Microsoft documents it as “execute the specified command without using the default Linux shell”, so the arguments reach execvp as they were written and no ;, &&, $(…) or quote in a distribution name, a path or a version string is ever interpreted by anything (https://learn.microsoft.com/en-us/windows/wsl/basic-commands).

The Windows half is the same story: super::exec::CommandRequest holds a Vec<OsString> and std::process::Command quotes each element for CommandLineToArgvW. There is no point in the chain at which a string is split back into arguments.

§The five preflight questions

02-target-architecture.md step 1 is “validate that NAME is installed as WSL2, starts as root, and runs systemd”, and 03-security-and-lifecycle.md adds the architecture row to the failure table. probe_readiness asks them in the order in which a failing answer is most useful:

  1. Installed, exactly. wsl --list --verbose, matched case-sensitively.
  2. WSL2. A WSL1 distribution has no systemd and no separate kernel; refusing here is Compatibility’s “explicit preflight failure”.
  3. Root. id -u must answer 0. The provider installs a system service and writes /usr/local/bin; discovering that it cannot halfway through is the failure mode this question removes.
  4. A supported Linux architecture. uname -m, mapped to the architectures the release actually publishes.
  5. systemd. systemctl is-system-running. WSL runs systemd only when the distribution opts in and the WSL build is 0.67.6 or newer (https://learn.microsoft.com/en-us/windows/wsl/systemd), and the Linux daemon is a system unit.

No question in this list mutates anything. That is what 03-security-and-lifecycle.md’s “WSL/systemd preflight — no mutation and no device login” means in code: a failure here happens before a credential has been issued, before a byte has been written into the distribution, and before a Windows task exists.

Structs§

DistributionReadiness
Everything the preflight established about one distribution.
LinuxCommand
A program to run inside a named distribution, as a literal argument vector.
WslExecutable
wsl.exe, as found on this host or as a test says it is.
WslInvoker
Runs wsl.exe, through whatever CommandRunner it was given.

Enums§

SystemdState
What systemctl is-system-running said.

Constants§

LINUX_USER
The Linux account every managed command runs as.

Functions§

architecture_from_uname
Maps uname -m onto the architectures the release publishes.
probe_readiness
Asks the five preflight questions. Mutates nothing.