| 548 | } |
| 549 | |
| 550 | BAN::ErrorOr<void> Ext2Inode::create_directory_impl(BAN::StringView name, mode_t mode, uid_t uid, gid_t gid) |
| 551 | { |
| 552 | ASSERT(this->mode().ifdir()); |
| 553 | ASSERT(Mode(mode).ifdir()); |
| 554 | |
| 555 | RWLockWRGuard _(m_lock); |
| 556 | |
| 557 | if (!find_inode_no_lock(name).is_error()) |
| 558 | return BAN::Error::from_errno(EEXIST); |
| 559 | |
| 560 | const uint32_t new_ino = TRY(m_fs.create_inode(initialize_new_inode_info(mode, uid, gid))); |
| 561 | |
| 562 | auto inode_or_error = m_fs.open_inode(new_ino); |
| 563 | if (inode_or_error.is_error()) |
| 564 | { |
| 565 | TRY(m_fs.delete_inode(new_ino)); |
| 566 | return inode_or_error.release_error(); |
| 567 | } |
| 568 | |
| 569 | auto inode = inode_or_error.release_value(); |
| 570 | |
| 571 | // link . and .. |
| 572 | if (auto ret = inode->link_inode_to_directory_no_lock(*inode, "."_sv); ret.is_error()) |
| 573 | return ({ TRY(inode->cleanup_from_fs_no_lock()); ret.release_error(); }); |
| 574 | if (auto ret = inode->link_inode_to_directory_no_lock(*this, ".."_sv); ret.is_error()) |
| 575 | return ({ TRY(inode->cleanup_from_fs_no_lock()); ret.release_error(); }); |
| 576 | |
| 577 | // link to parent |
| 578 | if (auto ret = link_inode_to_directory_no_lock(*inode, name); ret.is_error()) |
| 579 | return ({ TRY(inode->cleanup_from_fs_no_lock()); ret.release_error(); }); |
| 580 | |
| 581 | return {}; |
| 582 | } |
| 583 | |
| 584 | BAN::ErrorOr<void> Ext2Inode::link_inode_impl(BAN::StringView name, BAN::RefPtr<Inode> inode) |
| 585 | { |
nothing calls this directly
no test coverage detected