mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:28:12 +00:00
Kernel+SystemServer: Don't hardcode coredump directory path
Instead, allow userspace to decide on the coredump directory path. By default, SystemServer sets it to the /tmp/coredump directory, but users can now change this by writing a new path to the sysfs node at /sys/kernel/variables/coredump_directory, and also to read this node to check where coredumps are currently generated at.
This commit is contained in:
parent
7dcf8f971b
commit
0bb7c8f4c4
10 changed files with 203 additions and 1 deletions
|
@ -469,6 +469,19 @@ static ErrorOr<void> create_tmp_coredump_directory()
|
|||
return {};
|
||||
}
|
||||
|
||||
static ErrorOr<void> set_default_coredump_directory()
|
||||
{
|
||||
dbgln("Setting /tmp/coredump as the coredump directory");
|
||||
auto sysfs_coredump_directory_variable_fd = TRY(Core::System::open("/sys/kernel/variables/coredump_directory"sv, O_RDWR));
|
||||
ScopeGuard close_on_exit([&] {
|
||||
close(sysfs_coredump_directory_variable_fd);
|
||||
});
|
||||
auto tmp_coredump_directory_path = "/tmp/coredump"sv;
|
||||
auto nwritten = TRY(Core::System::write(sysfs_coredump_directory_variable_fd, tmp_coredump_directory_path.bytes()));
|
||||
VERIFY(static_cast<size_t>(nwritten) == tmp_coredump_directory_path.length());
|
||||
return {};
|
||||
}
|
||||
|
||||
static ErrorOr<void> create_tmp_semaphore_directory()
|
||||
{
|
||||
dbgln("Creating /tmp/semaphore directory");
|
||||
|
@ -494,6 +507,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
if (!user) {
|
||||
TRY(create_tmp_coredump_directory());
|
||||
TRY(set_default_coredump_directory());
|
||||
TRY(create_tmp_semaphore_directory());
|
||||
TRY(determine_system_mode());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue