diff --git a/nx/include/switch/services/fs.h b/nx/include/switch/services/fs.h index 64aeea52..1060d943 100644 --- a/nx/include/switch/services/fs.h +++ b/nx/include/switch/services/fs.h @@ -278,6 +278,7 @@ Result fsOpenGameCardFileSystem(FsFileSystem* out, const FsGameCardHandle* handl Result fsReadSaveDataFileSystemExtraDataBySaveDataSpaceId(void* buf, size_t len, FsSaveDataSpaceId saveDataSpaceId, u64 saveID); Result fsReadSaveDataFileSystemExtraData(void* buf, size_t len, u64 saveID); Result fsWriteSaveDataFileSystemExtraData(const void* buf, size_t len, FsSaveDataSpaceId saveDataSpaceId, u64 saveID); +Result fsExtendSaveDataFileSystem(FsSaveDataSpaceId saveDataSpaceId, u64 saveID, s64 dataSize, s64 journalSize); /// Do not call this directly, see fs_dev.h. Result fsMountSdcard(FsFileSystem* out); @@ -299,6 +300,9 @@ Result fsGetRightsIdByPath(const char* path, FsRightsId* out_rights_id); Result fsGetRightsIdAndKeyGenerationByPath(const char* path, u8* out_key_generation, FsRightsId* out_rights_id); Result fsDisableAutoSaveDataCreation(void); + +Result fsSetGlobalAccessLogMode(u32 mode); +Result fsGetGlobalAccessLogMode(u32* out_mode); // todo: Rest of commands here // Wrapper(s) for fsCreateSaveDataFileSystemBySystemSaveDataId. diff --git a/nx/source/services/fs.c b/nx/source/services/fs.c index 54a0b6e0..87f1032d 100644 --- a/nx/source/services/fs.c +++ b/nx/source/services/fs.c @@ -932,6 +932,123 @@ Result fsWriteSaveDataFileSystemExtraData(const void* buf, size_t len, FsSaveDat return rc; } +Result fsExtendSaveDataFileSystem(FsSaveDataSpaceId saveDataSpaceId, u64 saveID, s64 dataSize, s64 journalSize) { + if (hosversionBefore(3,0,0)) + return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + + IpcCommand c; + ipcInitialize(&c); + + struct { + u64 magic; + u64 cmd_id; + u64 saveDataSpaceId; + u64 saveID; + s64 dataSize; + s64 journalSize; + } *raw; + + raw = serviceIpcPrepareHeader(&g_fsSrv, &c, sizeof(*raw)); + + raw->magic = SFCI_MAGIC; + raw->cmd_id = 32; + raw->saveDataSpaceId = saveDataSpaceId; + raw->saveID = saveID; + raw->dataSize = dataSize; + raw->saveID = saveID; + raw->journalSize = journalSize; + + Result rc = serviceIpcDispatch(&g_fsSrv); + + if (R_SUCCEEDED(rc)) { + IpcParsedCommand r; + struct { + u64 magic; + u64 result; + } *resp; + + serviceIpcParse(&g_fsSrv, &r, sizeof(*resp)); + resp = r.Raw; + + rc = resp->result; + } + + return rc; +} + +Result fsSetGlobalAccessLogMode(u32 mode) +{ + IpcCommand c; + ipcInitialize(&c); + + struct { + u64 magic; + u64 cmd_id; + u32 mode; + } *raw; + + raw = serviceIpcPrepareHeader(&g_fsSrv, &c, sizeof(*raw)); + + raw->magic = SFCI_MAGIC; + raw->cmd_id = 1004; + raw->mode = mode; + + Result rc = serviceIpcDispatch(&g_fsSrv); + + if (R_SUCCEEDED(rc)) { + IpcParsedCommand r; + struct { + u64 magic; + u64 result; + } *resp; + + serviceIpcParse(&g_fsSrv, &r, sizeof(*resp)); + resp = r.Raw; + + rc = resp->result; + } + + return rc; +} + +Result fsGetGlobalAccessLogMode(u32* out_mode) +{ + IpcCommand c; + ipcInitialize(&c); + + struct { + u64 magic; + u64 cmd_id; + } *raw; + + raw = serviceIpcPrepareHeader(&g_fsSrv, &c, sizeof(*raw)); + + raw->magic = SFCI_MAGIC; + raw->cmd_id = 1005; + + Result rc = serviceIpcDispatch(&g_fsSrv); + + if (R_SUCCEEDED(rc)) { + IpcParsedCommand r; + struct { + u64 magic; + u64 result; + u32 mode; + } *resp; + + serviceIpcParse(&g_fsSrv, &r, sizeof(*resp)); + resp = r.Raw; + + rc = resp->result; + + if (R_SUCCEEDED(rc)) { + *out_mode = resp->mode; + } + } + + return rc; +} + // Wrapper(s) for fsCreateSaveDataFileSystemBySystemSaveDataId. Result fsCreate_SystemSaveDataWithOwner(FsSaveDataSpaceId saveDataSpaceId, u64 saveID, u128 userID, u64 ownerId, u64 size, u64 journalSize, u32 flags) { FsSave save = {