fix(kernel/vfs): 🎉 a complete rewrite of the vfs

This is the fourth time re-writing the VFS, hope this will be the last. Tried to make it as modular as possible so this won't be necessary in the future. 🙏

This change required the entire kernel code to be modified.
This commit is contained in:
2025-05-13 15:59:12 +00:00
parent 83a7f83f81
commit 557c7e6235
83 changed files with 3252 additions and 2487 deletions

View File

@ -0,0 +1,91 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __FENNIX_KERNEL_FILESYSTEM_EXT2_H__
#define __FENNIX_KERNEL_FILESYSTEM_EXT2_H__
#include <types.h>
#include <fs/vfs.hpp>
namespace Driver::ExtendedFilesystem
{
class EXT2
{
public:
struct SuperBlock
{
uint32_t Inodes;
uint32_t Blocks;
uint32_t ReservedBlocks;
uint32_t FreeBlock;
uint32_t FreeInodes;
uint32_t FirstDataBlock;
uint32_t LogBlockSize;
uint32_t LogFragSize;
uint32_t BlocksPerGroup;
uint32_t FragsPerGroup;
uint32_t InodesPerGroup;
uint32_t LastMountTime;
uint32_t LastWrittenTime;
uint16_t MountedTimes;
uint16_t MaximumMountedTimes;
uint16_t Magic;
uint16_t State;
uint16_t Errors;
uint16_t MinorRevLevel;
uint32_t LastCheck;
uint32_t CheckInternval;
uint32_t SystemID;
uint32_t RevLevel;
uint16_t ReservedBlocksUserID;
uint16_t ReservedBlocksGroupID;
uint32_t FirstInode;
uint16_t InodeSize;
uint16_t BlockGroups;
uint32_t FeatureCompatibility;
uint32_t FeatureIncompatibility;
uint32_t FeatureRoCompatibility;
uint8_t UUID[16];
char VolumeName[16];
char LastMounted[64];
uint32_t BitmapAlogrithm;
uint8_t PreallocatedBlocks;
uint8_t PreallocatedDirectoryBlocks;
uint16_t Padding;
uint8_t JournalUUID[16];
uint32_t JournalInum;
uint32_t JournalDev;
uint32_t LastOrphan;
uint32_t HashSeed[4];
uint8_t DefHashVersion;
uint8_t ReservedCharPad;
uint16_t ReservedWordPad;
uint32_t DefaultMountOptions;
uint32_t FirstMetaBg;
uint32_t Reserved[190];
};
EXT2(void *partition);
~EXT2();
};
}
#endif // !__FENNIX_KERNEL_FILESYSTEM_EXT2_H__

View File

