1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:07:44 +00:00

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.
This commit is contained in:
Liav A 2022-10-14 14:43:40 +03:00 committed by Linus Groh
parent 69efded562
commit 67d0f5686d

View file

@ -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;