From 27b88686465142e7ea3a212c5985c8e552fd37cc Mon Sep 17 00:00:00 2001 From: klockee <41720535+klockee@users.noreply.github.com> Date: Sat, 28 Jul 2018 11:08:42 -0400 Subject: [PATCH] Wrapped and implemented fsOpenBisFilesystem() (#140) --- nx/include/switch/services/fs.h | 1 + nx/source/services/fs.c | 41 +++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/nx/include/switch/services/fs.h b/nx/include/switch/services/fs.h index 859dfdc9..0cdd3358 100644 --- a/nx/include/switch/services/fs.h +++ b/nx/include/switch/services/fs.h @@ -145,6 +145,7 @@ void fsExit(void); Service* fsGetServiceSession(void); Result fsOpenBisStorage(FsStorage* out, u32 PartitionId); +Result fsOpenBisFileSystem(FsFileSystem* out, u32 PartitionId, const char* string); /// 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 8acb4ae1..0652c8aa 100644 --- a/nx/source/services/fs.c +++ b/nx/source/services/fs.c @@ -101,6 +101,47 @@ Result fsOpenBisStorage(FsStorage* out, u32 PartitionId) { return rc; } +Result fsOpenBisFileSystem(FsFileSystem* out, u32 PartitionId, const char* string) { + IpcCommand c; + ipcInitialize(&c); + + char tmpstr[FS_MAX_PATH] = {0}; + strncpy(tmpstr, string, sizeof(tmpstr)-1); + ipcAddSendStatic(&c, tmpstr, sizeof(tmpstr), 0); + + struct { + u64 magic; + u64 cmd_id; + u32 PartitionId; + } *raw; + + raw = ipcPrepareHeader(&c, sizeof(*raw)); + + raw->magic = SFCI_MAGIC; + raw->cmd_id = 11; + raw->PartitionId = PartitionId; + + Result rc = serviceIpcDispatch(&g_fsSrv); + + if (R_SUCCEEDED(rc)) { + IpcParsedCommand r; + ipcParse(&r); + + struct { + u64 magic; + u64 result; + } *resp = r.Raw; + + rc = resp->result; + + if (R_SUCCEEDED(rc)) { + serviceCreate(&out->s, r.Handles[0]); + } + } + + return rc; +} + Result fsMountSdcard(FsFileSystem* out) { IpcCommand c; ipcInitialize(&c);