@ -0,0 +1,200 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#include <driver.hpp>
#include <fs/ustar.hpp>
#include <interface/fs.h>
#include <memory.hpp>
#include <debug.h>
using namespace vfs;
namespace Driver::UnixStandardTAR
{
dev_t DriverID;
int USTAR_AllocateInode(FileSystemInfo *Info, Inode **Result)
{
assert(!"NOT IMPLEMENTED");
}
int USTAR_DeleteInode(FileSystemInfo *Info, Inode *Node)
{
assert(!"NOT IMPLEMENTED");
}
int USTAR_Synchronize(FileSystemInfo *Info, Inode *Node)
{
assert(!"NOT IMPLEMENTED");
}
int USTAR_Destroy(FileSystemInfo *Info)
{
assert(!"NOT IMPLEMENTED");
}
int USTAR_Probe(void *Device)
{
assert(!"NOT IMPLEMENTED");
}
int USTAR_Mount(FileSystemInfo *FS, Inode **Root, void *Device)
{
assert(!"NOT IMPLEMENTED");
}
int USTAR_Unmount(FileSystemInfo *FS)
{
assert(!"NOT IMPLEMENTED");
}
int USTAR_Lookup(Inode *Parent, const char *Name, Inode **Result)
{
assert(!"NOT IMPLEMENTED");
}
int USTAR_Create(Inode *Parent, const char *Name, mode_t Mode, Inode **Result)
{
assert(!"NOT IMPLEMENTED");
}
int USTAR_Remove(Inode *Parent, const char *Name)
{
assert(!"NOT IMPLEMENTED");
}
int USTAR_Rename(Inode *Parent, const char *OldName, const char *NewName)
{
assert(!"NOT IMPLEMENTED");
}
ssize_t USTAR_Read(Inode *Node, void *Buffer, size_t Size, off_t Offset)
{
assert(!"NOT IMPLEMENTED");
}
ssize_t USTAR_Write(Inode *Node, const void *Buffer, size_t Size, off_t Offset)
{
assert(!"NOT IMPLEMENTED");
}
int USTAR_Truncate(Inode *Node, off_t Size)
{
assert(!"NOT IMPLEMENTED");
}
int USTAR_Open(Inode *Node, int Flags, mode_t Mode)
{
assert(!"NOT IMPLEMENTED");
}
int USTAR_Close(Inode *Node)
{
assert(!"NOT IMPLEMENTED");
}
int USTAR_Ioctl(Inode *Node, unsigned long Request, void *Argp)
{
assert(!"NOT IMPLEMENTED");
}
ssize_t USTAR_ReadDir(Inode *Node, kdirent *Buffer, size_t Size, off_t Offset, off_t Entries)
{
assert(!"NOT IMPLEMENTED");
}
int USTAR_MkDir(Inode *Parent, const char *Name, mode_t Mode, Inode **Result)
{
assert(!"NOT IMPLEMENTED");
}
int USTAR_RmDir(Inode *Parent, const char *Name)
{
assert(!"NOT IMPLEMENTED");
}
int USTAR_SymLink(Inode *Parent, const char *Name, const char *Target, Inode **Result)
{
assert(!"NOT IMPLEMENTED");
}
ssize_t USTAR_ReadLink(Inode *Node, char *Buffer, size_t Size)
{
assert(!"NOT IMPLEMENTED");
}
off_t USTAR_Seek(Inode *Node, off_t Offset)
{
assert(!"NOT IMPLEMENTED");
}
int USTAR_Stat(Inode *Node, kstat *Stat)
{
assert(!"NOT IMPLEMENTED");
}
static SuperBlockOperations ustarSuperOps = {
.AllocateInode = USTAR_AllocateInode,
.DeleteInode = USTAR_DeleteInode,
.Synchronize = USTAR_Synchronize,
.Destroy = USTAR_Destroy,
.Probe = USTAR_Probe,
.Mount = USTAR_Mount,
.Unmount = USTAR_Unmount};
static InodeOperations ustarInodeOps = {
.Lookup = USTAR_Lookup,
.Create = USTAR_Create,
.Remove = USTAR_Remove,
.Rename = USTAR_Rename,
.Read = USTAR_Read,
.Write = USTAR_Write,
.Truncate = USTAR_Truncate,
.Open = USTAR_Open,
.Close = USTAR_Close,
.Ioctl = USTAR_Ioctl,
.ReadDir = USTAR_ReadDir,
.MkDir = USTAR_MkDir,
.RmDir = USTAR_RmDir,
.SymLink = USTAR_SymLink,
.ReadLink = USTAR_ReadLink,
.Seek = USTAR_Seek,
.Stat = USTAR_Stat};
int Entry()
{
FileSystemInfo *fsi = new FileSystemInfo;
fsi->Name = "Unix Standard TAR";
fsi->SuperOps = ustarSuperOps;
fsi->Ops = ustarInodeOps;
v0::RegisterFileSystem(DriverID, fsi);
return 0;
}
int Final() { return 0; }
int Panic() { return 0; }
int Probe() { return 0; }
REGISTER_BUILTIN_DRIVER(ustar,
"Unix Standard TAR Driver",
"enderice2",
1, 0, 0,
Entry,
Final,
Panic,
Probe);
}