Kernel: Ext2 directories can allocate new blocks if needed
This commit is contained in:
parent
1abf54d652
commit
660f7cbfeb
|
@ -1,7 +1,7 @@
|
||||||
#include <BAN/ScopeGuard.h>
|
#include <BAN/ScopeGuard.h>
|
||||||
#include <kernel/FS/Ext2/FileSystem.h>
|
#include <kernel/FS/Ext2/FileSystem.h>
|
||||||
|
|
||||||
#define EXT2_DEBUG_PRINT 1
|
#define EXT2_DEBUG_PRINT 0
|
||||||
#define EXT2_VERIFY_INODE 0
|
#define EXT2_VERIFY_INODE 0
|
||||||
|
|
||||||
namespace Kernel
|
namespace Kernel
|
||||||
|
|
|
@ -164,7 +164,7 @@ namespace Kernel
|
||||||
ASSERT(mode().iflnk());
|
ASSERT(mode().iflnk());
|
||||||
if (m_inode.size < sizeof(m_inode.block))
|
if (m_inode.size < sizeof(m_inode.block))
|
||||||
return BAN::String((const char*)m_inode.block);
|
return BAN::String((const char*)m_inode.block);
|
||||||
ASSERT_NOT_REACHED();
|
return BAN::Error::from_errno(ENOTSUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
BAN::ErrorOr<size_t> Ext2Inode::read(size_t offset, void* buffer, size_t count)
|
BAN::ErrorOr<size_t> Ext2Inode::read(size_t offset, void* buffer, size_t count)
|
||||||
|
@ -486,8 +486,6 @@ namespace Kernel
|
||||||
}
|
}
|
||||||
|
|
||||||
needs_new_block:
|
needs_new_block:
|
||||||
ASSERT_NOT_REACHED();
|
|
||||||
|
|
||||||
block_index = TRY(allocate_new_block());
|
block_index = TRY(allocate_new_block());
|
||||||
|
|
||||||
m_fs.read_block(block_index, block_buffer.span());
|
m_fs.read_block(block_index, block_buffer.span());
|
||||||
|
@ -511,6 +509,9 @@ needs_new_block:
|
||||||
return res.release_error();
|
return res.release_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mode().ifdir())
|
||||||
|
m_inode.size += blksize();
|
||||||
|
|
||||||
TRY(sync());
|
TRY(sync());
|
||||||
return new_block_index;
|
return new_block_index;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue