blob: 69e1b1978cd8014254ef49ac52703261b31a4082 [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 <disk_inspector/common_types.h>
#include "src/lib/storage/vfs/cpp/journal/format.h"
#include "src/storage/minfs/allocator/inode_manager.h"
#include "src/storage/minfs/format.h"
#include "src/storage/minfs/minfs_private.h"
namespace minfs {
constexpr char kInodeTableName[] = "inode table";
// The current implementation of the InodeTableObject prints out every inode
// that is allocated in the inode table.
// TODO( Change this implementation once we have a better format
// for how to display inodes when making disk-inspect interactive.
// Refer to ( for more details about the current implementation.
class InodeTableObject : public disk_inspector::DiskObject {
InodeTableObject() = delete;
InodeTableObject(const InodeTableObject&) = delete;
InodeTableObject(InodeTableObject&&) = delete;
InodeTableObject& operator=(const InodeTableObject&) = delete;
InodeTableObject& operator=(InodeTableObject&&) = delete;
InodeTableObject(const InspectableInodeManager* inodes, uint32_t allocated_inode_count,
uint32_t inode_count)
: inode_table_(inodes),
inode_count_(inode_count) {
// DiskObject interface:
const char* GetName() const override { return kInodeTableName; }
uint32_t GetNumElements() const override { return allocated_inode_count_; }
void GetValue(const void** out_buffer, size_t* out_buffer_size) const override;
std::unique_ptr<DiskObject> GetElementAt(uint32_t index) const override;
// Gets the inode from the list of allocated inodes at index |element_index|.
std::unique_ptr<disk_inspector::DiskObject> GetInode(uint32_t element_index) const;
void SetupAllocatedInodeIndex();
// Pointer to the minfs 'inodes_' field.
const InspectableInodeManager* inode_table_;
// Number of allocated inodes in the inode table.
const uint32_t allocated_inode_count_;
// Total number of inodes in the inode table.
const uint32_t inode_count_;
// List of indices of allocated inodes in the inode table.
std::vector<uint32_t> allocated_inode_indices;
} // namespace minfs