Skip to content

Commit

Permalink
Improve logging about corrupt ISOs
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Jul 12, 2023
1 parent 431a055 commit a920b61
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Core/FileSystems/ISOFileSystem.cpp
Expand Up @@ -177,6 +177,14 @@ ISOFileSystem::~ISOFileSystem() {
delete treeroot;
}

std::string ISOFileSystem::TreeEntry::BuildPath() {
if (parent) {
return parent->BuildPath() + "/" + name;
} else {
return name;
}
}

void ISOFileSystem::ReadDirectory(TreeEntry *root) {
for (u32 secnum = root->startsector, endsector = root->startsector + (root->dirsize + 2047) / 2048; secnum < endsector; ++secnum) {
u8 theSector[2048];
Expand Down Expand Up @@ -228,12 +236,12 @@ void ISOFileSystem::ReadDirectory(TreeEntry *root) {
entry->startsector = dir.firstDataSector;
entry->dirsize = dir.dataLength;
entry->valid = isFile; // Can pre-mark as valid if file, as we don't recurse into those.
VERBOSE_LOG(FILESYS, "%s: %s %08x %08x %i", entry->isDirectory ? "D" : "F", entry->name.c_str(), (u32)dir.firstDataSector, entry->startingPosition, entry->startingPosition);
VERBOSE_LOG(FILESYS, "%s: %s %08x %08x %d", entry->isDirectory ? "D" : "F", entry->name.c_str(), (u32)dir.firstDataSector, entry->startingPosition, entry->startingPosition);

// Round down to avoid any false reports.
if (isFile && dir.firstDataSector + (dir.dataLength / 2048) > blockDevice->GetNumBlocks()) {
blockDevice->NotifyReadError();
ERROR_LOG(FILESYS, "File '%s' starts or ends outside ISO", entry->name.c_str());
ERROR_LOG(FILESYS, "File '%s' starts or ends outside ISO. firstDataSector: %d len: %d", entry->BuildPath().c_str(), dir.firstDataSector, dir.dataLength);
}

if (entry->isDirectory && !relative) {
Expand Down
3 changes: 3 additions & 0 deletions Core/FileSystems/ISOFileSystem.h
Expand Up @@ -60,6 +60,9 @@ class ISOFileSystem : public IFileSystem {
struct TreeEntry {
~TreeEntry();

// Recursive function that reconstructs the path by looking at the parent pointers.
std::string BuildPath();

std::string name;
u32 flags = 0;
u32 startingPosition = 0;
Expand Down

0 comments on commit a920b61

Please sign in to comment.