summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem/Custody.h
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-05-31 15:22:52 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-05-31 15:22:52 +0200
commit8adadf8a462e87a588ca5d987c72ac2b635b36c4 (patch)
tree010eac1dd46a925edb01bce7197b392575bebd8d /Kernel/FileSystem/Custody.h
parent3fbddcecd2e438eefdd894f6c7574961531e49d6 (diff)
downloadserenity-8adadf8a462e87a588ca5d987c72ac2b635b36c4.zip
FileSystem: Reuse existing custodies when possible, and keep them updated.
Walk the custody cache and try to reuse an existing one when possible. The VFS is responsible for updating them when something happens that would cause the described relationship to change. This is definitely not perfect but it does work for the basic scenarios like renaming and removing directory entries.
Diffstat (limited to 'Kernel/FileSystem/Custody.h')
-rw-r--r--Kernel/FileSystem/Custody.h18
1 files changed, 15 insertions, 3 deletions
diff --git a/Kernel/FileSystem/Custody.h b/Kernel/FileSystem/Custody.h
index a468e4cf98..9de3d93dd8 100644
--- a/Kernel/FileSystem/Custody.h
+++ b/Kernel/FileSystem/Custody.h
@@ -1,13 +1,19 @@
#pragma once
#include <AK/AKString.h>
+#include <AK/Badge.h>
#include <AK/RetainPtr.h>
#include <AK/Retainable.h>
class Inode;
+class VFS;
+
+// FIXME: Custody needs some locking.
class Custody : public Retainable<Custody> {
public:
+ static Custody* get_if_cached(Custody* parent, const String& name);
+ static Retained<Custody> get_or_create(Custody* parent, const String& name, Inode&);
static Retained<Custody> create(Custody* parent, const String& name, Inode& inode)
{
return adopt(*new Custody(parent, name, inode));
@@ -17,18 +23,24 @@ public:
Custody* parent() { return m_parent.ptr(); }
const Custody* parent() const { return m_parent.ptr(); }
-
Inode& inode() { return *m_inode; }
const Inode& inode() const { return *m_inode; }
-
const String& name() const { return m_name; }
-
String absolute_path() const;
+ bool is_deleted() const { return m_deleted; }
+ bool is_mounted_on() const { return m_mounted_on; }
+
+ void did_delete(Badge<VFS>);
+ void did_mount_on(Badge<VFS>);
+ void did_rename(Badge<VFS>, const String& name);
+
private:
Custody(Custody* parent, const String& name, Inode&);
RetainPtr<Custody> m_parent;
String m_name;
Retained<Inode> m_inode;
+ bool m_deleted { false };
+ bool m_mounted_on { false };
};