diff --git a/nx/include/switch/services/fs.h b/nx/include/switch/services/fs.h index bbf5118f..6061a965 100644 --- a/nx/include/switch/services/fs.h +++ b/nx/include/switch/services/fs.h @@ -192,6 +192,12 @@ typedef enum { FsGameCardAttribute_Repair = (1 << 2), ///< Indicates that this gamecard is a repair tool. } FsGameCardAttribute; +typedef enum { + FsGameCardPartiton_Update = 0, + FsGameCardPartiton_Normal = 1, + FsGameCardPartiton_Secure = 2, +} FsGameCardPartiton; + typedef struct { u32 value; } FsGameCardHandle; @@ -242,6 +248,7 @@ Result fsCreateSaveDataFileSystemBySystemSaveDataId(const FsSave* save, const Fs Result fsDeleteSaveDataFileSystemBySaveDataSpaceId(FsSaveDataSpaceId saveDataSpaceId, u64 saveID); Result fsIsExFatSupported(bool* out); +Result fsOpenGameCardFileSystem(FsFileSystem* out, const FsGameCardHandle* handle, FsGameCardPartiton partition); /// Do not call this directly, see fs_dev.h. Result fsMountSdcard(FsFileSystem* out); diff --git a/nx/source/services/fs.c b/nx/source/services/fs.c index 206766fc..f520c771 100644 --- a/nx/source/services/fs.c +++ b/nx/source/services/fs.c @@ -736,6 +736,46 @@ Result fsIsExFatSupported(bool* out) return rc; } +Result fsOpenGameCardFileSystem(FsFileSystem* out, const FsGameCardHandle* handle, FsGameCardPartiton partition) { + IpcCommand c; + ipcInitialize(&c); + + struct { + u64 magic; + u64 cmd_id; + u32 handle; + u32 partition; + } *raw; + + raw = serviceIpcPrepareHeader(&g_fsSrv, &c, sizeof(*raw)); + + raw->magic = SFCI_MAGIC; + raw->cmd_id = 31; + raw->handle = handle->value; + raw->partition = partition; + + 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; + + if (R_SUCCEEDED(rc)) { + serviceCreateSubservice(&out->s, &g_fsSrv, &r, 0); + } + } + + 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 = {