diff options
author | Liav A <liavalb@gmail.com> | 2022-10-14 14:43:40 +0300 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-10-16 17:43:20 +0200 |
commit | 67d0f5686dc743cf6bbf11b4c61e566b5c3da3c3 (patch) | |
tree | 55d3a00c1f9c159dc583998ee65ed757d38e0237 /Userland/Services/SystemServer | |
parent | 69efded56284c52edadaf88fe16238b0510b453f (diff) | |
download | serenity-67d0f5686dc743cf6bbf11b4c61e566b5c3da3c3.zip |
SystemServer: Make system-mode=text the default in case of read failure
In case of failure when trying to read the system_mode global node, just
use as a default the text mode, so we have bootable system with degraded
functionality.
Diffstat (limited to 'Userland/Services/SystemServer')
-rw-r--r-- | Userland/Services/SystemServer/main.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Userland/Services/SystemServer/main.cpp b/Userland/Services/SystemServer/main.cpp index dc191258a8..67b6b9e32c 100644 --- a/Userland/Services/SystemServer/main.cpp +++ b/Userland/Services/SystemServer/main.cpp @@ -64,20 +64,28 @@ static void sigchld_handler(int) static ErrorOr<void> determine_system_mode() { + ArmedScopeGuard declare_text_mode_on_failure([&] { + // Note: Only if the mode is not set to self-test, degrade it to text mode. + if (g_system_mode != "self-test") + g_system_mode = "text"; + }); + auto f = Core::File::construct("/proc/system_mode"); if (!f->open(Core::OpenMode::ReadOnly)) { dbgln("Failed to read system_mode: {}", f->error_string()); - // Continue to assume "graphical". + // Continue and assume "text" mode. return {}; } const String system_mode = String::copy(f->read_all(), Chomp); if (f->error()) { dbgln("Failed to read system_mode: {}", f->error_string()); - // Continue to assume "graphical". + // Continue and assume "text" mode. return {}; } g_system_mode = system_mode; + declare_text_mode_on_failure.disarm(); + dbgln("Read system_mode: {}", g_system_mode); struct stat file_state; |