blob: 59b195f7c317560cf676e6b4c7d3871171e93961 [file] [log] [blame]
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/storage/minfs/inspector_inode_table.h"
#include <disk_inspector/common_types.h>
#include <safemath/safe_math.h>
#include "src/storage/minfs/inspector_inode.h"
#include "src/storage/minfs/inspector_private.h"
namespace minfs {
void InodeTableObject::GetValue(const void** out_buffer, size_t* out_buffer_size) const {
ZX_DEBUG_ASSERT_MSG(false, "Invalid GetValue call for non primitive data type.");
}
std::unique_ptr<disk_inspector::DiskObject> InodeTableObject::GetElementAt(uint32_t index) const {
if (index >= allocated_inode_count_) {
return nullptr;
}
return GetInode(index);
}
std::unique_ptr<disk_inspector::DiskObject> InodeTableObject::GetInode(
uint32_t element_index) const {
Inode inode_obj;
auto inode_index = safemath::strict_cast<ino_t>(allocated_inode_indices[element_index]);
inode_table_->Load(inode_index, &inode_obj);
return std::make_unique<InodeObject>(element_index, inode_index, inode_obj);
}
void InodeTableObject::SetupAllocatedInodeIndex() {
for (uint32_t i = 0; i < inode_count_; ++i) {
if (inode_table_->CheckAllocated(i))
allocated_inode_indices.push_back(i);
}
}
} // namespace minfs