Kernel: Ext2 check if file exists before creating it
This commit is contained in:
parent
3e68981b0b
commit
166550fbba
|
@ -424,6 +424,9 @@ done:
|
||||||
{
|
{
|
||||||
ASSERT(this->mode().ifdir());
|
ASSERT(this->mode().ifdir());
|
||||||
|
|
||||||
|
if (!find_inode_impl(name).is_error())
|
||||||
|
return BAN::Error::from_errno(EEXIST);
|
||||||
|
|
||||||
if (!(Mode(mode).ifreg()))
|
if (!(Mode(mode).ifreg()))
|
||||||
return BAN::Error::from_errno(ENOTSUP);
|
return BAN::Error::from_errno(ENOTSUP);
|
||||||
|
|
||||||
|
@ -448,6 +451,9 @@ done:
|
||||||
ASSERT(this->mode().ifdir());
|
ASSERT(this->mode().ifdir());
|
||||||
ASSERT(Mode(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)));
|
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);
|
auto inode_or_error = Ext2Inode::create(m_fs, new_ino);
|
||||||
|
|
Loading…
Reference in New Issue