From 86577c2c722b6695497fed18fd27299d6d9331b7 Mon Sep 17 00:00:00 2001 From: HookedBehemoth Date: Fri, 5 Jun 2020 18:19:52 +0200 Subject: [PATCH] add romfs wrapper for program mounting --- nx/include/switch/runtime/devices/romfs_dev.h | 8 ++++++++ nx/source/runtime/devices/romfs_dev.c | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/nx/include/switch/runtime/devices/romfs_dev.h b/nx/include/switch/runtime/devices/romfs_dev.h index b33e2418..7582a03b 100644 --- a/nx/include/switch/runtime/devices/romfs_dev.h +++ b/nx/include/switch/runtime/devices/romfs_dev.h @@ -82,6 +82,14 @@ Result romfsMountFromStorage(FsStorage storage, u64 offset, const char *name); */ Result romfsMountFromCurrentProcess(const char *name); +/** + * @brief Mounts RomFS of a running program. + * @note Permission needs to be set in the NPDM. + * @param program_id ProgramId to mount. + * @param name Device mount name. + */ +Result romfsMountProgram(u64 program_id, const char *name); + /** * @brief Mounts RomFS from a file path in a mounted fsdev device. * @param path File path. diff --git a/nx/source/runtime/devices/romfs_dev.c b/nx/source/runtime/devices/romfs_dev.c index 0dd50374..34d23978 100644 --- a/nx/source/runtime/devices/romfs_dev.c +++ b/nx/source/runtime/devices/romfs_dev.c @@ -342,6 +342,16 @@ Result romfsMountFromCurrentProcess(const char *name) { return romfsMountFromStorage(storage, 0, name); } +Result romfsMountProgram(u64 program_id, const char *name) { + FsStorage storage; + + Result rc = fsOpenDataStorageByProgramId(&storage, program_id); + if (R_FAILED(rc)) + return rc; + + return romfsMountFromStorage(storage, 0, name); +} + Result romfsMountFromFsdev(const char *path, u64 offset, const char *name) { FsFileSystem *tmpfs = NULL;