Clean up error handling for umd9660 ioctls.

This commit is contained in:
Unknown W. Brackets committed 2013-12-16 07:55:46 -08:00
1 parent 23ba2cec2f
commit 90b649c9fc
1 file changed
+46 -14
+46 -14
View File
@@ -1971,10 +1971,10 @@ int __IoIoctl(u32 id, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 out
// TODO: Should not work for umd0:/, ms0:/, etc.
// TODO: Should probably move this to something common between ISOFileSystem and VirtualDiscSystem.
if (!Memory::IsValidAddress(outdataPtr) || outlen < 0x800) {
WARN_LOG_REPORT(SCEIO, "sceIoIoCtl: Invalid out pointer while reading ISO9660 volume descriptor");
WARN_LOG_REPORT(SCEIO, "sceIoIoctl: Invalid out pointer while reading ISO9660 volume descriptor");
return SCE_KERNEL_ERROR_ERRNO_INVALID_ARGUMENT;
} else {
INFO_LOG(SCEIO, "sceIoIoCtl: reading ISO9660 volume descriptor read");
INFO_LOG(SCEIO, "sceIoIoctl: reading ISO9660 volume descriptor read");
u32 descFd = pspFileSystem.OpenFile("disc0:/sce_lbn0x10_size0x800", FILEACCESS_READ);
if (descFd == 0) {
return SCE_KERNEL_ERROR_ERRNO_INVALID_ARGUMENT;
@@ -1985,47 +1985,79 @@ int __IoIoctl(u32 id, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 out
}
break;
// Get ISO9660 path table (from open ISO9660 file.)
case 0x01020002:
// TODO: Should not work for umd0:/, ms0:/, etc.
// Seems like it will accept an out size > path table size, but only write path table bytes.
// If not big enough, returns SCE_KERNEL_ERROR_ERRNO_INVALID_ARGUMENT.
// Probably only the LE version.
{
char temp[256];
// We want the reported message to include the cmd, so it's unique.
sprintf(temp, "sceIoIoctl(%%s, %08x, %%08x, %%x, %%08x, %%x)", cmd);
Reporting::ReportMessage(temp, f->fullpath.c_str(), indataPtr, inlen, outdataPtr, outlen);
ERROR_LOG(SCEIO, "UNIMPL 0=sceIoIoctl id: %08x, cmd %08x, indataPtr %08x, inlen %08x, outdataPtr %08x, outLen %08x", id,cmd,indataPtr,inlen,outdataPtr,outlen);
}
break;
// Get UMD sector size
case 0x01020003:
INFO_LOG(SCEIO, "sceIoIoCtl: Asked for sector size of file %i", id);
if (Memory::IsValidAddress(outdataPtr) && outlen == 4) {
Memory::Write_U32(f->info.sectorSize, outdataPtr);
// TODO: Should not work for umd0:/, ms0:/, etc.
// TODO: Should probably move this to something common between ISOFileSystem and VirtualDiscSystem.
INFO_LOG(SCEIO, "sceIoIoctl: Asked for sector size of file %i", id);
if (Memory::IsValidAddress(outdataPtr) && outlen >= 4) {
// ISOs always use 2048 sized sectors.
Memory::Write_U32(2048, outdataPtr);
} else {
return SCE_KERNEL_ERROR_ERRNO_INVALID_ARGUMENT;
}
break;
// Get UMD file offset
case 0x01020004:
{
// TODO: Should not work for umd0:/, ms0:/, etc.
// TODO: Should probably move this to something common between ISOFileSystem and VirtualDiscSystem.
INFO_LOG(SCEIO, "sceIoIoctl: Asked for file offset of file %i", id);
if (Memory::IsValidAddress(outdataPtr) && outlen >= 4) {
u32 offset = (u32)pspFileSystem.GetSeekPos(f->handle);
INFO_LOG(SCEIO, "sceIoIoCtl: Asked for file offset of file %i", id);
if (Memory::IsValidAddress(outdataPtr) && outlen >= 4) {
Memory::Write_U32(offset, outdataPtr);
}
Memory::Write_U32(offset, outdataPtr);
} else {
return SCE_KERNEL_ERROR_ERRNO_INVALID_ARGUMENT;
}
break;
// 0x01020005 - SCE_KERNEL_ERROR_ERRNO_FUNCTION_NOT_SUPPORTED
// Get UMD file start sector.
case 0x01020006:
INFO_LOG(SCEIO, "sceIoIoCtl: Asked for start sector of file %i", id);
// TODO: Should not work for umd0:/, ms0:/, etc.
// TODO: Should probably move this to something common between ISOFileSystem and VirtualDiscSystem.
INFO_LOG(SCEIO, "sceIoIoctl: Asked for start sector of file %i", id);
if (Memory::IsValidAddress(outdataPtr) && outlen >= 4) {
Memory::Write_U32(f->info.startSector, outdataPtr);
} else {
return SCE_KERNEL_ERROR_ERRNO_INVALID_ARGUMENT;
}
break;
// Get UMD file size in bytes.
case 0x01020007:
INFO_LOG(SCEIO, "sceIoIoCtl: Asked for size of file %i", id);
// TODO: Should not work for umd0:/, ms0:/, etc.
// TODO: Should probably move this to something common between ISOFileSystem and VirtualDiscSystem.
INFO_LOG(SCEIO, "sceIoIoctl: Asked for size of file %i", id);
if (Memory::IsValidAddress(outdataPtr) && outlen >= 8) {
Memory::Write_U64(f->info.size, outdataPtr);
} else {
return SCE_KERNEL_ERROR_ERRNO_INVALID_ARGUMENT;
}
break;
// Unknown command, always expects return value of 1 according to JPCSP, used by Pangya Fantasy Golf.
// TODO: This is unsupported on ms0:/ (SCE_KERNEL_ERROR_UNSUP.)
case 0x01f30003:
INFO_LOG(SCEIO, "sceIoIoCtl: Unknown cmd %08x always returns 1", cmd);
INFO_LOG(SCEIO, "sceIoIoctl: Unknown cmd %08x always returns 1", cmd);
if(inlen != 4 || outlen != 1 || Memory::Read_U32(indataPtr) != outlen) {
INFO_LOG(SCEIO, "sceIoIoCtl id: %08x, cmd %08x, indataPtr %08x, inlen %08x, outdataPtr %08x, outlen %08x has invalid parameters", id, cmd, indataPtr, inlen, outdataPtr, outlen);
INFO_LOG(SCEIO, "sceIoIoctl id: %08x, cmd %08x, indataPtr %08x, inlen %08x, outdataPtr %08x, outlen %08x has invalid parameters", id, cmd, indataPtr, inlen, outdataPtr, outlen);
return SCE_KERNEL_ERROR_INVALID_ARGUMENT;
}
else {