mirror of
https://github.com/RGBCube/serenity
synced 2025-05-22 17:25:07 +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
|
@ -696,7 +696,16 @@ ErrorOr<void> Process::dump_core()
|
|||
VERIFY(is_dumpable());
|
||||
VERIFY(should_generate_coredump());
|
||||
dbgln("Generating coredump for pid: {}", pid().value());
|
||||
auto coredump_path = TRY(KString::formatted("/tmp/coredump/{}_{}_{}", name(), pid().value(), kgettimeofday().to_truncated_seconds()));
|
||||
auto coredump_directory_path = TRY(Coredump::directory_path().with([&](auto& coredump_directory_path) -> ErrorOr<NonnullOwnPtr<KString>> {
|
||||
if (coredump_directory_path)
|
||||
return KString::try_create(coredump_directory_path->view());
|
||||
return KString::try_create(""sv);
|
||||
}));
|
||||
if (coredump_directory_path->view() == ""sv) {
|
||||
dbgln("Generating coredump for pid {} failed because coredump directory was not set.", pid().value());
|
||||
return {};
|
||||
}
|
||||
auto coredump_path = TRY(KString::formatted("{}/{}_{}_{}", coredump_directory_path->view(), name(), pid().value(), kgettimeofday().to_truncated_seconds()));
|
||||
auto coredump = TRY(Coredump::try_create(*this, coredump_path->view()));
|
||||
return coredump->write();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue