From 660f7cbfeb9b20be47309ac36dd167f965e0f6db Mon Sep 17 00:00:00 2001 From: Bananymous Date: Fri, 8 Sep 2023 10:23:16 +0300 Subject: [PATCH] Kernel: Ext2 directories can allocate new blocks if needed --- kernel/kernel/FS/Ext2/FileSystem.cpp | 2 +- kernel/kernel/FS/Ext2/Inode.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/kernel/kernel/FS/Ext2/FileSystem.cpp b/kernel/kernel/FS/Ext2/FileSystem.cpp index 8b4527b36a..f2679cf3db 100644 --- a/kernel/kernel/FS/Ext2/FileSystem.cpp +++ b/kernel/kernel/FS/Ext2/FileSystem.cpp @@ -1,7 +1,7 @@ #include #include -#define EXT2_DEBUG_PRINT 1 +#define EXT2_DEBUG_PRINT 0 #define EXT2_VERIFY_INODE 0 namespace Kernel diff --git a/kernel/kernel/FS/Ext2/Inode.cpp b/kernel/kernel/FS/Ext2/Inode.cpp index 3db561c585..c7938f1352 100644 --- a/kernel/kernel/FS/Ext2/Inode.cpp +++ b/kernel/kernel/FS/Ext2/Inode.cpp @@ -164,7 +164,7 @@ namespace Kernel ASSERT(mode().iflnk()); if (m_inode.size < sizeof(m_inode.block)) return BAN::String((const char*)m_inode.block); - ASSERT_NOT_REACHED(); + return BAN::Error::from_errno(ENOTSUP); } BAN::ErrorOr Ext2Inode::read(size_t offset, void* buffer, size_t count) @@ -486,8 +486,6 @@ namespace Kernel } needs_new_block: - ASSERT_NOT_REACHED(); - block_index = TRY(allocate_new_block()); m_fs.read_block(block_index, block_buffer.span()); @@ -511,6 +509,9 @@ needs_new_block: return res.release_error(); } + if (mode().ifdir()) + m_inode.size += blksize(); + TRY(sync()); return new_block_index; }