summaryrefslogtreecommitdiff
path: root/VirtualFileSystem/SyntheticFileSystem.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2018-10-28 12:20:25 +0100
committerAndreas Kling <awesomekling@gmail.com>2018-10-28 12:20:25 +0100
commit1d4af5125078b097b9ab843d53ba50a0d9b1de5e (patch)
tree15d024898429359a91b327abf9c53be3f4124267 /VirtualFileSystem/SyntheticFileSystem.cpp
parent3f050c19720e1976bbbe2fd9061a52d2c3cd221c (diff)
downloadserenity-1d4af5125078b097b9ab843d53ba50a0d9b1de5e.zip
Add a VFS::absolutePath(InodeIdentifier).
This is pretty inefficient for ext2fs. We walk the entire block group containing the inode, searching through every directory for an entry referencing this inode. It might be a good idea to cache this information somehow. I'm not sure how often we'll be searching for it. Obviously there are multiple caching layers missing in the file system.
Diffstat (limited to 'VirtualFileSystem/SyntheticFileSystem.cpp')
-rw-r--r--VirtualFileSystem/SyntheticFileSystem.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/VirtualFileSystem/SyntheticFileSystem.cpp b/VirtualFileSystem/SyntheticFileSystem.cpp
index 51f48c8c9c..314e43c52d 100644
--- a/VirtualFileSystem/SyntheticFileSystem.cpp
+++ b/VirtualFileSystem/SyntheticFileSystem.cpp
@@ -199,7 +199,7 @@ Unix::ssize_t SyntheticFileSystem::readInodeBytes(InodeIdentifier inode, Unix::o
#endif
ASSERT(offset >= 0);
ASSERT(buffer);
-\
+
auto it = m_inodes.find(inode.index());
if (it == m_inodes.end())
return false;
@@ -235,3 +235,11 @@ auto SyntheticFileSystem::generateInodeIndex() -> InodeIndex
{
return m_nextInodeIndex++;
}
+
+InodeIdentifier SyntheticFileSystem::findParentOfInode(InodeIdentifier inode) const
+{
+ auto it = m_inodes.find(inode.index());
+ if (it == m_inodes.end())
+ return { };
+ return (*it).value->parent;
+}