From 47e445e08804d9f0e700e27c69b2289e838101cc Mon Sep 17 00:00:00 2001 From: ITotalJustice <47043333+ITotalJustice@users.noreply.github.com> Date: Sat, 16 Aug 2025 16:50:01 +0100 Subject: [PATCH 1/2] fs: add fsOpenGameCardDetectionEventNotifier and fsOpenGameCardStorage. --- nx/include/switch/services/fs.h | 8 ++++++++ nx/source/services/fs.c | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/nx/include/switch/services/fs.h b/nx/include/switch/services/fs.h index 387cccfd..b38563c3 100644 --- a/nx/include/switch/services/fs.h +++ b/nx/include/switch/services/fs.h @@ -261,6 +261,11 @@ typedef enum { FsGameCardPartition_Logo = 3, ///< [4.0.0+] } FsGameCardPartition; +typedef enum { + FsGameCardStoragePartition_Normal = 0, + FsGameCardStoragePartition_Secure = 1, +} FsGameCardStoragePartition; + typedef struct { u32 value; } FsGameCardHandle; @@ -540,8 +545,11 @@ Result fsOpenDataStorageByProgramId(FsStorage *out, u64 program_id); /// <[3.0.0 Result fsOpenDataStorageByDataId(FsStorage* out, u64 dataId, NcmStorageId storageId); Result fsOpenPatchDataStorageByCurrentProcess(FsStorage* out); +Result fsOpenGameCardStorage(FsStorage* out, const FsGameCardHandle* handle, FsGameCardStoragePartition partition); + Result fsOpenDeviceOperator(FsDeviceOperator* out); Result fsOpenSdCardDetectionEventNotifier(FsEventNotifier* out); +Result fsOpenGameCardDetectionEventNotifier(FsEventNotifier* out); Result fsIsSignedSystemPartitionOnSdCardValid(bool *out); diff --git a/nx/source/services/fs.c b/nx/source/services/fs.c index d1715d26..405581bd 100644 --- a/nx/source/services/fs.c +++ b/nx/source/services/fs.c @@ -538,6 +538,18 @@ Result fsOpenPatchDataStorageByCurrentProcess(FsStorage* out) { return _fsCmdGetSession(&g_fsSrv, &out->s, 203); } +Result fsOpenGameCardStorage(FsStorage* out, const FsGameCardHandle* handle, FsGameCardStoragePartition partition) { + const struct { + FsGameCardHandle handle; + u32 partition; + } in = { *handle, (u32)partition }; + + return serviceDispatchIn(&g_fsSrv, 30, in, + .out_num_objects = 1, + .out_objects = &out->s + ); +} + Result fsOpenDeviceOperator(FsDeviceOperator* out) { return _fsCmdGetSession(&g_fsSrv, &out->s, 400); } @@ -546,6 +558,10 @@ Result fsOpenSdCardDetectionEventNotifier(FsEventNotifier* out) { return _fsCmdGetSession(&g_fsSrv, &out->s, 500); } +Result fsOpenGameCardDetectionEventNotifier(FsEventNotifier* out) { + return _fsCmdGetSession(&g_fsSrv, &out->s, 501); +} + Result fsIsSignedSystemPartitionOnSdCardValid(bool *out) { if (!hosversionBetween(4, 8)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); From 0eb0c379f46735bad58c83f858b1243a85b99216 Mon Sep 17 00:00:00 2001 From: ITotalJustice <47043333+ITotalJustice@users.noreply.github.com> Date: Fri, 19 Sep 2025 22:01:16 +0100 Subject: [PATCH 2/2] use correct names for fsOpenGameCardPartition / FsGameCardPartitionRaw. --- nx/include/switch/services/fs.h | 8 ++++---- nx/source/services/fs.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/nx/include/switch/services/fs.h b/nx/include/switch/services/fs.h index b38563c3..da6003b8 100644 --- a/nx/include/switch/services/fs.h +++ b/nx/include/switch/services/fs.h @@ -262,9 +262,9 @@ typedef enum { } FsGameCardPartition; typedef enum { - FsGameCardStoragePartition_Normal = 0, - FsGameCardStoragePartition_Secure = 1, -} FsGameCardStoragePartition; + FsGameCardPartitionRaw_Normal = 0, + FsGameCardPartitionRaw_Secure = 1, +} FsGameCardPartitionRaw; typedef struct { u32 value; @@ -545,7 +545,7 @@ Result fsOpenDataStorageByProgramId(FsStorage *out, u64 program_id); /// <[3.0.0 Result fsOpenDataStorageByDataId(FsStorage* out, u64 dataId, NcmStorageId storageId); Result fsOpenPatchDataStorageByCurrentProcess(FsStorage* out); -Result fsOpenGameCardStorage(FsStorage* out, const FsGameCardHandle* handle, FsGameCardStoragePartition partition); +Result fsOpenGameCardPartition(FsStorage* out, const FsGameCardHandle* handle, FsGameCardPartitionRaw partition); Result fsOpenDeviceOperator(FsDeviceOperator* out); Result fsOpenSdCardDetectionEventNotifier(FsEventNotifier* out); diff --git a/nx/source/services/fs.c b/nx/source/services/fs.c index 405581bd..73ea9a63 100644 --- a/nx/source/services/fs.c +++ b/nx/source/services/fs.c @@ -538,7 +538,7 @@ Result fsOpenPatchDataStorageByCurrentProcess(FsStorage* out) { return _fsCmdGetSession(&g_fsSrv, &out->s, 203); } -Result fsOpenGameCardStorage(FsStorage* out, const FsGameCardHandle* handle, FsGameCardStoragePartition partition) { +Result fsOpenGameCardPartition(FsStorage* out, const FsGameCardHandle* handle, FsGameCardPartitionRaw partition) { const struct { FsGameCardHandle handle; u32 partition;