1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:48:10 +00:00

Automatically call Inode::flush_metadata() before an Inode is destroyed.

Use a little template magic to have Retainable::release() call out to
T::will_be_destroyed() if such a function exists before actually calling
the destructor. This gives us full access to virtual functions in the
pre-destruction code.
This commit is contained in:
Andreas Kling 2018-12-19 22:28:09 +01:00
parent 1f44cd9dd9
commit d0f06e5f3f
6 changed files with 41 additions and 17 deletions

View file

@ -87,7 +87,7 @@ public:
virtual InodeIdentifier lookup(const String& name) = 0;
virtual String reverse_lookup(InodeIdentifier) = 0;
bool is_dirty() const { return m_dirty; }
bool is_metadata_dirty() const { return m_metadata_dirty; }
int set_atime(Unix::time_t);
int set_ctime(Unix::time_t);
@ -95,6 +95,8 @@ public:
virtual void flush_metadata() = 0;
void will_be_destroyed();
protected:
Inode(FS& fs, unsigned index)
: m_fs(fs)
@ -103,13 +105,13 @@ protected:
}
virtual void populate_metadata() const = 0;
void set_dirty(bool b) { m_dirty = b; }
void set_metadata_dirty(bool b) { m_metadata_dirty = b; }
mutable InodeMetadata m_metadata;
private:
FS& m_fs;
unsigned m_index { 0 };
bool m_dirty { false };
bool m_metadata_dirty { false };
};
inline FS* InodeIdentifier::fs()