1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 18:15:07 +00:00
serenity/Kernel/FileSystem/Custody.cpp
Andreas Kling 4cb87b1753 FileSystem: Add a Custody class that represents a parent/child guardianship.
A custody is kind of a directory entry abstraction that represents a single
entry in a parent directory that tells us the name of a child inode.

The idea here is for path resolution to produce a chain of custody objects.
2019-05-30 17:46:08 +02:00

27 lines
641 B
C++

#include <AK/HashTable.h>
#include <Kernel/FileSystem/Custody.h>
#include <Kernel/FileSystem/Inode.h>
#include <Kernel/Lock.h>
static Lockable<HashTable<Custody*>>& all_custodies()
{
static Lockable<HashTable<Custody*>>* table;
if (!table)
table = new Lockable<HashTable<Custody*>>;
return *table;
}
Custody::Custody(Custody* parent, const String& name, Inode& inode)
: m_parent(parent)
, m_name(name)
, m_inode(inode)
{
LOCKER(all_custodies().lock());
all_custodies().resource().set(this);
}
Custody::~Custody()
{
LOCKER(all_custodies().lock());
all_custodies().resource().remove(this);
}