mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-10 06:01:52 +00:00
fs: miscellaneous bucket tree fixes
This commit is contained in:
parent
a2496e5462
commit
f215da3b37
3 changed files with 10 additions and 8 deletions
|
@ -126,7 +126,7 @@ namespace ams::fssystem {
|
|||
this->allocator = nullptr;
|
||||
}
|
||||
|
||||
void FillSzero(size_t node_size) const {
|
||||
void FillZero(size_t node_size) const {
|
||||
if (this->header) {
|
||||
std::memset(this->header, 0, node_size);
|
||||
}
|
||||
|
@ -298,7 +298,7 @@ namespace ams::fssystem {
|
|||
}
|
||||
|
||||
bool IsValid() const { return this->entry_index >= 0; }
|
||||
bool CanMoveNext() const { return this->IsValid() && (this->entry_index + 1 < this->entry_set.info.count || this->entry_set.info.index + 1 < this->entry_set.info.count); }
|
||||
bool CanMoveNext() const { return this->IsValid() && (this->entry_index + 1 < this->entry_set.info.count || this->entry_set.info.index + 1 < this->entry_set_count); }
|
||||
bool CanMovePrevious() const { return this->IsValid() && (this->entry_index > 0 || this->entry_set.info.index > 0); }
|
||||
|
||||
Result MoveNext();
|
||||
|
|
|
@ -130,12 +130,12 @@ namespace ams::fssystem {
|
|||
}
|
||||
|
||||
Result BucketTree::NodeHeader::Verify(s32 node_index, size_t node_size, size_t entry_size) const {
|
||||
R_UNLESS(this->index == node_index, fs::ResultInvalidArgument());
|
||||
R_UNLESS(entry_size == 0 || node_size < entry_size + NodeHeaderSize, fs::ResultInvalidSize());
|
||||
R_UNLESS(this->index == node_index, fs::ResultInvalidBucketTreeNodeIndex());
|
||||
R_UNLESS(entry_size != 0 && node_size >= entry_size + NodeHeaderSize, fs::ResultInvalidSize());
|
||||
|
||||
const size_t max_entry_count = (node_size - NodeHeaderSize) / entry_size;
|
||||
R_UNLESS(this->count > 0 && static_cast<size_t>(this->count) <= max_entry_count, fs::ResultInvalidBucketTreeNodeEntryCount());
|
||||
R_UNLESS(this->offset > 0, fs::ResultInvalidBucketTreeNodeOffset());
|
||||
R_UNLESS(this->offset >= 0, fs::ResultInvalidBucketTreeNodeOffset());
|
||||
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
@ -440,7 +440,7 @@ namespace ams::fssystem {
|
|||
/* Create the node, and find. */
|
||||
StorageNode node(sizeof(s64), header.count);
|
||||
node.Find(buffer, virtual_address);
|
||||
R_UNLESS(node.GetIndex() >= 0, fs::ResultOutOfRange());
|
||||
R_UNLESS(node.GetIndex() >= 0, fs::ResultInvalidBucketTreeVirtualOffset());
|
||||
|
||||
/* Return the index. */
|
||||
*out_index = this->tree->GetEntrySetIndex(header.index, node.GetIndex());
|
||||
|
@ -485,7 +485,7 @@ namespace ams::fssystem {
|
|||
const auto entry_size = this->tree->entry_size;
|
||||
const auto entry_set_size = this->tree->node_size;
|
||||
const auto entry_set_offset = entry_set_index * static_cast<s64>(entry_set_size);
|
||||
fs::SubStorage &storage = tree->node_storage;
|
||||
fs::SubStorage &storage = tree->entry_storage;
|
||||
|
||||
/* Read the entry set. */
|
||||
R_TRY(storage.Read(entry_set_offset, buffer, entry_set_size));
|
||||
|
@ -517,7 +517,7 @@ namespace ams::fssystem {
|
|||
const auto entry_size = this->tree->entry_size;
|
||||
const auto entry_set_size = this->tree->node_size;
|
||||
const auto entry_set_offset = entry_set_index * static_cast<s64>(entry_set_size);
|
||||
fs::SubStorage &storage = tree->node_storage;
|
||||
fs::SubStorage &storage = tree->entry_storage;
|
||||
|
||||
/* Read and validate the entry_set. */
|
||||
EntrySetHeader entry_set;
|
||||
|
|
|
@ -141,6 +141,8 @@ namespace ams::fs {
|
|||
R_DEFINE_ERROR_RESULT(InvalidBucketTreeNodeOffset, 4035);
|
||||
R_DEFINE_ERROR_RESULT(InvalidBucketTreeEntryOffset, 4036);
|
||||
R_DEFINE_ERROR_RESULT(InvalidBucketTreeEntrySetOffset, 4037);
|
||||
R_DEFINE_ERROR_RESULT(InvalidBucketTreeNodeIndex, 4038);
|
||||
R_DEFINE_ERROR_RESULT(InvalidBucketTreeVirtualOffset, 4039);
|
||||
|
||||
R_DEFINE_ERROR_RANGE(RomNcaCorrupted, 4041, 4139);
|
||||
R_DEFINE_ERROR_RANGE(RomNcaFileSystemCorrupted, 4051, 4069);
|
||||
|
|
Loading…
Reference in a new issue