mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:47:34 +00:00
TmpFS: Stop using FS::DirectoryEntry in TmpFSInode
The list of children can just be a bunch of { name, inode }.
This commit is contained in:
parent
c096cb9352
commit
108263314a
2 changed files with 5 additions and 8 deletions
|
@ -135,8 +135,8 @@ KResult TmpFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntry
|
||||||
callback({ "..", m_parent, 0 });
|
callback({ "..", m_parent, 0 });
|
||||||
|
|
||||||
for (auto& it : m_children) {
|
for (auto& it : m_children) {
|
||||||
auto& entry = it.value.entry;
|
auto& entry = it.value;
|
||||||
callback({ { entry.name, entry.name_length }, entry.inode, entry.file_type });
|
callback({ entry.name, entry.inode->identifier(), 0 });
|
||||||
}
|
}
|
||||||
return KSuccess;
|
return KSuccess;
|
||||||
}
|
}
|
||||||
|
@ -218,7 +218,7 @@ RefPtr<Inode> TmpFSInode::lookup(StringView name)
|
||||||
auto it = m_children.find(name);
|
auto it = m_children.find(name);
|
||||||
if (it == m_children.end())
|
if (it == m_children.end())
|
||||||
return {};
|
return {};
|
||||||
return it->value.inode;
|
return fs().get_inode(it->value.inode->identifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
KResultOr<size_t> TmpFSInode::directory_entry_count() const
|
KResultOr<size_t> TmpFSInode::directory_entry_count() const
|
||||||
|
@ -295,10 +295,7 @@ KResult TmpFSInode::add_child(Inode& child, const StringView& name, mode_t)
|
||||||
ASSERT(is_directory());
|
ASSERT(is_directory());
|
||||||
ASSERT(child.fsid() == fsid());
|
ASSERT(child.fsid() == fsid());
|
||||||
|
|
||||||
String owned_name = name;
|
m_children.set(name, { name, static_cast<TmpFSInode&>(child) });
|
||||||
FS::DirectoryEntry entry = { owned_name.characters(), owned_name.length(), child.identifier(), 0 };
|
|
||||||
|
|
||||||
m_children.set(owned_name, { entry, static_cast<TmpFSInode&>(child) });
|
|
||||||
did_add_child(name);
|
did_add_child(name);
|
||||||
return KSuccess;
|
return KSuccess;
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ private:
|
||||||
|
|
||||||
Optional<KBuffer> m_content;
|
Optional<KBuffer> m_content;
|
||||||
struct Child {
|
struct Child {
|
||||||
FS::DirectoryEntry entry;
|
String name;
|
||||||
NonnullRefPtr<TmpFSInode> inode;
|
NonnullRefPtr<TmpFSInode> inode;
|
||||||
};
|
};
|
||||||
HashMap<String, Child> m_children;
|
HashMap<String, Child> m_children;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue