1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 01:37:35 +00:00

Kernel: Plumb OOM propagation through Custody factory

Modify the Custody::create(..) API so it has the ability to propagate
OOM back to the caller.
This commit is contained in:
Brian Gianforcaro 2021-05-10 00:28:23 -07:00 committed by Andreas Kling
parent fb93535419
commit 0b7395848a
3 changed files with 27 additions and 7 deletions

View file

@ -11,6 +11,7 @@
#include <AK/String.h>
#include <Kernel/Forward.h>
#include <Kernel/Heap/SlabAllocator.h>
#include <Kernel/KResult.h>
namespace Kernel {
@ -19,9 +20,13 @@ namespace Kernel {
class Custody : public RefCounted<Custody> {
MAKE_SLAB_ALLOCATED(Custody)
public:
static NonnullRefPtr<Custody> create(Custody* parent, const StringView& name, Inode& inode, int mount_flags)
static KResultOr<NonnullRefPtr<Custody>> create(Custody* parent, const StringView& name, Inode& inode, int mount_flags)
{
return adopt_ref(*new Custody(parent, name, inode, mount_flags));
auto custody = new Custody(parent, name, inode, mount_flags);
if (!custody)
return ENOMEM;
return adopt_ref(*custody);
}
~Custody();