| 1 | # Plan 9 |
| 2 | |
| 3 | Plan9 is a Linux process that hosts a plan9 filesystem server for WSL1 and WSL2 distributions. It's created by [init](init.md) in each distribution. |
| 4 | |
| 5 | ## WSL 1 |
| 6 | |
| 7 | In WSL1 distributions, `plan9` serves its filesystem through a unix socket, which can then be connected to from Windows. |
| 8 | |
| 9 | ## WSL2 |
| 10 | |
| 11 | In WSL2 distributions, `plan9` runs its filesystem through an `hvsocket` |
| 12 | |
| 13 | ## Accessing the distribution files from Windows |
| 14 | |
| 15 | From Windows, a special redirector driver (p9rdr.sys) registers both `\\wsl$` and `\\wsl.localhost`. When either of those paths are accessed, `p9rdr.sys` calls [wslservice.exe](wslservice.exe.md) to list the available distributions for a given Windows user. |
| 16 | |
| 17 | When a distribution path is accessed (like `\\wsl.localhost\debian`), `p9rdr.sys` calls into [wslservice.exe](wslservice.exe.md) via COM to start the distribution, and connect to its plan9 server, which allows the files to be accessed from Windows. |
| 18 | |
| 19 | See `src/linux/init/plan9.cpp` |