master
h 102 lines 3.23 KB
Raw
1 /*++
2
3 Copyright (c) Microsoft. All rights reserved.
4
5 Module Name:
6
7 WslDistributionConfig.h
8
9 Abstract:
10
11 This file contains the WslDistributionConfig class definition.
12
13 --*/
14
15 #pragma once
16 #include <optional>
17 #include "p9tracelogging.h"
18 #include "lxinitshared.h"
19 #include "common.h"
20 #include "SocketChannel.h"
21
22 namespace wsl::linux {
23
24 constexpr auto c_ConfigAutoMountOption = "automount.enabled";
25 constexpr auto c_ConfigAutoUpdateTimezoneOption = "time.useWindowsTimezone";
26 constexpr auto c_ConfigBootCommandOption = "boot.command";
27 constexpr auto c_ConfigBootProtectBinfmtOption = "boot.protectBinfmt";
28 constexpr auto c_ConfigBootSystemdOption = "boot.systemd";
29 constexpr auto c_ConfigInteropAppendWindowsPathOption = "interop.appendWindowsPath";
30 constexpr auto c_ConfigInteropEnabledOption = "interop.enabled";
31 constexpr auto c_ConfigMountFsTabOption = "automount.mountFsTab";
32 constexpr auto c_ConfigGenerateHostsOption = "network.generateHosts";
33 constexpr auto c_ConfigGenerateResolvConfOption = "network.generateResolvConf";
34 constexpr auto c_ConfigEnableGuiAppsOption = "general.guiApplications";
35 constexpr auto c_ConfigPlan9EnabledOption = "fileServer.enabled";
36 constexpr auto c_ConfigAppendGpuLibPathOption = "gpu.appendLibPath";
37 constexpr auto c_ConfigGpuEnabledOption = "gpu.enabled";
38 constexpr auto c_ConfigLinkOsLibsOption = "automount.ldconfig";
39 constexpr auto c_ConfigAutoMountRoot = "automount.root";
40
41 struct WslDistributionConfig
42 {
43 WslDistributionConfig(const char* configFilePath);
44
45 WslDistributionConfig(const WslDistributionConfig&) = delete;
46 WslDistributionConfig& operator=(const WslDistributionConfig&) = delete;
47
48 WslDistributionConfig(WslDistributionConfig&&) = default;
49 WslDistributionConfig& operator=(WslDistributionConfig&&) = default;
50
51 enum class CGroupVersion
52 {
53 v1 = 0,
54 v2 = 1
55 };
56
57 bool AutoMount = true;
58 bool AutoUpdateTimezone = true;
59 std::optional<std::string> BootCommand;
60 bool BootInit = false;
61 int BootInitTimeout = 10 * 1000;
62 bool BootProtectBinfmt = true;
63 std::optional<std::string> DefaultUser;
64 std::string DrvFsPrefix = "/mnt";
65 std::optional<std::string> DrvFsOptions;
66 bool InteropAppendWindowsPath = true;
67 bool InteropEnabled = true;
68 bool MountFsTab = true;
69 bool GenerateHosts = true;
70 bool GenerateResolvConf = true;
71 std::optional<std::string> HostName;
72 bool Plan9Enabled = true;
73 std::optional<std::string> Plan9LogFile;
74 int Plan9LogLevel = TRACE_LEVEL_INFORMATION;
75 bool Plan9LogTruncate = true;
76 int Umask = 0022;
77 bool AppendGpuLibPath = true;
78 bool GpuEnabled = true;
79 bool LinkOsLibs = true;
80 CGroupVersion CGroup = CGroupVersion::v2;
81
82 //
83 // Values not set by /etc/wsl.conf.
84 //
85
86 bool GuiAppsEnabled = false;
87 std::optional<int> FeatureFlags;
88 std::optional<LX_MINI_INIT_NETWORKING_MODE> NetworkingMode;
89 std::optional<std::string> VmId;
90
91 //
92 // Global state for boot state. The socket is used to delay-start the distro init process
93 // to when the first session leader is created.
94 //
95
96 wil::unique_fd BootStartWriteSocket;
97 wsl::shared::SocketChannel Plan9ControlChannel;
98 std::optional<pid_t> InitPid;
99 std::optional<std::string> CgroupPath;
100 };
101
102 } // namespace wsl::linux