mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:27:35 +00:00
Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED) Since all of these checks are done in release builds as well, let's rename them to VERIFY to prevent confusion, as everyone is used to assertions being compiled out in release. We can introduce a new ASSERT macro that is specifically for debug checks, but I'm doing this wholesale conversion first since we've accumulated thousands of these already, and it's not immediately obvious which ones are suitable for ASSERT.
This commit is contained in:
parent
b33a6a443e
commit
5d180d1f99
725 changed files with 3448 additions and 3448 deletions
|
@ -78,7 +78,7 @@ public:
|
|||
{
|
||||
if (auto it = m_hash.find(block_index); it != m_hash.end()) {
|
||||
auto& entry = const_cast<CacheEntry&>(*it->value);
|
||||
ASSERT(entry.block_index == block_index);
|
||||
VERIFY(entry.block_index == block_index);
|
||||
return entry;
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ public:
|
|||
return get(block_index);
|
||||
}
|
||||
|
||||
ASSERT(m_clean_list.last());
|
||||
VERIFY(m_clean_list.last());
|
||||
auto& new_entry = *m_clean_list.last();
|
||||
m_clean_list.prepend(new_entry);
|
||||
|
||||
|
@ -127,7 +127,7 @@ private:
|
|||
BlockBasedFS::BlockBasedFS(FileDescription& file_description)
|
||||
: FileBackedFS(file_description)
|
||||
{
|
||||
ASSERT(file_description.file().is_seekable());
|
||||
VERIFY(file_description.file().is_seekable());
|
||||
}
|
||||
|
||||
BlockBasedFS::~BlockBasedFS()
|
||||
|
@ -136,8 +136,8 @@ BlockBasedFS::~BlockBasedFS()
|
|||
|
||||
KResult BlockBasedFS::write_block(BlockIndex index, const UserOrKernelBuffer& data, size_t count, size_t offset, bool allow_cache)
|
||||
{
|
||||
ASSERT(m_logical_block_size);
|
||||
ASSERT(offset + count <= block_size());
|
||||
VERIFY(m_logical_block_size);
|
||||
VERIFY(offset + count <= block_size());
|
||||
dbgln_if(BBFS_DEBUG, "BlockBasedFileSystem::write_block {}, size={}", index, count);
|
||||
|
||||
if (!allow_cache) {
|
||||
|
@ -147,7 +147,7 @@ KResult BlockBasedFS::write_block(BlockIndex index, const UserOrKernelBuffer& da
|
|||
auto nwritten = file_description().write(data, count);
|
||||
if (nwritten.is_error())
|
||||
return nwritten.error();
|
||||
ASSERT(nwritten.value() == count);
|
||||
VERIFY(nwritten.value() == count);
|
||||
return KSuccess;
|
||||
}
|
||||
|
||||
|
@ -171,8 +171,8 @@ bool BlockBasedFS::raw_read(BlockIndex index, UserOrKernelBuffer& buffer)
|
|||
u32 base_offset = index.value() * m_logical_block_size;
|
||||
file_description().seek(base_offset, SEEK_SET);
|
||||
auto nread = file_description().read(buffer, m_logical_block_size);
|
||||
ASSERT(!nread.is_error());
|
||||
ASSERT(nread.value() == m_logical_block_size);
|
||||
VERIFY(!nread.is_error());
|
||||
VERIFY(nread.value() == m_logical_block_size);
|
||||
return true;
|
||||
}
|
||||
bool BlockBasedFS::raw_write(BlockIndex index, const UserOrKernelBuffer& buffer)
|
||||
|
@ -180,8 +180,8 @@ bool BlockBasedFS::raw_write(BlockIndex index, const UserOrKernelBuffer& buffer)
|
|||
size_t base_offset = index.value() * m_logical_block_size;
|
||||
file_description().seek(base_offset, SEEK_SET);
|
||||
auto nwritten = file_description().write(buffer, m_logical_block_size);
|
||||
ASSERT(!nwritten.is_error());
|
||||
ASSERT(nwritten.value() == m_logical_block_size);
|
||||
VERIFY(!nwritten.is_error());
|
||||
VERIFY(nwritten.value() == m_logical_block_size);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -208,7 +208,7 @@ bool BlockBasedFS::raw_write_blocks(BlockIndex index, size_t count, const UserOr
|
|||
|
||||
KResult BlockBasedFS::write_blocks(BlockIndex index, unsigned count, const UserOrKernelBuffer& data, bool allow_cache)
|
||||
{
|
||||
ASSERT(m_logical_block_size);
|
||||
VERIFY(m_logical_block_size);
|
||||
dbgln_if(BBFS_DEBUG, "BlockBasedFileSystem::write_blocks {}, count={}", index, count);
|
||||
for (unsigned i = 0; i < count; ++i) {
|
||||
auto result = write_block(BlockIndex { index.value() + i }, data.offset(i * block_size()), block_size(), 0, allow_cache);
|
||||
|
@ -220,8 +220,8 @@ KResult BlockBasedFS::write_blocks(BlockIndex index, unsigned count, const UserO
|
|||
|
||||
KResult BlockBasedFS::read_block(BlockIndex index, UserOrKernelBuffer* buffer, size_t count, size_t offset, bool allow_cache) const
|
||||
{
|
||||
ASSERT(m_logical_block_size);
|
||||
ASSERT(offset + count <= block_size());
|
||||
VERIFY(m_logical_block_size);
|
||||
VERIFY(offset + count <= block_size());
|
||||
dbgln_if(BBFS_DEBUG, "BlockBasedFileSystem::read_block {}", index);
|
||||
|
||||
if (!allow_cache) {
|
||||
|
@ -231,7 +231,7 @@ KResult BlockBasedFS::read_block(BlockIndex index, UserOrKernelBuffer* buffer, s
|
|||
auto nread = file_description().read(*buffer, count);
|
||||
if (nread.is_error())
|
||||
return nread.error();
|
||||
ASSERT(nread.value() == count);
|
||||
VERIFY(nread.value() == count);
|
||||
return KSuccess;
|
||||
}
|
||||
|
||||
|
@ -243,7 +243,7 @@ KResult BlockBasedFS::read_block(BlockIndex index, UserOrKernelBuffer* buffer, s
|
|||
auto nread = file_description().read(entry_data_buffer, block_size());
|
||||
if (nread.is_error())
|
||||
return nread.error();
|
||||
ASSERT(nread.value() == block_size());
|
||||
VERIFY(nread.value() == block_size());
|
||||
entry.has_data = true;
|
||||
}
|
||||
if (buffer && !buffer->write(entry.data + offset, count))
|
||||
|
@ -253,7 +253,7 @@ KResult BlockBasedFS::read_block(BlockIndex index, UserOrKernelBuffer* buffer, s
|
|||
|
||||
KResult BlockBasedFS::read_blocks(BlockIndex index, unsigned count, UserOrKernelBuffer& buffer, bool allow_cache) const
|
||||
{
|
||||
ASSERT(m_logical_block_size);
|
||||
VERIFY(m_logical_block_size);
|
||||
if (!count)
|
||||
return EINVAL;
|
||||
if (count == 1)
|
||||
|
|
|
@ -61,7 +61,7 @@ size_t DevFS::allocate_inode_index()
|
|||
{
|
||||
LOCKER(m_lock);
|
||||
m_next_inode_index = m_next_inode_index.value() + 1;
|
||||
ASSERT(m_next_inode_index > 0);
|
||||
VERIFY(m_next_inode_index > 0);
|
||||
return 1 + m_next_inode_index.value();
|
||||
}
|
||||
|
||||
|
@ -102,17 +102,17 @@ DevFSInode::DevFSInode(DevFS& fs)
|
|||
}
|
||||
ssize_t DevFSInode::read_bytes(off_t, ssize_t, UserOrKernelBuffer&, FileDescription*) const
|
||||
{
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
KResult DevFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)>) const
|
||||
{
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
RefPtr<Inode> DevFSInode::lookup(StringView)
|
||||
{
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
void DevFSInode::flush_metadata()
|
||||
|
@ -121,7 +121,7 @@ void DevFSInode::flush_metadata()
|
|||
|
||||
ssize_t DevFSInode::write_bytes(off_t, ssize_t, const UserOrKernelBuffer&, FileDescription*)
|
||||
{
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
KResultOr<NonnullRefPtr<Inode>> DevFSInode::create_child(const String&, mode_t, dev_t, uid_t, gid_t)
|
||||
|
@ -141,7 +141,7 @@ KResult DevFSInode::remove_child(const StringView&)
|
|||
|
||||
KResultOr<size_t> DevFSInode::directory_entry_count() const
|
||||
{
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
KResult DevFSInode::chmod(mode_t)
|
||||
|
@ -174,8 +174,8 @@ DevFSLinkInode::DevFSLinkInode(DevFS& fs, String name)
|
|||
ssize_t DevFSLinkInode::read_bytes(off_t offset, ssize_t, UserOrKernelBuffer& buffer, FileDescription*) const
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
ASSERT(offset == 0);
|
||||
ASSERT(!m_link.is_null());
|
||||
VERIFY(offset == 0);
|
||||
VERIFY(!m_link.is_null());
|
||||
if (!buffer.write(((const u8*)m_link.substring_view(0).characters_without_null_termination()) + offset, m_link.length()))
|
||||
return -EFAULT;
|
||||
return m_link.length();
|
||||
|
@ -195,8 +195,8 @@ InodeMetadata DevFSLinkInode::metadata() const
|
|||
ssize_t DevFSLinkInode::write_bytes(off_t offset, ssize_t count, const UserOrKernelBuffer& buffer, FileDescription*)
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
ASSERT(offset == 0);
|
||||
ASSERT(buffer.is_kernel_buffer());
|
||||
VERIFY(offset == 0);
|
||||
VERIFY(buffer.is_kernel_buffer());
|
||||
m_link = buffer.copy_into_string(count);
|
||||
return count;
|
||||
}
|
||||
|
@ -361,7 +361,7 @@ String DevFSDeviceInode::name() const
|
|||
ssize_t DevFSDeviceInode::read_bytes(off_t offset, ssize_t count, UserOrKernelBuffer& buffer, FileDescription* description) const
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
ASSERT(!!description);
|
||||
VERIFY(!!description);
|
||||
if (!m_attached_device->can_read(*description, offset))
|
||||
return -EIO;
|
||||
auto nread = const_cast<Device&>(*m_attached_device).read(*description, offset, buffer, count);
|
||||
|
@ -387,7 +387,7 @@ InodeMetadata DevFSDeviceInode::metadata() const
|
|||
ssize_t DevFSDeviceInode::write_bytes(off_t offset, ssize_t count, const UserOrKernelBuffer& buffer, FileDescription* description)
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
ASSERT(!!description);
|
||||
VERIFY(!!description);
|
||||
if (!m_attached_device->can_read(*description, offset))
|
||||
return -EIO;
|
||||
auto nread = const_cast<Device&>(*m_attached_device).write(*description, offset, buffer, count);
|
||||
|
|
|
@ -63,7 +63,7 @@ bool DevPtsFS::initialize()
|
|||
|
||||
static unsigned inode_index_to_pty_index(InodeIndex inode_index)
|
||||
{
|
||||
ASSERT(inode_index > 1);
|
||||
VERIFY(inode_index > 1);
|
||||
return inode_index.value() - 2;
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ RefPtr<Inode> DevPtsFS::get_inode(InodeIdentifier inode_id) const
|
|||
|
||||
unsigned pty_index = inode_index_to_pty_index(inode_id.index());
|
||||
auto* device = Device::get_device(201, pty_index);
|
||||
ASSERT(device);
|
||||
VERIFY(device);
|
||||
|
||||
auto inode = adopt(*new DevPtsFSInode(const_cast<DevPtsFS&>(*this), inode_id.index(), static_cast<SlavePTY*>(device)));
|
||||
inode->m_metadata.inode = inode_id;
|
||||
|
@ -122,12 +122,12 @@ DevPtsFSInode::~DevPtsFSInode()
|
|||
|
||||
ssize_t DevPtsFSInode::read_bytes(off_t, ssize_t, UserOrKernelBuffer&, FileDescription*) const
|
||||
{
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
ssize_t DevPtsFSInode::write_bytes(off_t, ssize_t, const UserOrKernelBuffer&, FileDescription*)
|
||||
{
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
InodeMetadata DevPtsFSInode::metadata() const
|
||||
|
@ -159,14 +159,14 @@ KResult DevPtsFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEn
|
|||
|
||||
KResultOr<size_t> DevPtsFSInode::directory_entry_count() const
|
||||
{
|
||||
ASSERT(identifier().index() == 1);
|
||||
VERIFY(identifier().index() == 1);
|
||||
|
||||
return 2 + s_ptys->size();
|
||||
}
|
||||
|
||||
RefPtr<Inode> DevPtsFSInode::lookup(StringView name)
|
||||
{
|
||||
ASSERT(identifier().index() == 1);
|
||||
VERIFY(identifier().index() == 1);
|
||||
|
||||
if (name == "." || name == "..")
|
||||
return this;
|
||||
|
|
|
@ -91,28 +91,28 @@ Ext2FS::~Ext2FS()
|
|||
bool Ext2FS::flush_super_block()
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
ASSERT((sizeof(ext2_super_block) % logical_block_size()) == 0);
|
||||
VERIFY((sizeof(ext2_super_block) % logical_block_size()) == 0);
|
||||
auto super_block_buffer = UserOrKernelBuffer::for_kernel_buffer((u8*)&m_super_block);
|
||||
bool success = raw_write_blocks(2, (sizeof(ext2_super_block) / logical_block_size()), super_block_buffer);
|
||||
ASSERT(success);
|
||||
VERIFY(success);
|
||||
return true;
|
||||
}
|
||||
|
||||
const ext2_group_desc& Ext2FS::group_descriptor(GroupIndex group_index) const
|
||||
{
|
||||
// FIXME: Should this fail gracefully somehow?
|
||||
ASSERT(group_index <= m_block_group_count);
|
||||
ASSERT(group_index > 0);
|
||||
VERIFY(group_index <= m_block_group_count);
|
||||
VERIFY(group_index > 0);
|
||||
return block_group_descriptors()[group_index.value() - 1];
|
||||
}
|
||||
|
||||
bool Ext2FS::initialize()
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
ASSERT((sizeof(ext2_super_block) % logical_block_size()) == 0);
|
||||
VERIFY((sizeof(ext2_super_block) % logical_block_size()) == 0);
|
||||
auto super_block_buffer = UserOrKernelBuffer::for_kernel_buffer((u8*)&m_super_block);
|
||||
bool success = raw_read_blocks(2, (sizeof(ext2_super_block) / logical_block_size()), super_block_buffer);
|
||||
ASSERT(success);
|
||||
VERIFY(success);
|
||||
|
||||
auto& super_block = this->super_block();
|
||||
if constexpr (EXT2_DEBUG) {
|
||||
|
@ -134,7 +134,7 @@ bool Ext2FS::initialize()
|
|||
|
||||
set_block_size(EXT2_BLOCK_SIZE(&super_block));
|
||||
|
||||
ASSERT(block_size() <= (int)max_block_size);
|
||||
VERIFY(block_size() <= (int)max_block_size);
|
||||
|
||||
m_block_group_count = ceil_div(super_block.s_blocks_count, super_block.s_blocks_per_group);
|
||||
|
||||
|
@ -227,7 +227,7 @@ Ext2FS::BlockListShape Ext2FS::compute_block_list_shape(unsigned blocks) const
|
|||
shape.meta_blocks += divide_rounded_up(shape.triply_indirect_blocks, entries_per_block * entries_per_block);
|
||||
shape.meta_blocks += divide_rounded_up(shape.triply_indirect_blocks, entries_per_block);
|
||||
blocks_remaining -= shape.triply_indirect_blocks;
|
||||
ASSERT(blocks_remaining == 0);
|
||||
VERIFY(blocks_remaining == 0);
|
||||
return shape;
|
||||
}
|
||||
|
||||
|
@ -302,7 +302,7 @@ KResult Ext2FS::write_block_list_for_inode(InodeIndex inode_index, ext2_inode& e
|
|||
auto block_contents = ByteBuffer::create_uninitialized(block_size());
|
||||
OutputMemoryStream stream { block_contents };
|
||||
|
||||
ASSERT(new_shape.indirect_blocks <= entries_per_block);
|
||||
VERIFY(new_shape.indirect_blocks <= entries_per_block);
|
||||
for (unsigned i = 0; i < new_shape.indirect_blocks; ++i) {
|
||||
stream << blocks[output_block_index++].value();
|
||||
--remaining_blocks;
|
||||
|
@ -355,7 +355,7 @@ KResult Ext2FS::write_block_list_for_inode(InodeIndex inode_index, ext2_inode& e
|
|||
}
|
||||
auto* dind_block_as_pointers = (unsigned*)dind_block_contents.data();
|
||||
|
||||
ASSERT(indirect_block_count <= entries_per_block);
|
||||
VERIFY(indirect_block_count <= entries_per_block);
|
||||
for (unsigned i = 0; i < indirect_block_count; ++i) {
|
||||
bool ind_block_dirty = false;
|
||||
|
||||
|
@ -386,7 +386,7 @@ KResult Ext2FS::write_block_list_for_inode(InodeIndex inode_index, ext2_inode& e
|
|||
if (entries_to_write > entries_per_block)
|
||||
entries_to_write = entries_per_block;
|
||||
|
||||
ASSERT(entries_to_write <= entries_per_block);
|
||||
VERIFY(entries_to_write <= entries_per_block);
|
||||
for (unsigned j = 0; j < entries_to_write; ++j) {
|
||||
BlockIndex output_block = blocks[output_block_index++];
|
||||
if (ind_block_as_pointers[j] != output_block) {
|
||||
|
@ -405,7 +405,7 @@ KResult Ext2FS::write_block_list_for_inode(InodeIndex inode_index, ext2_inode& e
|
|||
if (ind_block_dirty) {
|
||||
auto buffer = UserOrKernelBuffer::for_kernel_buffer(ind_block_contents.data());
|
||||
int err = write_block(indirect_block_index, buffer, block_size());
|
||||
ASSERT(err >= 0);
|
||||
VERIFY(err >= 0);
|
||||
}
|
||||
}
|
||||
for (unsigned i = indirect_block_count; i < entries_per_block; ++i) {
|
||||
|
@ -418,7 +418,7 @@ KResult Ext2FS::write_block_list_for_inode(InodeIndex inode_index, ext2_inode& e
|
|||
if (dind_block_dirty) {
|
||||
auto buffer = UserOrKernelBuffer::for_kernel_buffer(dind_block_contents.data());
|
||||
int err = write_block(e2inode.i_block[EXT2_DIND_BLOCK], buffer, block_size());
|
||||
ASSERT(err >= 0);
|
||||
VERIFY(err >= 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -427,7 +427,7 @@ KResult Ext2FS::write_block_list_for_inode(InodeIndex inode_index, ext2_inode& e
|
|||
|
||||
// FIXME: Implement!
|
||||
dbgln("we don't know how to write tind ext2fs blocks yet!");
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
Vector<Ext2FS::BlockIndex> Ext2FS::block_list_for_inode(const ext2_inode& e2inode, bool include_block_list_blocks) const
|
||||
|
@ -536,13 +536,13 @@ Vector<Ext2FS::BlockIndex> Ext2FS::block_list_for_inode_impl(const ext2_inode& e
|
|||
void Ext2FS::free_inode(Ext2FSInode& inode)
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
ASSERT(inode.m_raw_inode.i_links_count == 0);
|
||||
VERIFY(inode.m_raw_inode.i_links_count == 0);
|
||||
dbgln_if(EXT2_DEBUG, "Ext2FS: Inode {} has no more links, time to delete!", inode.index());
|
||||
|
||||
// Mark all blocks used by this inode as free.
|
||||
auto block_list = block_list_for_inode(inode.m_raw_inode, true);
|
||||
for (auto block_index : block_list) {
|
||||
ASSERT(block_index <= super_block().s_blocks_count);
|
||||
VERIFY(block_index <= super_block().s_blocks_count);
|
||||
if (block_index.value())
|
||||
set_block_allocation_state(block_index, false);
|
||||
}
|
||||
|
@ -674,7 +674,7 @@ void Ext2FSInode::flush_metadata()
|
|||
RefPtr<Inode> Ext2FS::get_inode(InodeIdentifier inode) const
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
ASSERT(inode.fsid() == fsid());
|
||||
VERIFY(inode.fsid() == fsid());
|
||||
|
||||
{
|
||||
auto it = m_inode_cache.find(inode.index());
|
||||
|
@ -706,14 +706,14 @@ RefPtr<Inode> Ext2FS::get_inode(InodeIdentifier inode) const
|
|||
ssize_t Ext2FSInode::read_bytes(off_t offset, ssize_t count, UserOrKernelBuffer& buffer, FileDescription* description) const
|
||||
{
|
||||
Locker inode_locker(m_lock);
|
||||
ASSERT(offset >= 0);
|
||||
VERIFY(offset >= 0);
|
||||
if (m_raw_inode.i_size == 0)
|
||||
return 0;
|
||||
|
||||
// Symbolic links shorter than 60 characters are store inline inside the i_block array.
|
||||
// This avoids wasting an entire block on short links. (Most links are short.)
|
||||
if (is_symlink() && size() < max_inline_symlink_length) {
|
||||
ASSERT(offset == 0);
|
||||
VERIFY(offset == 0);
|
||||
ssize_t nread = min((off_t)size() - offset, static_cast<off_t>(count));
|
||||
if (!buffer.write(((const u8*)m_raw_inode.i_block) + offset, (size_t)nread))
|
||||
return -EFAULT;
|
||||
|
@ -748,7 +748,7 @@ ssize_t Ext2FSInode::read_bytes(off_t offset, ssize_t count, UserOrKernelBuffer&
|
|||
|
||||
for (size_t bi = first_block_logical_index; remaining_count && bi <= last_block_logical_index; ++bi) {
|
||||
auto block_index = m_block_list[bi];
|
||||
ASSERT(block_index.value());
|
||||
VERIFY(block_index.value());
|
||||
size_t offset_into_block = (bi == first_block_logical_index) ? offset_into_first_block : 0;
|
||||
size_t num_bytes_to_copy = min(block_size - offset_into_block, remaining_count);
|
||||
auto buffer_offset = buffer.offset(nread);
|
||||
|
@ -827,7 +827,7 @@ KResult Ext2FSInode::resize(u64 new_size)
|
|||
auto nwritten = write_bytes(clear_from, min(sizeof(zero_buffer), bytes_to_clear), UserOrKernelBuffer::for_kernel_buffer(zero_buffer), nullptr);
|
||||
if (nwritten < 0)
|
||||
return KResult((ErrnoCode)-nwritten);
|
||||
ASSERT(nwritten != 0);
|
||||
VERIFY(nwritten != 0);
|
||||
bytes_to_clear -= nwritten;
|
||||
clear_from += nwritten;
|
||||
}
|
||||
|
@ -838,8 +838,8 @@ KResult Ext2FSInode::resize(u64 new_size)
|
|||
|
||||
ssize_t Ext2FSInode::write_bytes(off_t offset, ssize_t count, const UserOrKernelBuffer& data, FileDescription* description)
|
||||
{
|
||||
ASSERT(offset >= 0);
|
||||
ASSERT(count >= 0);
|
||||
VERIFY(offset >= 0);
|
||||
VERIFY(count >= 0);
|
||||
|
||||
Locker inode_locker(m_lock);
|
||||
Locker fs_locker(fs().m_lock);
|
||||
|
@ -849,7 +849,7 @@ ssize_t Ext2FSInode::write_bytes(off_t offset, ssize_t count, const UserOrKernel
|
|||
return result;
|
||||
|
||||
if (is_symlink()) {
|
||||
ASSERT(offset == 0);
|
||||
VERIFY(offset == 0);
|
||||
if (max((size_t)(offset + count), (size_t)m_raw_inode.i_size) < max_inline_symlink_length) {
|
||||
dbgln_if(EXT2_DEBUG, "Ext2FS: write_bytes poking into i_block array for inline symlink '{}' ({} bytes)", data.copy_into_string(count), count);
|
||||
if (!data.read(((u8*)m_raw_inode.i_block) + offset, (size_t)count))
|
||||
|
@ -937,7 +937,7 @@ u8 Ext2FS::internal_file_type_to_directory_entry_type(const DirectoryEntryView&
|
|||
KResult Ext2FSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)> callback) const
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
ASSERT(is_directory());
|
||||
VERIFY(is_directory());
|
||||
|
||||
dbgln_if(EXT2_VERY_DEBUG, "Ext2FS: Traversing as directory: {}", index());
|
||||
|
||||
|
@ -1020,7 +1020,7 @@ KResultOr<NonnullRefPtr<Inode>> Ext2FSInode::create_child(const String& name, mo
|
|||
KResult Ext2FSInode::add_child(Inode& child, const StringView& name, mode_t mode)
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
ASSERT(is_directory());
|
||||
VERIFY(is_directory());
|
||||
|
||||
if (name.length() > EXT2_NAME_LEN)
|
||||
return ENAMETOOLONG;
|
||||
|
@ -1064,7 +1064,7 @@ KResult Ext2FSInode::remove_child(const StringView& name)
|
|||
{
|
||||
LOCKER(m_lock);
|
||||
dbgln_if(EXT2_DEBUG, "Ext2FSInode::remove_child('{}') in inode {}", name, index());
|
||||
ASSERT(is_directory());
|
||||
VERIFY(is_directory());
|
||||
|
||||
auto it = m_lookup_cache.find(name);
|
||||
if (it == m_lookup_cache.end())
|
||||
|
@ -1162,7 +1162,7 @@ auto Ext2FS::allocate_blocks(GroupIndex preferred_group_index, size_t count) ->
|
|||
}
|
||||
}
|
||||
|
||||
ASSERT(found_a_group);
|
||||
VERIFY(found_a_group);
|
||||
auto& bgd = group_descriptor(group_index);
|
||||
auto& cached_bitmap = get_bitmap_block(bgd.bg_block_bitmap);
|
||||
|
||||
|
@ -1172,7 +1172,7 @@ auto Ext2FS::allocate_blocks(GroupIndex preferred_group_index, size_t count) ->
|
|||
BlockIndex first_block_in_group = (group_index.value() - 1) * blocks_per_group() + first_block_index().value();
|
||||
size_t free_region_size = 0;
|
||||
auto first_unset_bit_index = block_bitmap.find_longest_range_of_unset_bits(count - blocks.size(), free_region_size);
|
||||
ASSERT(first_unset_bit_index.has_value());
|
||||
VERIFY(first_unset_bit_index.has_value());
|
||||
dbgln_if(EXT2_DEBUG, "Ext2FS: allocating free region of size: {} [{}]", free_region_size, group_index);
|
||||
for (size_t i = 0; i < free_region_size; ++i) {
|
||||
BlockIndex block_index = (first_unset_bit_index.value() + i) + first_block_in_group.value();
|
||||
|
@ -1182,7 +1182,7 @@ auto Ext2FS::allocate_blocks(GroupIndex preferred_group_index, size_t count) ->
|
|||
}
|
||||
}
|
||||
|
||||
ASSERT(blocks.size() == count);
|
||||
VERIFY(blocks.size() == count);
|
||||
return blocks;
|
||||
}
|
||||
|
||||
|
@ -1239,7 +1239,7 @@ InodeIndex Ext2FS::find_a_free_inode(GroupIndex preferred_group)
|
|||
InodeIndex inode = first_free_inode_in_group;
|
||||
dbgln_if(EXT2_DEBUG, "Ext2FS: found suitable inode {}", inode);
|
||||
|
||||
ASSERT(get_inode_allocation_state(inode) == false);
|
||||
VERIFY(get_inode_allocation_state(inode) == false);
|
||||
return inode;
|
||||
}
|
||||
|
||||
|
@ -1285,7 +1285,7 @@ bool Ext2FS::set_inode_allocation_state(InodeIndex inode_index, bool new_state)
|
|||
dbgln_if(EXT2_DEBUG, "Ext2FS: set_inode_allocation_state({}) {} -> {}", inode_index, current_state, new_state);
|
||||
|
||||
if (current_state == new_state) {
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1325,14 +1325,14 @@ Ext2FS::CachedBitmap& Ext2FS::get_bitmap_block(BlockIndex bitmap_block_index)
|
|||
auto block = KBuffer::create_with_size(block_size(), Region::Access::Read | Region::Access::Write, "Ext2FS: Cached bitmap block");
|
||||
auto buffer = UserOrKernelBuffer::for_kernel_buffer(block.data());
|
||||
int err = read_block(bitmap_block_index, &buffer, block_size());
|
||||
ASSERT(err >= 0);
|
||||
VERIFY(err >= 0);
|
||||
m_cached_bitmaps.append(make<CachedBitmap>(bitmap_block_index, move(block)));
|
||||
return *m_cached_bitmaps.last();
|
||||
}
|
||||
|
||||
bool Ext2FS::set_block_allocation_state(BlockIndex block_index, bool new_state)
|
||||
{
|
||||
ASSERT(block_index != 0);
|
||||
VERIFY(block_index != 0);
|
||||
LOCKER(m_lock);
|
||||
|
||||
auto group_index = group_index_from_block_index(block_index);
|
||||
|
@ -1346,7 +1346,7 @@ bool Ext2FS::set_block_allocation_state(BlockIndex block_index, bool new_state)
|
|||
dbgln_if(EXT2_DEBUG, "Ext2FS: block {} state: {} -> {} (in bitmap block {})", block_index, current_state, new_state, bgd.bg_block_bitmap);
|
||||
|
||||
if (current_state == new_state) {
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1374,7 +1374,7 @@ bool Ext2FS::set_block_allocation_state(BlockIndex block_index, bool new_state)
|
|||
KResult Ext2FS::create_directory(Ext2FSInode& parent_inode, const String& name, mode_t mode, uid_t uid, gid_t gid)
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
ASSERT(is_directory(mode));
|
||||
VERIFY(is_directory(mode));
|
||||
|
||||
auto inode_or_error = create_inode(parent_inode, name, mode, 0, uid, gid);
|
||||
if (inode_or_error.is_error())
|
||||
|
@ -1424,7 +1424,7 @@ KResultOr<NonnullRefPtr<Inode>> Ext2FS::create_inode(Ext2FSInode& parent_inode,
|
|||
|
||||
// Looks like we're good, time to update the inode bitmap and group+global inode counters.
|
||||
bool success = set_inode_allocation_state(inode_id, true);
|
||||
ASSERT(success);
|
||||
VERIFY(success);
|
||||
|
||||
struct timeval now;
|
||||
kgettimeofday(now);
|
||||
|
@ -1450,7 +1450,7 @@ KResultOr<NonnullRefPtr<Inode>> Ext2FS::create_inode(Ext2FSInode& parent_inode,
|
|||
|
||||
e2inode.i_flags = 0;
|
||||
success = write_ext2_inode(inode_id, e2inode);
|
||||
ASSERT(success);
|
||||
VERIFY(success);
|
||||
|
||||
// We might have cached the fact that this inode didn't exist. Wipe the slate.
|
||||
m_inode_cache.remove(inode_id);
|
||||
|
@ -1487,7 +1487,7 @@ bool Ext2FSInode::populate_lookup_cache() const
|
|||
|
||||
RefPtr<Inode> Ext2FSInode::lookup(StringView name)
|
||||
{
|
||||
ASSERT(is_directory());
|
||||
VERIFY(is_directory());
|
||||
if (!populate_lookup_cache())
|
||||
return {};
|
||||
LOCKER(m_lock);
|
||||
|
@ -1549,7 +1549,7 @@ KResult Ext2FSInode::decrement_link_count()
|
|||
LOCKER(m_lock);
|
||||
if (fs().is_readonly())
|
||||
return EROFS;
|
||||
ASSERT(m_raw_inode.i_links_count);
|
||||
VERIFY(m_raw_inode.i_links_count);
|
||||
--m_raw_inode.i_links_count;
|
||||
if (ref_count() == 1 && m_raw_inode.i_links_count == 0)
|
||||
fs().uncache_inode(index());
|
||||
|
@ -1565,7 +1565,7 @@ void Ext2FS::uncache_inode(InodeIndex index)
|
|||
|
||||
KResultOr<size_t> Ext2FSInode::directory_entry_count() const
|
||||
{
|
||||
ASSERT(is_directory());
|
||||
VERIFY(is_directory());
|
||||
LOCKER(m_lock);
|
||||
populate_lookup_cache();
|
||||
return m_lookup_cache.size();
|
||||
|
|
|
@ -134,13 +134,13 @@ void FIFO::detach(Direction direction)
|
|||
#if FIFO_DEBUG
|
||||
klog() << "close reader (" << m_readers << " - 1)";
|
||||
#endif
|
||||
ASSERT(m_readers);
|
||||
VERIFY(m_readers);
|
||||
--m_readers;
|
||||
} else if (direction == Direction::Writer) {
|
||||
#if FIFO_DEBUG
|
||||
klog() << "close writer (" << m_writers << " - 1)";
|
||||
#endif
|
||||
ASSERT(m_writers);
|
||||
VERIFY(m_writers);
|
||||
--m_writers;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
|
||||
virtual bool should_add_blocker(Thread::Blocker& b, void* data) override
|
||||
{
|
||||
ASSERT(b.blocker_type() == Thread::Blocker::Type::File);
|
||||
VERIFY(b.blocker_type() == Thread::Blocker::Type::File);
|
||||
auto& blocker = static_cast<Thread::FileBlocker&>(b);
|
||||
return !blocker.unblock(true, data);
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public:
|
|||
{
|
||||
ScopedSpinLock lock(m_lock);
|
||||
do_unblock([&](auto& b, void* data, bool&) {
|
||||
ASSERT(b.blocker_type() == Thread::Blocker::Type::File);
|
||||
VERIFY(b.blocker_type() == Thread::Blocker::Type::File);
|
||||
auto& blocker = static_cast<Thread::FileBlocker&>(b);
|
||||
return blocker.unblock(false, data);
|
||||
});
|
||||
|
@ -159,7 +159,7 @@ protected:
|
|||
private:
|
||||
ALWAYS_INLINE void do_evaluate_block_conditions()
|
||||
{
|
||||
ASSERT(!Processor::current().in_irq());
|
||||
VERIFY(!Processor::current().in_irq());
|
||||
block_condition().unblock();
|
||||
}
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ Thread::FileBlocker::BlockFlags FileDescription::should_unblock(Thread::FileBloc
|
|||
|
||||
if ((u32)block_flags & (u32)Thread::FileBlocker::BlockFlags::SocketFlags) {
|
||||
auto* sock = socket();
|
||||
ASSERT(sock);
|
||||
VERIFY(sock);
|
||||
if (((u32)block_flags & (u32)Thread::FileBlocker::BlockFlags::Accept) && sock->can_accept())
|
||||
unblock_flags |= (u32)Thread::FileBlocker::BlockFlags::Accept;
|
||||
if (((u32)block_flags & (u32)Thread::FileBlocker::BlockFlags::Connect) && sock->setup_state() == Socket::SetupState::Completed)
|
||||
|
@ -205,8 +205,8 @@ bool FileDescription::can_read() const
|
|||
KResultOr<NonnullOwnPtr<KBuffer>> FileDescription::read_entire_file()
|
||||
{
|
||||
// HACK ALERT: (This entire function)
|
||||
ASSERT(m_file->is_inode());
|
||||
ASSERT(m_inode);
|
||||
VERIFY(m_file->is_inode());
|
||||
VERIFY(m_inode);
|
||||
return m_inode->read_entire(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ void FS::lock_all()
|
|||
|
||||
void FS::set_block_size(size_t block_size)
|
||||
{
|
||||
ASSERT(block_size > 0);
|
||||
VERIFY(block_size > 0);
|
||||
if (block_size == m_block_size)
|
||||
return;
|
||||
m_block_size = block_size;
|
||||
|
|
|
@ -49,7 +49,7 @@ SpinLock<u32>& Inode::all_inodes_lock()
|
|||
|
||||
InlineLinkedList<Inode>& Inode::all_with_lock()
|
||||
{
|
||||
ASSERT(s_all_inodes_lock.is_locked());
|
||||
VERIFY(s_all_inodes_lock.is_locked());
|
||||
|
||||
return *s_list;
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ void Inode::sync()
|
|||
}
|
||||
|
||||
for (auto& inode : inodes) {
|
||||
ASSERT(inode.is_metadata_dirty());
|
||||
VERIFY(inode.is_metadata_dirty());
|
||||
inode.flush_metadata();
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ KResultOr<NonnullOwnPtr<KBuffer>> Inode::read_entire(FileDescription* descriptio
|
|||
nread = read_bytes(offset, sizeof(buffer), buf, description);
|
||||
if (nread < 0)
|
||||
return KResult((ErrnoCode)-nread);
|
||||
ASSERT(nread <= (ssize_t)sizeof(buffer));
|
||||
VERIFY(nread <= (ssize_t)sizeof(buffer));
|
||||
if (nread <= 0)
|
||||
break;
|
||||
builder.append((const char*)buffer, nread);
|
||||
|
@ -203,27 +203,27 @@ bool Inode::unbind_socket()
|
|||
void Inode::register_watcher(Badge<InodeWatcher>, InodeWatcher& watcher)
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
ASSERT(!m_watchers.contains(&watcher));
|
||||
VERIFY(!m_watchers.contains(&watcher));
|
||||
m_watchers.set(&watcher);
|
||||
}
|
||||
|
||||
void Inode::unregister_watcher(Badge<InodeWatcher>, InodeWatcher& watcher)
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
ASSERT(m_watchers.contains(&watcher));
|
||||
VERIFY(m_watchers.contains(&watcher));
|
||||
m_watchers.remove(&watcher);
|
||||
}
|
||||
|
||||
NonnullRefPtr<FIFO> Inode::fifo()
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
ASSERT(metadata().is_fifo());
|
||||
VERIFY(metadata().is_fifo());
|
||||
|
||||
// FIXME: Release m_fifo when it is closed by all readers and writers
|
||||
if (!m_fifo)
|
||||
m_fifo = FIFO::create(metadata().uid);
|
||||
|
||||
ASSERT(m_fifo);
|
||||
VERIFY(m_fifo);
|
||||
return *m_fifo;
|
||||
}
|
||||
|
||||
|
@ -233,7 +233,7 @@ void Inode::set_metadata_dirty(bool metadata_dirty)
|
|||
|
||||
if (metadata_dirty) {
|
||||
// Sanity check.
|
||||
ASSERT(!fs().is_readonly());
|
||||
VERIFY(!fs().is_readonly());
|
||||
}
|
||||
|
||||
if (m_metadata_dirty == metadata_dirty)
|
||||
|
|
|
@ -122,8 +122,8 @@ KResultOr<Region*> InodeFile::mmap(Process& process, FileDescription& descriptio
|
|||
|
||||
String InodeFile::absolute_path(const FileDescription& description) const
|
||||
{
|
||||
ASSERT_NOT_REACHED();
|
||||
ASSERT(description.custody());
|
||||
VERIFY_NOT_REACHED();
|
||||
VERIFY(description.custody());
|
||||
return description.absolute_path();
|
||||
}
|
||||
|
||||
|
@ -140,15 +140,15 @@ KResult InodeFile::truncate(u64 size)
|
|||
|
||||
KResult InodeFile::chown(FileDescription& description, uid_t uid, gid_t gid)
|
||||
{
|
||||
ASSERT(description.inode() == m_inode);
|
||||
ASSERT(description.custody());
|
||||
VERIFY(description.inode() == m_inode);
|
||||
VERIFY(description.custody());
|
||||
return VFS::the().chown(*description.custody(), uid, gid);
|
||||
}
|
||||
|
||||
KResult InodeFile::chmod(FileDescription& description, mode_t mode)
|
||||
{
|
||||
ASSERT(description.inode() == m_inode);
|
||||
ASSERT(description.custody());
|
||||
VERIFY(description.inode() == m_inode);
|
||||
VERIFY(description.custody());
|
||||
return VFS::the().chmod(*description.custody(), mode);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ bool InodeWatcher::can_write(const FileDescription&, size_t) const
|
|||
KResultOr<size_t> InodeWatcher::read(FileDescription&, size_t, UserOrKernelBuffer& buffer, size_t buffer_size)
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
ASSERT(!m_queue.is_empty() || !m_inode);
|
||||
VERIFY(!m_queue.is_empty() || !m_inode);
|
||||
|
||||
if (!m_inode)
|
||||
return 0;
|
||||
|
|
|
@ -44,7 +44,7 @@ Plan9FS::~Plan9FS()
|
|||
{
|
||||
// Make sure to destroy the root inode before the FS gets destroyed.
|
||||
if (m_root_inode) {
|
||||
ASSERT(m_root_inode->ref_count() == 1);
|
||||
VERIFY(m_root_inode->ref_count() == 1);
|
||||
m_root_inode = nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ public:
|
|||
template<typename N>
|
||||
Decoder& read_number(N& number)
|
||||
{
|
||||
ASSERT(sizeof(number) <= m_data.length());
|
||||
VERIFY(sizeof(number) <= m_data.length());
|
||||
memcpy(&number, m_data.characters_without_null_termination(), sizeof(number));
|
||||
m_data = m_data.substring_view(sizeof(number), m_data.length() - sizeof(number));
|
||||
return *this;
|
||||
|
@ -170,14 +170,14 @@ public:
|
|||
template<typename T>
|
||||
Message& operator>>(T& t)
|
||||
{
|
||||
ASSERT(m_have_been_built);
|
||||
VERIFY(m_have_been_built);
|
||||
m_built.decoder >> t;
|
||||
return *this;
|
||||
}
|
||||
|
||||
StringView read_data()
|
||||
{
|
||||
ASSERT(m_have_been_built);
|
||||
VERIFY(m_have_been_built);
|
||||
return m_built.decoder.read_data();
|
||||
}
|
||||
|
||||
|
@ -197,7 +197,7 @@ private:
|
|||
template<typename N>
|
||||
Message& append_number(N number)
|
||||
{
|
||||
ASSERT(!m_have_been_built);
|
||||
VERIFY(!m_have_been_built);
|
||||
m_builder.append(reinterpret_cast<const char*>(&number), sizeof(number));
|
||||
return *this;
|
||||
}
|
||||
|
@ -330,7 +330,7 @@ Plan9FS::Message::Decoder& Plan9FS::Message::Decoder::operator>>(StringView& str
|
|||
{
|
||||
u16 length;
|
||||
*this >> length;
|
||||
ASSERT(length <= m_data.length());
|
||||
VERIFY(length <= m_data.length());
|
||||
string = m_data.substring_view(0, length);
|
||||
m_data = m_data.substring_view_starting_after_substring(string);
|
||||
return *this;
|
||||
|
@ -340,7 +340,7 @@ StringView Plan9FS::Message::Decoder::read_data()
|
|||
{
|
||||
u32 length;
|
||||
*this >> length;
|
||||
ASSERT(length <= m_data.length());
|
||||
VERIFY(length <= m_data.length());
|
||||
auto data = m_data.substring_view(0, length);
|
||||
m_data = m_data.substring_view_starting_after_substring(data);
|
||||
return data;
|
||||
|
@ -401,12 +401,12 @@ Plan9FS::Message& Plan9FS::Message::operator=(Message&& message)
|
|||
|
||||
const KBuffer& Plan9FS::Message::build()
|
||||
{
|
||||
ASSERT(!m_have_been_built);
|
||||
VERIFY(!m_have_been_built);
|
||||
|
||||
auto tmp_buffer = m_builder.build();
|
||||
|
||||
// FIXME: We should not assume success here.
|
||||
ASSERT(tmp_buffer);
|
||||
VERIFY(tmp_buffer);
|
||||
|
||||
m_have_been_built = true;
|
||||
m_builder.~KBufferBuilder();
|
||||
|
@ -470,7 +470,7 @@ bool Plan9FS::Plan9FSBlockCondition::should_add_blocker(Thread::Blocker& b, void
|
|||
void Plan9FS::Plan9FSBlockCondition::unblock_completed(u16 tag)
|
||||
{
|
||||
unblock([&](Thread::Blocker& b, void*, bool&) {
|
||||
ASSERT(b.blocker_type() == Thread::Blocker::Type::Plan9FS);
|
||||
VERIFY(b.blocker_type() == Thread::Blocker::Type::Plan9FS);
|
||||
auto& blocker = static_cast<Blocker&>(b);
|
||||
return blocker.unblock(tag);
|
||||
});
|
||||
|
@ -479,7 +479,7 @@ void Plan9FS::Plan9FSBlockCondition::unblock_completed(u16 tag)
|
|||
void Plan9FS::Plan9FSBlockCondition::unblock_all()
|
||||
{
|
||||
unblock([&](Thread::Blocker& b, void*, bool&) {
|
||||
ASSERT(b.blocker_type() == Thread::Blocker::Type::Plan9FS);
|
||||
VERIFY(b.blocker_type() == Thread::Blocker::Type::Plan9FS);
|
||||
auto& blocker = static_cast<Blocker&>(b);
|
||||
return blocker.unblock();
|
||||
});
|
||||
|
@ -498,13 +498,13 @@ bool Plan9FS::is_complete(const ReceiveCompletion& completion)
|
|||
LOCKER(m_lock);
|
||||
if (m_completions.contains(completion.tag)) {
|
||||
// If it's still in the map then it can't be complete
|
||||
ASSERT(!completion.completed);
|
||||
VERIFY(!completion.completed);
|
||||
return false;
|
||||
}
|
||||
|
||||
// if it's not in the map anymore, it must be complete. But we MUST
|
||||
// hold m_lock to be able to check completion.completed!
|
||||
ASSERT(completion.completed);
|
||||
VERIFY(completion.completed);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -150,14 +150,14 @@ static inline ProcFileType to_proc_file_type(const InodeIdentifier& identifier)
|
|||
|
||||
static inline int to_fd(const InodeIdentifier& identifier)
|
||||
{
|
||||
ASSERT(to_proc_parent_directory(identifier) == PDI_PID_fd);
|
||||
VERIFY(to_proc_parent_directory(identifier) == PDI_PID_fd);
|
||||
return (identifier.index().value() & 0xff) - FI_MaxStaticFileIndex;
|
||||
}
|
||||
|
||||
static inline size_t to_sys_index(const InodeIdentifier& identifier)
|
||||
{
|
||||
ASSERT(to_proc_parent_directory(identifier) == PDI_Root_sys);
|
||||
ASSERT(to_proc_file_type(identifier) == FI_Root_sys_variable);
|
||||
VERIFY(to_proc_parent_directory(identifier) == PDI_Root_sys);
|
||||
VERIFY(to_proc_file_type(identifier) == FI_Root_sys_variable);
|
||||
return identifier.index().value() >> 16u;
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ static inline InodeIdentifier to_identifier_with_stack(unsigned fsid, ThreadID t
|
|||
|
||||
static inline InodeIdentifier sys_var_to_identifier(unsigned fsid, unsigned index)
|
||||
{
|
||||
ASSERT(index < 256);
|
||||
VERIFY(index < 256);
|
||||
return { fsid, (PDI_Root_sys << 12u) | (index << 16u) | FI_Root_sys_variable };
|
||||
}
|
||||
|
||||
|
@ -199,7 +199,7 @@ static inline InodeIdentifier to_parent_id(const InodeIdentifier& identifier)
|
|||
case PDI_PID_stacks:
|
||||
return to_identifier(identifier.fsid(), PDI_PID, to_pid(identifier), FI_PID_stacks);
|
||||
}
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
@ -436,7 +436,7 @@ static bool procfs$devices(InodeIdentifier, KBufferBuilder& builder)
|
|||
else if (device.is_character_device())
|
||||
obj.add("type", "character");
|
||||
else
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
});
|
||||
array.finish();
|
||||
return true;
|
||||
|
@ -633,7 +633,7 @@ static bool procfs$pid_exe(InodeIdentifier identifier, KBufferBuilder& builder)
|
|||
if (!process)
|
||||
return false;
|
||||
auto* custody = process->executable();
|
||||
ASSERT(custody);
|
||||
VERIFY(custody);
|
||||
builder.append(custody->absolute_path().bytes());
|
||||
return true;
|
||||
}
|
||||
|
@ -884,14 +884,14 @@ SysVariable& SysVariable::for_inode(InodeIdentifier id)
|
|||
if (index >= sys_variables().size())
|
||||
return sys_variables()[0];
|
||||
auto& variable = sys_variables()[index];
|
||||
ASSERT(variable.address);
|
||||
VERIFY(variable.address);
|
||||
return variable;
|
||||
}
|
||||
|
||||
static bool read_sys_bool(InodeIdentifier inode_id, KBufferBuilder& builder)
|
||||
{
|
||||
auto& variable = SysVariable::for_inode(inode_id);
|
||||
ASSERT(variable.type == SysVariable::Type::Boolean);
|
||||
VERIFY(variable.type == SysVariable::Type::Boolean);
|
||||
|
||||
u8 buffer[2];
|
||||
auto* lockable_bool = reinterpret_cast<Lockable<bool>*>(variable.address);
|
||||
|
@ -907,7 +907,7 @@ static bool read_sys_bool(InodeIdentifier inode_id, KBufferBuilder& builder)
|
|||
static ssize_t write_sys_bool(InodeIdentifier inode_id, const UserOrKernelBuffer& buffer, size_t size)
|
||||
{
|
||||
auto& variable = SysVariable::for_inode(inode_id);
|
||||
ASSERT(variable.type == SysVariable::Type::Boolean);
|
||||
VERIFY(variable.type == SysVariable::Type::Boolean);
|
||||
|
||||
char value = 0;
|
||||
bool did_read = false;
|
||||
|
@ -920,7 +920,7 @@ static ssize_t write_sys_bool(InodeIdentifier inode_id, const UserOrKernelBuffer
|
|||
});
|
||||
if (nread < 0)
|
||||
return nread;
|
||||
ASSERT(nread == 0 || (nread == 1 && did_read));
|
||||
VERIFY(nread == 0 || (nread == 1 && did_read));
|
||||
if (nread == 0 || !(value == '0' || value == '1'))
|
||||
return (ssize_t)size;
|
||||
|
||||
|
@ -936,7 +936,7 @@ static ssize_t write_sys_bool(InodeIdentifier inode_id, const UserOrKernelBuffer
|
|||
static bool read_sys_string(InodeIdentifier inode_id, KBufferBuilder& builder)
|
||||
{
|
||||
auto& variable = SysVariable::for_inode(inode_id);
|
||||
ASSERT(variable.type == SysVariable::Type::String);
|
||||
VERIFY(variable.type == SysVariable::Type::String);
|
||||
|
||||
auto* lockable_string = reinterpret_cast<Lockable<String>*>(variable.address);
|
||||
LOCKER(lockable_string->lock(), Lock::Mode::Shared);
|
||||
|
@ -947,7 +947,7 @@ static bool read_sys_string(InodeIdentifier inode_id, KBufferBuilder& builder)
|
|||
static ssize_t write_sys_string(InodeIdentifier inode_id, const UserOrKernelBuffer& buffer, size_t size)
|
||||
{
|
||||
auto& variable = SysVariable::for_inode(inode_id);
|
||||
ASSERT(variable.type == SysVariable::Type::String);
|
||||
VERIFY(variable.type == SysVariable::Type::String);
|
||||
|
||||
auto string_copy = buffer.copy_into_string(size);
|
||||
if (string_copy.is_null())
|
||||
|
@ -1032,7 +1032,7 @@ RefPtr<Inode> ProcFS::get_inode(InodeIdentifier inode_id) const
|
|||
}
|
||||
auto inode = adopt(*new ProcFSInode(const_cast<ProcFS&>(*this), inode_id.index()));
|
||||
auto result = m_inodes.set(inode_id.index().value(), inode.ptr());
|
||||
ASSERT(result == ((it == m_inodes.end()) ? AK::HashSetResult::InsertedNewEntry : AK::HashSetResult::ReplacedExistingEntry));
|
||||
VERIFY(result == ((it == m_inodes.end()) ? AK::HashSetResult::InsertedNewEntry : AK::HashSetResult::ReplacedExistingEntry));
|
||||
return inode;
|
||||
}
|
||||
|
||||
|
@ -1081,7 +1081,7 @@ KResult ProcFSInode::refresh_data(FileDescription& description) const
|
|||
bool (*read_callback)(InodeIdentifier, KBufferBuilder&) = nullptr;
|
||||
if (directory_entry) {
|
||||
read_callback = directory_entry->read_callback;
|
||||
ASSERT(read_callback);
|
||||
VERIFY(read_callback);
|
||||
} else {
|
||||
switch (to_proc_parent_directory(identifier())) {
|
||||
case PDI_PID_fd:
|
||||
|
@ -1093,7 +1093,7 @@ KResult ProcFSInode::refresh_data(FileDescription& description) const
|
|||
case PDI_Root_sys:
|
||||
switch (SysVariable::for_inode(identifier()).type) {
|
||||
case SysVariable::Type::Invalid:
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
case SysVariable::Type::Boolean:
|
||||
read_callback = read_sys_bool;
|
||||
break;
|
||||
|
@ -1103,10 +1103,10 @@ KResult ProcFSInode::refresh_data(FileDescription& description) const
|
|||
}
|
||||
break;
|
||||
default:
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
ASSERT(read_callback);
|
||||
VERIFY(read_callback);
|
||||
}
|
||||
|
||||
if (!cached_data)
|
||||
|
@ -1231,8 +1231,8 @@ InodeMetadata ProcFSInode::metadata() const
|
|||
ssize_t ProcFSInode::read_bytes(off_t offset, ssize_t count, UserOrKernelBuffer& buffer, FileDescription* description) const
|
||||
{
|
||||
dbgln_if(PROCFS_DEBUG, "ProcFS: read_bytes offset: {} count: {}", offset, count);
|
||||
ASSERT(offset >= 0);
|
||||
ASSERT(buffer.user_or_kernel_ptr());
|
||||
VERIFY(offset >= 0);
|
||||
VERIFY(buffer.user_or_kernel_ptr());
|
||||
|
||||
if (!description)
|
||||
return -EIO;
|
||||
|
@ -1350,7 +1350,7 @@ KResult ProcFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntr
|
|||
|
||||
RefPtr<Inode> ProcFSInode::lookup(StringView name)
|
||||
{
|
||||
ASSERT(is_directory());
|
||||
VERIFY(is_directory());
|
||||
if (name == ".")
|
||||
return this;
|
||||
if (name == "..")
|
||||
|
@ -1490,7 +1490,7 @@ ssize_t ProcFSInode::write_bytes(off_t offset, ssize_t size, const UserOrKernelB
|
|||
if (to_proc_parent_directory(identifier()) == PDI_Root_sys) {
|
||||
switch (SysVariable::for_inode(identifier()).type) {
|
||||
case SysVariable::Type::Invalid:
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
case SysVariable::Type::Boolean:
|
||||
write_callback = write_sys_bool;
|
||||
break;
|
||||
|
@ -1506,9 +1506,9 @@ ssize_t ProcFSInode::write_bytes(off_t offset, ssize_t size, const UserOrKernelB
|
|||
write_callback = directory_entry->write_callback;
|
||||
}
|
||||
|
||||
ASSERT(is_persistent_inode(identifier()));
|
||||
VERIFY(is_persistent_inode(identifier()));
|
||||
// FIXME: Being able to write into ProcFS at a non-zero offset seems like something we should maybe support..
|
||||
ASSERT(offset == 0);
|
||||
VERIFY(offset == 0);
|
||||
ssize_t nwritten = write_callback(identifier(), buffer, (size_t)size);
|
||||
if (nwritten < 0)
|
||||
klog() << "ProcFS: Writing " << size << " bytes failed: " << nwritten;
|
||||
|
@ -1565,7 +1565,7 @@ KResultOr<NonnullRefPtr<Custody>> ProcFSInode::resolve_as_link(Custody& base, Re
|
|||
res = &process->root_directory();
|
||||
break;
|
||||
default:
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
if (!res)
|
||||
|
@ -1666,7 +1666,7 @@ KResult ProcFSInode::remove_child([[maybe_unused]] const StringView& name)
|
|||
|
||||
KResultOr<size_t> ProcFSInode::directory_entry_count() const
|
||||
{
|
||||
ASSERT(is_directory());
|
||||
VERIFY(is_directory());
|
||||
size_t count = 0;
|
||||
KResult result = traverse_as_directory([&count](auto&) {
|
||||
++count;
|
||||
|
|
|
@ -131,19 +131,19 @@ private:
|
|||
// ^Inode
|
||||
virtual KResult attach(FileDescription&) override;
|
||||
virtual void did_seek(FileDescription&, off_t) override;
|
||||
virtual ssize_t read_bytes(off_t, ssize_t, UserOrKernelBuffer&, FileDescription*) const override { ASSERT_NOT_REACHED(); }
|
||||
virtual ssize_t read_bytes(off_t, ssize_t, UserOrKernelBuffer&, FileDescription*) const override { VERIFY_NOT_REACHED(); }
|
||||
virtual InodeMetadata metadata() const override;
|
||||
virtual KResult traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)>) const override { ASSERT_NOT_REACHED(); }
|
||||
virtual KResult traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)>) const override { VERIFY_NOT_REACHED(); }
|
||||
virtual RefPtr<Inode> lookup(StringView name) override;
|
||||
virtual void flush_metadata() override {};
|
||||
virtual ssize_t write_bytes(off_t, ssize_t, const UserOrKernelBuffer&, FileDescription*) override { ASSERT_NOT_REACHED(); }
|
||||
virtual ssize_t write_bytes(off_t, ssize_t, const UserOrKernelBuffer&, FileDescription*) override { VERIFY_NOT_REACHED(); }
|
||||
virtual KResultOr<NonnullRefPtr<Inode>> create_child(const String& name, mode_t, dev_t, uid_t, gid_t) override;
|
||||
virtual KResult add_child(Inode&, const StringView& name, mode_t) override;
|
||||
virtual KResult remove_child(const StringView& name) override;
|
||||
virtual KResultOr<size_t> directory_entry_count() const override;
|
||||
virtual KResult chmod(mode_t) override { return EINVAL; }
|
||||
virtual KResult chown(uid_t, gid_t) override { return EINVAL; }
|
||||
virtual KResultOr<NonnullRefPtr<Custody>> resolve_as_link(Custody&, RefPtr<Custody>*, int, int) const override { ASSERT_NOT_REACHED(); }
|
||||
virtual KResultOr<NonnullRefPtr<Custody>> resolve_as_link(Custody&, RefPtr<Custody>*, int, int) const override { VERIFY_NOT_REACHED(); }
|
||||
virtual FileDescription* preopen_fd() override { return m_fd; }
|
||||
|
||||
ProcFS& fs() { return static_cast<ProcFS&>(Inode::fs()); }
|
||||
|
|
|
@ -52,7 +52,7 @@ bool TmpFS::initialize()
|
|||
|
||||
NonnullRefPtr<Inode> TmpFS::root_inode() const
|
||||
{
|
||||
ASSERT(!m_root_inode.is_null());
|
||||
VERIFY(!m_root_inode.is_null());
|
||||
|
||||
return *m_root_inode;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ NonnullRefPtr<Inode> TmpFS::root_inode() const
|
|||
void TmpFS::register_inode(TmpFSInode& inode)
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
ASSERT(inode.identifier().fsid() == fsid());
|
||||
VERIFY(inode.identifier().fsid() == fsid());
|
||||
|
||||
auto index = inode.identifier().index();
|
||||
m_inodes.set(index, inode);
|
||||
|
@ -69,7 +69,7 @@ void TmpFS::register_inode(TmpFSInode& inode)
|
|||
void TmpFS::unregister_inode(InodeIdentifier identifier)
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
ASSERT(identifier.fsid() == fsid());
|
||||
VERIFY(identifier.fsid() == fsid());
|
||||
|
||||
m_inodes.remove(identifier.index());
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ unsigned TmpFS::next_inode_index()
|
|||
RefPtr<Inode> TmpFS::get_inode(InodeIdentifier identifier) const
|
||||
{
|
||||
LOCKER(m_lock, Lock::Mode::Shared);
|
||||
ASSERT(identifier.fsid() == fsid());
|
||||
VERIFY(identifier.fsid() == fsid());
|
||||
|
||||
auto it = m_inodes.find(identifier.index());
|
||||
if (it == m_inodes.end())
|
||||
|
@ -149,9 +149,9 @@ KResult TmpFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntry
|
|||
ssize_t TmpFSInode::read_bytes(off_t offset, ssize_t size, UserOrKernelBuffer& buffer, FileDescription*) const
|
||||
{
|
||||
LOCKER(m_lock, Lock::Mode::Shared);
|
||||
ASSERT(!is_directory());
|
||||
ASSERT(size >= 0);
|
||||
ASSERT(offset >= 0);
|
||||
VERIFY(!is_directory());
|
||||
VERIFY(size >= 0);
|
||||
VERIFY(offset >= 0);
|
||||
|
||||
if (!m_content)
|
||||
return 0;
|
||||
|
@ -170,8 +170,8 @@ ssize_t TmpFSInode::read_bytes(off_t offset, ssize_t size, UserOrKernelBuffer& b
|
|||
ssize_t TmpFSInode::write_bytes(off_t offset, ssize_t size, const UserOrKernelBuffer& buffer, FileDescription*)
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
ASSERT(!is_directory());
|
||||
ASSERT(offset >= 0);
|
||||
VERIFY(!is_directory());
|
||||
VERIFY(offset >= 0);
|
||||
|
||||
auto result = prepare_to_write_data();
|
||||
if (result.is_error())
|
||||
|
@ -217,7 +217,7 @@ ssize_t TmpFSInode::write_bytes(off_t offset, ssize_t size, const UserOrKernelBu
|
|||
RefPtr<Inode> TmpFSInode::lookup(StringView name)
|
||||
{
|
||||
LOCKER(m_lock, Lock::Mode::Shared);
|
||||
ASSERT(is_directory());
|
||||
VERIFY(is_directory());
|
||||
|
||||
if (name == ".")
|
||||
return this;
|
||||
|
@ -233,7 +233,7 @@ RefPtr<Inode> TmpFSInode::lookup(StringView name)
|
|||
KResultOr<size_t> TmpFSInode::directory_entry_count() const
|
||||
{
|
||||
LOCKER(m_lock, Lock::Mode::Shared);
|
||||
ASSERT(is_directory());
|
||||
VERIFY(is_directory());
|
||||
return 2 + m_children.size();
|
||||
}
|
||||
|
||||
|
@ -301,8 +301,8 @@ KResultOr<NonnullRefPtr<Inode>> TmpFSInode::create_child(const String& name, mod
|
|||
KResult TmpFSInode::add_child(Inode& child, const StringView& name, mode_t)
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
ASSERT(is_directory());
|
||||
ASSERT(child.fsid() == fsid());
|
||||
VERIFY(is_directory());
|
||||
VERIFY(child.fsid() == fsid());
|
||||
|
||||
if (name.length() > NAME_MAX)
|
||||
return ENAMETOOLONG;
|
||||
|
@ -315,7 +315,7 @@ KResult TmpFSInode::add_child(Inode& child, const StringView& name, mode_t)
|
|||
KResult TmpFSInode::remove_child(const StringView& name)
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
ASSERT(is_directory());
|
||||
VERIFY(is_directory());
|
||||
|
||||
if (name == "." || name == "..")
|
||||
return KSuccess;
|
||||
|
@ -332,7 +332,7 @@ KResult TmpFSInode::remove_child(const StringView& name)
|
|||
KResult TmpFSInode::truncate(u64 size)
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
ASSERT(!is_directory());
|
||||
VERIFY(!is_directory());
|
||||
|
||||
if (size == 0)
|
||||
m_content.clear();
|
||||
|
|
|
@ -67,7 +67,7 @@ UNMAP_AFTER_INIT VFS::~VFS()
|
|||
|
||||
InodeIdentifier VFS::root_inode_id() const
|
||||
{
|
||||
ASSERT(m_root_inode);
|
||||
VERIFY(m_root_inode);
|
||||
return m_root_inode->identifier();
|
||||
}
|
||||
|
||||
|
@ -211,8 +211,8 @@ KResult VFS::traverse_directory_inode(Inode& dir_inode, Function<bool(const FS::
|
|||
bool is_root_inode = dir_inode.identifier() == dir_inode.fs().root_inode()->identifier();
|
||||
if (is_root_inode && !is_vfs_root(dir_inode.identifier()) && entry.name == "..") {
|
||||
auto mount = find_mount_for_guest(dir_inode);
|
||||
ASSERT(mount);
|
||||
ASSERT(mount->host());
|
||||
VERIFY(mount);
|
||||
VERIFY(mount->host());
|
||||
resolved_inode = mount->host()->identifier();
|
||||
}
|
||||
callback({ entry.name, resolved_inode, entry.file_type });
|
||||
|
@ -697,7 +697,7 @@ KResult VFS::unlink(StringView path, Custody& base)
|
|||
// We have just checked that the inode is not a directory, and thus it's not
|
||||
// the root. So it should have a parent. Note that this would be invalidated
|
||||
// if we were to support bind-mounting regular files on top of the root.
|
||||
ASSERT(parent_custody);
|
||||
VERIFY(parent_custody);
|
||||
|
||||
auto& parent_inode = parent_custody->inode();
|
||||
auto current_process = Process::current();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue