mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:08:11 +00:00
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.
This commit is contained in:
parent
3a1d5fa112
commit
4cb87b1753
5 changed files with 141 additions and 0 deletions
27
Kernel/FileSystem/Custody.cpp
Normal file
27
Kernel/FileSystem/Custody.cpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
#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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue