mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:27:43 +00:00
Kernel/TmpFS: Remove inode map from TmpFS
The HashMap of InodeIndex->Inode in TmpFS only had one purpose: looking up parent inodes by index. Instead of using a map for this, we can simply give each inode a WeakPtr to its parent inode. This saves us the trouble of dealing with the fallibility of HashMap allocations, and it just generally simpler. :^)
This commit is contained in:
parent
2d9bd24249
commit
cda8f34876
2 changed files with 16 additions and 55 deletions
|
@ -33,11 +33,6 @@ private:
|
|||
|
||||
RefPtr<TmpFSInode> m_root_inode;
|
||||
|
||||
HashMap<InodeIndex, TmpFSInode*> m_inodes;
|
||||
ErrorOr<NonnullRefPtr<Inode>> get_inode(InodeIdentifier identifier) const;
|
||||
void register_inode(TmpFSInode&);
|
||||
void unregister_inode(InodeIdentifier);
|
||||
|
||||
unsigned m_next_inode_index { 1 };
|
||||
unsigned next_inode_index();
|
||||
};
|
||||
|
@ -67,11 +62,10 @@ public:
|
|||
virtual ErrorOr<void> set_atime(time_t) override;
|
||||
virtual ErrorOr<void> set_ctime(time_t) override;
|
||||
virtual ErrorOr<void> set_mtime(time_t) override;
|
||||
virtual void remove_from_secondary_lists() override;
|
||||
|
||||
private:
|
||||
TmpFSInode(TmpFS& fs, const InodeMetadata& metadata, InodeIdentifier parent);
|
||||
static ErrorOr<NonnullRefPtr<TmpFSInode>> try_create(TmpFS&, InodeMetadata const& metadata, InodeIdentifier parent);
|
||||
TmpFSInode(TmpFS& fs, const InodeMetadata& metadata, WeakPtr<TmpFSInode> parent);
|
||||
static ErrorOr<NonnullRefPtr<TmpFSInode>> try_create(TmpFS&, InodeMetadata const& metadata, WeakPtr<TmpFSInode> parent);
|
||||
static ErrorOr<NonnullRefPtr<TmpFSInode>> try_create_root(TmpFS&);
|
||||
|
||||
struct Child {
|
||||
|
@ -84,7 +78,7 @@ private:
|
|||
Child* find_child_by_name(StringView);
|
||||
|
||||
InodeMetadata m_metadata;
|
||||
InodeIdentifier m_parent;
|
||||
WeakPtr<TmpFSInode> m_parent;
|
||||
|
||||
OwnPtr<KBuffer> m_content;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue