mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:58:11 +00:00
Fix some broken stuff in VFS test environment.
It's still lagging behind the metal environment but here's some work towards fixing it at least.
This commit is contained in:
parent
981a3ae4b3
commit
61a84193d7
4 changed files with 27 additions and 15 deletions
|
@ -7,6 +7,7 @@ AK_OBJS = \
|
|||
../AK/TemporaryFile.o \
|
||||
../AK/SimpleMalloc.o \
|
||||
../AK/StringBuilder.o \
|
||||
../AK/FileSystemPath.o \
|
||||
../AK/kmalloc.o
|
||||
|
||||
VFS_OBJS = \
|
||||
|
|
|
@ -258,10 +258,10 @@ void VirtualFileSystem::enumerateDirectoryInode(InodeIdentifier directoryInode,
|
|||
}
|
||||
|
||||
#ifndef SERENITY
|
||||
void VirtualFileSystem::listDirectory(const String& path)
|
||||
void VirtualFileSystem::listDirectory(const String& path, InodeIdentifier base)
|
||||
{
|
||||
int error;
|
||||
auto directoryInode = resolvePath(path, error);
|
||||
auto directoryInode = resolvePath(path, error, base);
|
||||
if (!directoryInode.isValid())
|
||||
return;
|
||||
|
||||
|
@ -359,10 +359,10 @@ void VirtualFileSystem::listDirectory(const String& path)
|
|||
});
|
||||
}
|
||||
|
||||
void VirtualFileSystem::listDirectoryRecursively(const String& path)
|
||||
void VirtualFileSystem::listDirectoryRecursively(const String& path, InodeIdentifier base)
|
||||
{
|
||||
int error;
|
||||
auto directory = resolvePath(path, error);
|
||||
auto directory = resolvePath(path, error, base);
|
||||
if (!directory.isValid())
|
||||
return;
|
||||
|
||||
|
@ -374,7 +374,7 @@ void VirtualFileSystem::listDirectoryRecursively(const String& path)
|
|||
if (entry.name != "." && entry.name != "..") {
|
||||
char buf[4096];
|
||||
ksprintf(buf, "%s/%s", path.characters(), entry.name.characters());
|
||||
listDirectoryRecursively(buf);
|
||||
listDirectoryRecursively(buf, base);
|
||||
}
|
||||
} else {
|
||||
kprintf("%s/%s\n", path.characters(), entry.name.characters());
|
||||
|
|
|
@ -79,8 +79,8 @@ public:
|
|||
~VirtualFileSystem();
|
||||
|
||||
bool isDirectory(const String& path, InodeIdentifier base = InodeIdentifier());
|
||||
void listDirectory(const String& path);
|
||||
void listDirectoryRecursively(const String& path);
|
||||
void listDirectory(const String& path, InodeIdentifier base);
|
||||
void listDirectoryRecursively(const String& path, InodeIdentifier base);
|
||||
|
||||
unsigned maxNodeCount() const { return m_maxNodeCount; }
|
||||
unsigned allocatedNodeCount() const { return m_maxNodeCount - m_nodeFreeList.size(); }
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "FullDevice.h"
|
||||
#include "RandomDevice.h"
|
||||
#include <cstring>
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/SimpleMalloc.h>
|
||||
#include <AK/StdLib.h>
|
||||
#include <AK/kmalloc.h>
|
||||
|
@ -77,9 +78,9 @@ int main(int c, char** v)
|
|||
|
||||
vfs.mount(std::move(synthfs), "/syn");
|
||||
|
||||
vfs.listDirectory("/");
|
||||
vfs.listDirectory(".", vfs.root()->inode);
|
||||
printf("list /syn:\n");
|
||||
vfs.listDirectory("/syn");
|
||||
vfs.listDirectory("/syn", vfs.root()->inode);
|
||||
|
||||
#if 0
|
||||
auto descriptor = vfs.open("/home/andreas/../../home/./andreas/./file2");
|
||||
|
@ -94,6 +95,8 @@ int main(int c, char** v)
|
|||
|
||||
String currentDirectory = "/";
|
||||
|
||||
auto cwd = vfs.root()->inode;
|
||||
|
||||
while (true) {
|
||||
char cmdbuf[256];
|
||||
printf("::>");
|
||||
|
@ -120,22 +123,30 @@ int main(int c, char** v)
|
|||
}
|
||||
|
||||
if (cmd == "ls") {
|
||||
vfs.listDirectory(currentDirectory);
|
||||
vfs.listDirectory(".", cwd);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cmd == "lr") {
|
||||
vfs.listDirectoryRecursively(currentDirectory);
|
||||
vfs.listDirectoryRecursively(".", cwd);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cmd == "cd" && parts.size() > 1) {
|
||||
char buf[1024];
|
||||
char buf[4096];
|
||||
sprintf(buf, "%s/%s", currentDirectory.characters(), parts[1].characters());
|
||||
if (vfs.isDirectory(buf)) {
|
||||
currentDirectory = buf;
|
||||
FileSystemPath new_path(buf);
|
||||
if (new_path.string() == "/") {
|
||||
cwd = vfs.root()->inode;
|
||||
continue;
|
||||
}
|
||||
int error;
|
||||
auto new_cwd = vfs.open(new_path.string(), error, 0, cwd);
|
||||
if (new_cwd && new_cwd->isDirectory()) {
|
||||
currentDirectory = new_path.string();
|
||||
cwd = new_cwd->metadata().inode;
|
||||
} else {
|
||||
printf("No such directory: %s\n", buf);
|
||||
printf("No such directory: %s\n", parts[1].characters());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue