2023-06-20 19:39:22 +00:00
|
|
|
#include "fs/ext2/FileSystem.h"
|
|
|
|
|
|
|
|
namespace Ext2
|
|
|
|
{
|
|
|
|
FileSystem::FileSystem()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Result<SharedPtr<VFS::Inode>> FileSystem::find_inode_by_number(ino_t inode)
|
|
|
|
{
|
|
|
|
auto maybe_inode = m_inode_cache.try_get(inode);
|
|
|
|
if (maybe_inode.has_value()) return maybe_inode.value();
|
|
|
|
|
2023-06-20 19:39:41 +00:00
|
|
|
// TODO: Locate the inode's block group descriptor and find it in the block group's inode table.
|
2023-06-20 19:39:22 +00:00
|
|
|
return err(ENOENT);
|
|
|
|
}
|
|
|
|
|
|
|
|
Result<SharedPtr<VFS::FileSystem>> FileSystem::create(SharedPtr<Device> host_device)
|
|
|
|
{
|
|
|
|
SharedPtr<FileSystem> fs = TRY(adopt_shared_if_nonnull(new (std::nothrow) FileSystem()));
|
|
|
|
const usize nread = TRY(host_device->read((u8*)&fs->m_superblock, 1024, 1024));
|
|
|
|
if (nread != 1024) return err(EINVAL); // Source had an invalid superblock.
|
|
|
|
if (fs->m_superblock.signature != EXT2_MAGIC) return err(EINVAL); // Source had an invalid superblock.
|
|
|
|
|
|
|
|
// TODO: Implement basic Ext2 reading, enough to be able to mount a volume.
|
|
|
|
return err(ENOTSUP);
|
|
|
|
}
|
|
|
|
}
|