Compare commits
3 Commits
00d625a697
...
868213bb85
Author | SHA1 | Date | |
---|---|---|---|
868213bb85 | |||
2b7537acba | |||
fe7a03e43b |
@ -28,7 +28,7 @@ namespace Ext2
|
|||||||
if (offset % block_size)
|
if (offset % block_size)
|
||||||
{
|
{
|
||||||
usize block_offset = (offset % block_size);
|
usize block_offset = (offset % block_size);
|
||||||
usize block = find_block(offset / block_size);
|
usize block = TRY(find_block(offset / block_size));
|
||||||
usize size_to_read = block_size - block_offset;
|
usize size_to_read = block_size - block_offset;
|
||||||
if (size_to_read > to_read) size_to_read = to_read;
|
if (size_to_read > to_read) size_to_read = to_read;
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ namespace Ext2
|
|||||||
|
|
||||||
while (to_read >= block_size)
|
while (to_read >= block_size)
|
||||||
{
|
{
|
||||||
usize block = find_block(offset / block_size);
|
usize block = TRY(find_block(offset / block_size));
|
||||||
|
|
||||||
usize host_offset = block * block_size;
|
usize host_offset = block * block_size;
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ namespace Ext2
|
|||||||
|
|
||||||
if (to_read > 0)
|
if (to_read > 0)
|
||||||
{
|
{
|
||||||
usize block = find_block(offset / block_size);
|
usize block = TRY(find_block(offset / block_size));
|
||||||
|
|
||||||
usize host_offset = block * block_size;
|
usize host_offset = block * block_size;
|
||||||
|
|
||||||
@ -69,11 +69,26 @@ namespace Ext2
|
|||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
usize Inode::find_block(usize index) const
|
Result<usize> Inode::find_block(usize index) const
|
||||||
{
|
{
|
||||||
expect(index < 12, "ext2: Finding blocks in the indirect pointers is not yet supported");
|
if (index < 12) return m_raw_inode.direct_pointers[index];
|
||||||
|
|
||||||
return m_raw_inode.direct_pointers[index];
|
usize block_index = (index - 12) * sizeof(u32);
|
||||||
|
if (block_index >= m_fs->m_block_size)
|
||||||
|
{
|
||||||
|
fail("ext2: Finding blocks beyond the singly indirect pointer block is not yet supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
usize block_size = m_fs->m_block_size;
|
||||||
|
|
||||||
|
if (m_singly_indirect_block.is_empty())
|
||||||
|
{
|
||||||
|
TRY(m_singly_indirect_block.try_resize(block_size));
|
||||||
|
TRY(m_fs->m_host_device->read(m_singly_indirect_block.data(), m_raw_inode.singly_indirect_ptr * block_size,
|
||||||
|
block_size));
|
||||||
|
}
|
||||||
|
|
||||||
|
return *reinterpret_cast<u32*>(&m_singly_indirect_block.data()[block_index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<void> Inode::lazy_initialize_dir() const
|
Result<void> Inode::lazy_initialize_dir() const
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "fs/ext2/FileSystem.h"
|
#include "fs/ext2/FileSystem.h"
|
||||||
|
#include <luna/Buffer.h>
|
||||||
#include <luna/String.h>
|
#include <luna/String.h>
|
||||||
|
|
||||||
#define EXT2_FIFO 0x1000
|
#define EXT2_FIFO 0x1000
|
||||||
@ -141,12 +142,14 @@ namespace Ext2
|
|||||||
FileSystem* m_fs;
|
FileSystem* m_fs;
|
||||||
ino_t m_inum;
|
ino_t m_inum;
|
||||||
|
|
||||||
|
mutable Buffer m_singly_indirect_block;
|
||||||
|
|
||||||
String m_link;
|
String m_link;
|
||||||
|
|
||||||
mutable Vector<VFS::DirectoryEntry> m_entries;
|
mutable Vector<VFS::DirectoryEntry> m_entries;
|
||||||
mutable bool m_dir_already_lazily_initialized { false };
|
mutable bool m_dir_already_lazily_initialized { false };
|
||||||
|
|
||||||
usize find_block(usize index) const;
|
Result<usize> find_block(usize index) const;
|
||||||
|
|
||||||
friend class FileSystem;
|
friend class FileSystem;
|
||||||
};
|
};
|
||||||
|
@ -235,7 +235,7 @@ namespace Scheduler
|
|||||||
{
|
{
|
||||||
switch_context(old_thread, new_thread, regs);
|
switch_context(old_thread, new_thread, regs);
|
||||||
if (!old_thread->is_kernel) old_thread->fp_data.save();
|
if (!old_thread->is_kernel) old_thread->fp_data.save();
|
||||||
if (old_thread->is_kernel && MMU::get_page_directory() != MMU::kernel_page_directory())
|
if (MMU::get_page_directory() != MMU::kernel_page_directory())
|
||||||
old_thread->directory = MMU::get_page_directory();
|
old_thread->directory = MMU::get_page_directory();
|
||||||
if (new_thread->directory) MMU::switch_page_directory(new_thread->directory);
|
if (new_thread->directory) MMU::switch_page_directory(new_thread->directory);
|
||||||
if (!new_thread->is_kernel)
|
if (!new_thread->is_kernel)
|
||||||
|
@ -7,6 +7,6 @@ cd $LUNA_ROOT
|
|||||||
|
|
||||||
fakeroot -u -s $LUNA_ROOT/.fakeroot -- tools/install.sh
|
fakeroot -u -s $LUNA_ROOT/.fakeroot -- tools/install.sh
|
||||||
|
|
||||||
genext2fs -d base -B 4096 -b 512 -L luna-rootfs -U -N 512 build/ext2fs.bin
|
genext2fs -d base -B 4096 -b 1024 -L luna-rootfs -U -N 1024 build/ext2fs.bin
|
||||||
|
|
||||||
fakeroot -u -i $LUNA_ROOT/.fakeroot -- mkbootimg luna.json Luna.iso
|
fakeroot -u -i $LUNA_ROOT/.fakeroot mkbootimg luna.json Luna.iso
|
||||||
|
Loading…
Reference in New Issue
Block a user