1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:07:45 +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

@ -43,7 +43,8 @@ ELFLOADER_OBJS = \
AK_OBJS = \
../AK/String.o \
../AK/StringImpl.o
../AK/StringImpl.o \
../AK/StringBuilder.o
OBJS = $(KERNEL_OBJS) $(VFS_OBJS) $(AK_OBJS) $(ELFLOADER_OBJS)

View file

@ -234,7 +234,7 @@ Task* Task::createUserTask(const String& path, uid_t uid, gid_t gid, pid_t paren
cwd = parentTask->m_cwd.copyRef();
}
auto handle = VirtualFileSystem::the().open(path, cwd.ptr());
auto handle = VirtualFileSystem::the().open(path, cwd ? cwd->inode : InodeIdentifier());
if (!handle) {
error = -ENOENT; // FIXME: Get a more detailed error from VFS.
return nullptr;
@ -785,7 +785,7 @@ int Task::sys$close(int fd)
int Task::sys$lstat(const char* path, Unix::stat* statbuf)
{
VALIDATE_USER_BUFFER(statbuf, sizeof(Unix::stat));
auto handle = VirtualFileSystem::the().open(move(path), m_cwd.ptr());
auto handle = VirtualFileSystem::the().open(move(path), cwdInode());
if (!handle)
return -1;
handle->stat(statbuf);
@ -795,7 +795,7 @@ int Task::sys$lstat(const char* path, Unix::stat* statbuf)
int Task::sys$chdir(const char* path)
{
VALIDATE_USER_BUFFER(path, strlen(path));
auto handle = VirtualFileSystem::the().open(path, m_cwd.ptr());
auto handle = VirtualFileSystem::the().open(path, cwdInode());
if (!handle)
return -ENOENT; // FIXME: More detailed error.
if (!handle->isDirectory())
@ -819,7 +819,7 @@ int Task::sys$open(const char* path, size_t pathLength)
VALIDATE_USER_BUFFER(path, pathLength);
if (m_fileHandles.size() >= m_maxFileHandles)
return -EMFILE;
auto handle = VirtualFileSystem::the().open(String(path, pathLength), m_cwd.ptr());
auto handle = VirtualFileSystem::the().open(String(path, pathLength), cwdInode());
if (!handle)
return -ENOENT; // FIXME: Detailed error.
int fd = m_fileHandles.size();

View file

@ -133,6 +133,8 @@ public:
bool isValidAddressForKernel(LinearAddress) const;
bool isValidAddressForUser(LinearAddress) const;
InodeIdentifier cwdInode() const { return m_cwd ? m_cwd->inode : InodeIdentifier(); }
private:
friend class MemoryManager;
friend bool scheduleNewTask();