1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 11:45:11 +00:00

Kernel: Fix ProcFS for non-process backed sub dirs

While hacking on `sysctl` an issue in ProcFS was making me unable to
read/write from `/proc/sys/XXX`. Some directories in the ProcFS are not
actually backed by a process and need to return `nullptr` so callbacks
get properly set. We now do an explicit check for the parent to ensure
it's one that is PID-based.
This commit is contained in:
Spencer Dixon 2021-05-02 12:56:59 -04:00 committed by Andreas Kling
parent 028dad6e87
commit 27bfb01f25

View file

@ -1045,7 +1045,11 @@ ProcFSInode::~ProcFSInode()
RefPtr<Process> ProcFSInode::process() const
{
return Process::from_pid(to_pid(identifier()));
auto parent = to_proc_parent_directory(identifier());
if (parent == PDI_PID || parent == PDI_PID_fd || parent == PDI_PID_stacks)
return Process::from_pid(to_pid(identifier()));
return nullptr;
}
KResult ProcFSInode::refresh_data(FileDescription& description) const