mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 18:15:07 +00:00

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.
27 lines
641 B
C++
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);
|
|
}
|