cellSaveData fix

This commit is contained in:
Nekotekina 2015-08-16 23:37:10 +03:00
parent fcd6b64f8f
commit 6b6cd11fbe
3 changed files with 37 additions and 17 deletions

View File

@ -32,7 +32,7 @@ s32 cellMsgDialogOpen2(u32 type, vm::cptr<char> msgString, vm::ptr<CellMsgDialog
{ {
cellSysutil.Warning("cellMsgDialogOpen2(type=0x%x, msgString=*0x%x, callback=*0x%x, userData=*0x%x, extParam=*0x%x)", type, msgString, callback, userData, extParam); cellSysutil.Warning("cellMsgDialogOpen2(type=0x%x, msgString=*0x%x, callback=*0x%x, userData=*0x%x, extParam=*0x%x)", type, msgString, callback, userData, extParam);
if (!msgString || strlen(msgString.get_ptr()) >= 0x200 || type & -0x33f8) if (!msgString || std::strlen(msgString.get_ptr()) >= 0x200 || type & -0x33f8)
{ {
return CELL_MSGDIALOG_ERROR_PARAM; return CELL_MSGDIALOG_ERROR_PARAM;
} }

View File

@ -77,7 +77,7 @@ never_inline s32 savedata_op(PPUThread& ppu, u32 operation, u32 version, vm::cpt
const auto fileSet = stack.of(&_stack_t::fileSet); const auto fileSet = stack.of(&_stack_t::fileSet);
// path of the specified user (00000001 by default) // path of the specified user (00000001 by default)
const std::string base_dir = fmt::format("/dev_hdd0/home/%08d/savedata/", userId ? userId : 1u); const std::string base_dir = fmt::format("/dev_hdd0/home/%08u/savedata/", userId ? userId : 1u);
result->userdata = userdata; // probably should be assigned only once (allows the callback to change it) result->userdata = userdata; // probably should be assigned only once (allows the callback to change it)
@ -447,10 +447,11 @@ never_inline s32 savedata_op(PPUThread& ppu, u32 operation, u32 version, vm::cpt
return CELL_SAVEDATA_ERROR_CBRESULT; return CELL_SAVEDATA_ERROR_CBRESULT;
} }
// Update PARAM.SFO
if (statSet->setParam) if (statSet->setParam)
{ {
psf.Clear(); psf.Clear();
// Update PARAM.SFO
psf.SetString("ACCOUNT_ID", ""); // ??? psf.SetString("ACCOUNT_ID", ""); // ???
psf.SetInteger("ATTRIBUTE", statSet->setParam->attribute); psf.SetInteger("ATTRIBUTE", statSet->setParam->attribute);
psf.SetString("CATEGORY", "SD"); // ??? psf.SetString("CATEGORY", "SD"); // ???
@ -463,14 +464,26 @@ never_inline s32 savedata_op(PPUThread& ppu, u32 operation, u32 version, vm::cpt
psf.SetString("SUB_TITLE", statSet->setParam->subTitle); psf.SetString("SUB_TITLE", statSet->setParam->subTitle);
psf.SetString("TITLE", statSet->setParam->title); psf.SetString("TITLE", statSet->setParam->title);
} }
else if (!psf)
{
// setParam is NULL for new savedata: abort operation
return CELL_OK;
}
switch (const u32 mode = statSet->reCreateMode & 0xffff) switch (const u32 mode = statSet->reCreateMode & 0xffff)
{ {
case CELL_SAVEDATA_RECREATE_NO: case CELL_SAVEDATA_RECREATE_NO:
{
cellSaveData.Error("Savedata %s considered broken", save_entry.dirName);
// fallthrough
}
case CELL_SAVEDATA_RECREATE_NO_NOBROKEN: case CELL_SAVEDATA_RECREATE_NO_NOBROKEN:
{ {
break; break;
} }
case CELL_SAVEDATA_RECREATE_YES: case CELL_SAVEDATA_RECREATE_YES:
case CELL_SAVEDATA_RECREATE_YES_RESET_OWNER: case CELL_SAVEDATA_RECREATE_YES_RESET_OWNER:
{ {
@ -483,8 +496,17 @@ never_inline s32 savedata_op(PPUThread& ppu, u32 operation, u32 version, vm::cpt
} }
} }
if (!statSet->setParam)
{
// Savedata deleted and setParam is NULL: delete directory and abort operation
if (Emu.GetVFS().RemoveDir(dir_path)) cellSysutil.Error("savedata_op(): savedata directory %s deleted", save_entry.dirName);
return CELL_OK;
}
break; break;
} }
default: default:
{ {
cellSysutil.Error("savedata_op(): unknown statSet->reCreateMode (0x%x)", statSet->reCreateMode); cellSysutil.Error("savedata_op(): unknown statSet->reCreateMode (0x%x)", statSet->reCreateMode);

View File

@ -7,28 +7,26 @@ enum
{ {
CELL_SYNC_ERROR_AGAIN = 0x80410101, CELL_SYNC_ERROR_AGAIN = 0x80410101,
CELL_SYNC_ERROR_INVAL = 0x80410102, CELL_SYNC_ERROR_INVAL = 0x80410102,
CELL_SYNC_ERROR_NOSYS = 0x80410103, // ??? CELL_SYNC_ERROR_NOSYS = 0x80410103,
CELL_SYNC_ERROR_NOMEM = 0x80410104, CELL_SYNC_ERROR_NOMEM = 0x80410104,
CELL_SYNC_ERROR_SRCH = 0x80410105, // ??? CELL_SYNC_ERROR_SRCH = 0x80410105,
CELL_SYNC_ERROR_NOENT = 0x80410106, // ??? CELL_SYNC_ERROR_NOENT = 0x80410106,
CELL_SYNC_ERROR_NOEXEC = 0x80410107, // ??? CELL_SYNC_ERROR_NOEXEC = 0x80410107,
CELL_SYNC_ERROR_DEADLK = 0x80410108, CELL_SYNC_ERROR_DEADLK = 0x80410108,
CELL_SYNC_ERROR_PERM = 0x80410109, CELL_SYNC_ERROR_PERM = 0x80410109,
CELL_SYNC_ERROR_BUSY = 0x8041010A, CELL_SYNC_ERROR_BUSY = 0x8041010A,
//////////////////////// 0x8041010B, // ??? CELL_SYNC_ERROR_ABORT = 0x8041010C,
CELL_SYNC_ERROR_ABORT = 0x8041010C, // ??? CELL_SYNC_ERROR_FAULT = 0x8041010D,
CELL_SYNC_ERROR_FAULT = 0x8041010D, // ??? CELL_SYNC_ERROR_CHILD = 0x8041010E,
CELL_SYNC_ERROR_CHILD = 0x8041010E, // ???
CELL_SYNC_ERROR_STAT = 0x8041010F, CELL_SYNC_ERROR_STAT = 0x8041010F,
CELL_SYNC_ERROR_ALIGN = 0x80410110, CELL_SYNC_ERROR_ALIGN = 0x80410110,
CELL_SYNC_ERROR_NULL_POINTER = 0x80410111, CELL_SYNC_ERROR_NULL_POINTER = 0x80410111,
CELL_SYNC_ERROR_NOT_SUPPORTED_THREAD = 0x80410112,
CELL_SYNC_ERROR_NOT_SUPPORTED_THREAD = 0x80410112, // ??? CELL_SYNC_ERROR_SHOTAGE = 0x80410112,
CELL_SYNC_ERROR_SHOTAGE = 0x80410112, // ??? CELL_SYNC_ERROR_NO_NOTIFIER = 0x80410113,
CELL_SYNC_ERROR_NO_NOTIFIER = 0x80410113, // ??? CELL_SYNC_ERROR_UNKNOWNKEY = 0x80410113,
CELL_SYNC_ERROR_UNKNOWNKEY = 0x80410113, // ??? CELL_SYNC_ERROR_NO_SPU_CONTEXT_STORAGE = 0x80410114,
CELL_SYNC_ERROR_NO_SPU_CONTEXT_STORAGE = 0x80410114, // ???
}; };
struct alignas(4) sync_mutex_t // CellSyncMutex sync var struct alignas(4) sync_mutex_t // CellSyncMutex sync var