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

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.
This commit is contained in:
Andreas Kling 2018-10-28 12:20:25 +01:00
parent 3f050c1972
commit 1d4af51250
11 changed files with 116 additions and 18 deletions

View file

@ -66,7 +66,7 @@ public:
VirtualFileSystem();
~VirtualFileSystem();
bool isDirectory(const String& path, Node* base = nullptr);
bool isDirectory(const String& path, InodeIdentifier base = InodeIdentifier());
void listDirectory(const String& path);
void listDirectoryRecursively(const String& path);
@ -79,9 +79,9 @@ public:
bool mountRoot(RetainPtr<FileSystem>&&);
bool mount(RetainPtr<FileSystem>&&, const String& path);
OwnPtr<FileHandle> open(const String& path, Node* base = nullptr);
OwnPtr<FileHandle> create(const String& path, Node* base = nullptr);
OwnPtr<FileHandle> mkdir(const String& path, Node* base = nullptr);
OwnPtr<FileHandle> open(const String& path, InodeIdentifier base = InodeIdentifier());
OwnPtr<FileHandle> create(const String& path, InodeIdentifier base = InodeIdentifier());
OwnPtr<FileHandle> mkdir(const String& path, InodeIdentifier base = InodeIdentifier());
bool isRoot(InodeIdentifier) const;
@ -92,12 +92,13 @@ public:
size_t mountCount() const { return m_mounts.size(); }
void forEachMount(Function<void(const Mount&)>) const;
String absolutePath(InodeIdentifier);
private:
friend class FileHandle;
void enumerateDirectoryInode(InodeIdentifier, Function<bool(const FileSystem::DirectoryEntry&)>);
String absolutePath(InodeIdentifier);
InodeIdentifier resolvePath(const String& path, Node* base = nullptr);
InodeIdentifier resolvePath(const String& path, InodeIdentifier base = InodeIdentifier());
InodeIdentifier resolveSymbolicLink(const String& basePath, InodeIdentifier symlinkInode);
RetainPtr<Node> allocateNode();