Virtual File System #10

Merged
apio merged 7 commits from vfs into main 2022-10-10 18:25:43 +00:00
2 changed files with 14 additions and 0 deletions
Showing only changes of commit 8158ddc94f - Show all commits

View File

@ -19,5 +19,8 @@ namespace VFS
int32_t read(Node* node, uint32_t offset, uint32_t length, char* buffer);
Node* open(const char* filename);
void mount_root(Node* root);
Node* root();
}

View File

@ -2,6 +2,7 @@
#include "fs/VFS.h"
#include "log/Log.h"
#include "std/string.h"
static VFS::Node* vfs_root;
@ -18,6 +19,9 @@ int32_t VFS::read(Node* node, uint32_t offset, uint32_t length, char* buffer)
return -1;
}
kdbgln("read(): node %s (inode %ld), offset %d, %d bytes, into %p", node->name, node->inode, offset, length,
(void*)buffer);
return node->read_func(node, offset, length, buffer);
}
@ -34,6 +38,8 @@ VFS::Node* VFS::open(const char* filename)
return 0;
}
kinfoln("open(): opening %s", filename);
return vfs_root->find_func(vfs_root, filename);
}
@ -51,4 +57,9 @@ void VFS::mount_root(Node* root)
}
kinfoln("mounting node '%s' as vfs root", root->name);
vfs_root = root;
}
VFS::Node* VFS::root()
{
return vfs_root;
}