From 2e2693d1ea64eaca8e3e358bfd627c2483f580b8 Mon Sep 17 00:00:00 2001 From: Nigel Date: Tue, 15 Mar 2022 21:56:32 +0100 Subject: [PATCH] Build some structures will need for the virtual filesystem --- .../EXT2/SuperBlock.h | 0 .../FAT/BiosParameterBlock.h | 0 .../FAT/DirectoryEntry.h | 0 .../FAT/ExtendBootRecord.h | 0 src/kernel/kernel.h | 6 +-- src/kernel/vfs/File.h | 9 ++++ src/kernel/vfs/VFS.cpp | 50 +++++++++++++++++++ src/kernel/vfs/VFS.h | 29 +++++++++++ 8 files changed, 91 insertions(+), 3 deletions(-) rename src/kernel/{filesytems => filesystems}/EXT2/SuperBlock.h (100%) rename src/kernel/{filesytems => filesystems}/FAT/BiosParameterBlock.h (100%) rename src/kernel/{filesytems => filesystems}/FAT/DirectoryEntry.h (100%) rename src/kernel/{filesytems => filesystems}/FAT/ExtendBootRecord.h (100%) create mode 100644 src/kernel/vfs/File.h create mode 100644 src/kernel/vfs/VFS.cpp create mode 100644 src/kernel/vfs/VFS.h diff --git a/src/kernel/filesytems/EXT2/SuperBlock.h b/src/kernel/filesystems/EXT2/SuperBlock.h similarity index 100% rename from src/kernel/filesytems/EXT2/SuperBlock.h rename to src/kernel/filesystems/EXT2/SuperBlock.h diff --git a/src/kernel/filesytems/FAT/BiosParameterBlock.h b/src/kernel/filesystems/FAT/BiosParameterBlock.h similarity index 100% rename from src/kernel/filesytems/FAT/BiosParameterBlock.h rename to src/kernel/filesystems/FAT/BiosParameterBlock.h diff --git a/src/kernel/filesytems/FAT/DirectoryEntry.h b/src/kernel/filesystems/FAT/DirectoryEntry.h similarity index 100% rename from src/kernel/filesytems/FAT/DirectoryEntry.h rename to src/kernel/filesystems/FAT/DirectoryEntry.h diff --git a/src/kernel/filesytems/FAT/ExtendBootRecord.h b/src/kernel/filesystems/FAT/ExtendBootRecord.h similarity index 100% rename from src/kernel/filesytems/FAT/ExtendBootRecord.h rename to src/kernel/filesystems/FAT/ExtendBootRecord.h diff --git a/src/kernel/kernel.h b/src/kernel/kernel.h index 26f6fa5..ac164a3 100644 --- a/src/kernel/kernel.h +++ b/src/kernel/kernel.h @@ -28,9 +28,9 @@ extern "C" #include "ide/ide.h" #include "./drivers/IO/ata/ataDevice.h" #include "./PartitionTable/MBR/MasterBootRecord.h" -#include "./filesytems/FAT/BiosParameterBlock.h" -#include "./filesytems/FAT/ExtendBootRecord.h" -#include "./filesytems/FAT/DirectoryEntry.h" +#include "./filesystems/FAT/BiosParameterBlock.h" +#include "./filesystems/FAT/ExtendBootRecord.h" +#include "./filesystems/FAT/DirectoryEntry.h" #include "drivers/ACPI/rsdp.h" diff --git a/src/kernel/vfs/File.h b/src/kernel/vfs/File.h new file mode 100644 index 0000000..5a76c48 --- /dev/null +++ b/src/kernel/vfs/File.h @@ -0,0 +1,9 @@ +#pragma once + +class File { + +public: + virtual const File* Open () const ; // TODO: figure out a proper return value + virtual const char* Read() const; + virtual void Write(); +}; diff --git a/src/kernel/vfs/VFS.cpp b/src/kernel/vfs/VFS.cpp new file mode 100644 index 0000000..8eca77a --- /dev/null +++ b/src/kernel/vfs/VFS.cpp @@ -0,0 +1,50 @@ +#include "VFS.h" +/* + * TODO: Implement this!! + * + */ + + + +void VirtualFileSystem::Initialize(FS* root) +{ + root = root; +} + +void VirtualFileSystem::Open(const char* path) +{ + /* + What does this mean? + 1. Parse the path string + 2. Traverse the graph (Finding the correct Node) + 3. Create some kind of open file pointer thingy + */ +} + +void VirtualFileSystem::Read() +{ + // NOTE: we need some way to know what file we wish to read from +} + +void VirtualFileSystem::Write() +{ + // NOTE: we need some way to know what file we wish to write to +} + +void VirtualFileSystem::Mount(const char* path, FS* FileSystem) +{ + /* + What does this mean? + 1. Parse the path string + 2. Add a node to our internal graph + */ +} + +void VirtualFileSystem::UnMount(FS* FileSystem) +{ + /* + What does this mean? + 1. Parse the path string + 2. Remve a node to our internal graph + */ +} \ No newline at end of file diff --git a/src/kernel/vfs/VFS.h b/src/kernel/vfs/VFS.h new file mode 100644 index 0000000..b525cc2 --- /dev/null +++ b/src/kernel/vfs/VFS.h @@ -0,0 +1,29 @@ +#pragma once + +class VirtualFileSystem{ +public: + void Initialize( FS* root); + void Open (const char* path); + void Read(); + void Write(); + + void Mount(const char* path,FS* FileSystem); + void UnMount(FS* FileSystem); + +private: + FS* root; + + +}; + +struct FS +{ + const char* name ; + int DeviceID; + int ManufacturerID; + FS* next; + char**(Read)(); + void*(Write)(); + void*(Open)(); +}; +