Kernel: Ext2 check if file exists before creating it

This commit is contained in:
Bananymous 2024-10-07 18:20:08 +03:00
parent 3e68981b0b
commit 166550fbba
1 changed files with 6 additions and 0 deletions

View File

@ -424,6 +424,9 @@ done:
{
ASSERT(this->mode().ifdir());
if (!find_inode_impl(name).is_error())
return BAN::Error::from_errno(EEXIST);
if (!(Mode(mode).ifreg()))
return BAN::Error::from_errno(ENOTSUP);
@ -448,6 +451,9 @@ done:
ASSERT(this->mode().ifdir());
ASSERT(Mode(mode).ifdir());
if (!find_inode_impl(name).is_error())
return BAN::Error::from_errno(EEXIST);
const uint32_t new_ino = TRY(m_fs.create_inode(initialize_new_inode_info(mode, uid, gid)));
auto inode_or_error = Ext2Inode::create(m_fs, new_ino);