mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 06:18:59 +00:00
Kernel: Change Ext2FS to be backed by a file instead of a block device
In contrast to the previous patchset that was reverted, this time we use a "special" method to access a file with block size of 512 bytes (like a harddrive essentially).
This commit is contained in:
parent
1d6c8724b9
commit
ecee76b741
Notes:
sideshowbarker
2024-07-19 07:51:19 +09:00
Author: https://github.com/supercomputer7
Commit: ecee76b741
Pull-request: https://github.com/SerenityOS/serenity/pull/1663
Reviewed-by: https://github.com/awesomekling
10 changed files with 104 additions and 77 deletions
|
@ -64,13 +64,13 @@ static u8 to_ext2_file_type(mode_t mode)
|
|||
return EXT2_FT_UNKNOWN;
|
||||
}
|
||||
|
||||
NonnullRefPtr<Ext2FS> Ext2FS::create(BlockDevice& device)
|
||||
NonnullRefPtr<Ext2FS> Ext2FS::create(FileDescription& file_description)
|
||||
{
|
||||
return adopt(*new Ext2FS(device));
|
||||
return adopt(*new Ext2FS(file_description));
|
||||
}
|
||||
|
||||
Ext2FS::Ext2FS(BlockDevice& device)
|
||||
: DiskBackedFS(device)
|
||||
Ext2FS::Ext2FS(FileDescription& file_description)
|
||||
: FileBackedFS(file_description)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ Ext2FS::~Ext2FS()
|
|||
bool Ext2FS::flush_super_block()
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
bool success = device().write_blocks(2, 1, (const u8*)&m_super_block);
|
||||
bool success = raw_write(2, (const u8*)&m_super_block);
|
||||
ASSERT(success);
|
||||
return true;
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ const ext2_group_desc& Ext2FS::group_descriptor(GroupIndex group_index) const
|
|||
bool Ext2FS::initialize()
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
bool success = const_cast<BlockDevice&>(device()).read_blocks(2, 1, (u8*)&m_super_block);
|
||||
bool success = raw_read(2, (u8*)&m_super_block);
|
||||
ASSERT(success);
|
||||
|
||||
auto& super_block = this->super_block();
|
||||
|
@ -543,7 +543,7 @@ void Ext2FS::flush_writes()
|
|||
}
|
||||
}
|
||||
|
||||
DiskBackedFS::flush_writes();
|
||||
FileBackedFS::flush_writes();
|
||||
|
||||
// Uncache Inodes that are only kept alive by the index-to-inode lookup cache.
|
||||
// We don't uncache Inodes that are being watched by at least one InodeWatcher.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue