mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:17:34 +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:
parent
69efded562
commit
67d0f5686d
1 changed files with 10 additions and 2 deletions
|
@ -64,20 +64,28 @@ static void sigchld_handler(int)
|
||||||
|
|
||||||
static ErrorOr<void> determine_system_mode()
|
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");
|
auto f = Core::File::construct("/proc/system_mode");
|
||||||
if (!f->open(Core::OpenMode::ReadOnly)) {
|
if (!f->open(Core::OpenMode::ReadOnly)) {
|
||||||
dbgln("Failed to read system_mode: {}", f->error_string());
|
dbgln("Failed to read system_mode: {}", f->error_string());
|
||||||
// Continue to assume "graphical".
|
// Continue and assume "text" mode.
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
const String system_mode = String::copy(f->read_all(), Chomp);
|
const String system_mode = String::copy(f->read_all(), Chomp);
|
||||||
if (f->error()) {
|
if (f->error()) {
|
||||||
dbgln("Failed to read system_mode: {}", f->error_string());
|
dbgln("Failed to read system_mode: {}", f->error_string());
|
||||||
// Continue to assume "graphical".
|
// Continue and assume "text" mode.
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
g_system_mode = system_mode;
|
g_system_mode = system_mode;
|
||||||
|
declare_text_mode_on_failure.disarm();
|
||||||
|
|
||||||
dbgln("Read system_mode: {}", g_system_mode);
|
dbgln("Read system_mode: {}", g_system_mode);
|
||||||
|
|
||||||
struct stat file_state;
|
struct stat file_state;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue