1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:38: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:
Liav A 2022-11-26 14:42:35 +02:00 committed by Andrew Kaster
parent 7dcf8f971b
commit 0bb7c8f4c4
10 changed files with 203 additions and 1 deletions

View file

@ -9,6 +9,7 @@
#include <AK/ByteBuffer.h>
#include <AK/JsonObjectSerializer.h>
#include <AK/Singleton.h>
#include <Kernel/Coredump.h>
#include <Kernel/FileSystem/Custody.h>
#include <Kernel/FileSystem/OpenFileDescription.h>
@ -22,8 +23,15 @@
#define INCLUDE_USERSPACE_HEAP_MEMORY_IN_COREDUMPS 0
static Singleton<SpinlockProtected<OwnPtr<KString>>> s_coredump_directory_path;
namespace Kernel {
SpinlockProtected<OwnPtr<KString>>& Coredump::directory_path()
{
return s_coredump_directory_path;
}
bool Coredump::FlatRegionData::looks_like_userspace_heap_region() const
{
return name().starts_with("LibJS:"sv) || name().starts_with("malloc:"sv);