Improve logging about corrupt ISOs

This commit is contained in:
Henrik Rydgård 2023-07-08 10:44:49 +02:00
parent 431a0551b2
commit a920b6100c
2 changed files with 13 additions and 2 deletions

View File

@ -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];
@ -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) {

View File

@ -60,6 +60,9 @@ private:
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;