2019-05-30 17:46:08 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
2019-05-31 15:22:52 +02:00
|
|
|
#include <AK/Badge.h>
|
2019-08-08 11:08:27 +02:00
|
|
|
#include <AK/InlineLinkedList.h>
|
2019-06-21 18:58:45 +02:00
|
|
|
#include <AK/RefCounted.h>
|
2019-08-08 11:08:27 +02:00
|
|
|
#include <AK/RefPtr.h>
|
2020-01-11 18:25:26 +03:00
|
|
|
#include <AK/String.h>
|
2019-05-30 17:46:08 +02:00
|
|
|
|
|
|
|
|
class Inode;
|
2019-05-31 15:22:52 +02:00
|
|
|
class VFS;
|
|
|
|
|
|
|
|
|
|
// FIXME: Custody needs some locking.
|
2019-05-30 17:46:08 +02:00
|
|
|
|
2019-08-08 11:08:27 +02:00
|
|
|
class Custody : public RefCounted<Custody>
|
|
|
|
|
, public InlineLinkedListNode<Custody> {
|
2019-05-30 17:46:08 +02:00
|
|
|
public:
|
2019-08-24 22:01:17 +02:00
|
|
|
static Custody* get_if_cached(Custody* parent, const StringView& name);
|
2020-01-11 18:25:26 +03:00
|
|
|
static NonnullRefPtr<Custody> get_or_create(Custody* parent, const StringView& name, Inode&, int mount_flags);
|
|
|
|
|
static NonnullRefPtr<Custody> create(Custody* parent, const StringView& name, Inode& inode, int mount_flags)
|
2019-05-30 17:46:08 +02:00
|
|
|
{
|
2020-01-11 18:25:26 +03:00
|
|
|
return adopt(*new Custody(parent, name, inode, mount_flags));
|
2019-05-30 17:46:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~Custody();
|
|
|
|
|
|
|
|
|
|
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; }
|
2019-05-30 18:58:59 +02:00
|
|
|
String absolute_path() const;
|
|
|
|
|
|
2019-05-31 15:22:52 +02:00
|
|
|
bool is_deleted() const { return m_deleted; }
|
|
|
|
|
bool is_mounted_on() const { return m_mounted_on; }
|
|
|
|
|
|
2020-01-11 18:25:26 +03:00
|
|
|
int mount_flags() const { return m_mount_flags; }
|
|
|
|
|
|
2019-05-31 15:22:52 +02:00
|
|
|
void did_delete(Badge<VFS>);
|
|
|
|
|
void did_mount_on(Badge<VFS>);
|
|
|
|
|
void did_rename(Badge<VFS>, const String& name);
|
|
|
|
|
|
2019-08-08 11:08:27 +02:00
|
|
|
// For InlineLinkedListNode.
|
|
|
|
|
Custody* m_next { nullptr };
|
|
|
|
|
Custody* m_prev { nullptr };
|
|
|
|
|
|
2019-05-30 17:46:08 +02:00
|
|
|
private:
|
2020-01-11 18:25:26 +03:00
|
|
|
Custody(Custody* parent, const StringView& name, Inode&, int mount_flags);
|
2019-05-30 17:46:08 +02:00
|
|
|
|
2019-06-21 18:37:47 +02:00
|
|
|
RefPtr<Custody> m_parent;
|
2019-05-30 17:46:08 +02:00
|
|
|
String m_name;
|
2019-06-21 18:37:47 +02:00
|
|
|
NonnullRefPtr<Inode> m_inode;
|
2019-05-31 15:22:52 +02:00
|
|
|
bool m_deleted { false };
|
|
|
|
|
bool m_mounted_on { false };
|
2020-01-11 18:25:26 +03:00
|
|
|
int m_mount_flags { 0 };
|
2019-05-30 17:46:08 +02:00
|
|
|
};
|