mirror of
https://github.com/switchbrew/libnx.git
synced 2025-07-06 11:22:15 +02:00
Make fsOpenFileSystem and fsOpenFileSystemWithId work on all firmware versions
This commit is contained in:
parent
f9e59d12be
commit
a94bc6a68f
@ -179,8 +179,8 @@ typedef enum
|
|||||||
} FsFileSystemType;
|
} FsFileSystemType;
|
||||||
|
|
||||||
/// Mount requested filesystem type from content file
|
/// Mount requested filesystem type from content file
|
||||||
Result fsOpenFileSystem(FsFileSystem* out, FsFileSystemType fsType, const char* contentPath); /// only on 1.0.0
|
Result fsOpenFileSystem(FsFileSystem* out, FsFileSystemType fsType, const char* contentPath);
|
||||||
Result fsOpenFileSystemWithId(FsFileSystem* out, u64 titleId, FsFileSystemType fsType, const char* contentPath); /// 2.0.0+
|
Result fsOpenFileSystemWithId(FsFileSystem* out, u64 titleId, FsFileSystemType fsType, const char* contentPath);
|
||||||
|
|
||||||
// IFileSystem
|
// IFileSystem
|
||||||
Result fsFsCreateFile(FsFileSystem* fs, const char* path, size_t size, int flags);
|
Result fsFsCreateFile(FsFileSystem* fs, const char* path, size_t size, int flags);
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "result.h"
|
#include "result.h"
|
||||||
#include "arm/atomics.h"
|
#include "arm/atomics.h"
|
||||||
#include "kernel/ipc.h"
|
#include "kernel/ipc.h"
|
||||||
|
#include "kernel/detect.h"
|
||||||
#include "services/fs.h"
|
#include "services/fs.h"
|
||||||
#include "services/sm.h"
|
#include "services/sm.h"
|
||||||
|
|
||||||
@ -433,44 +434,7 @@ Result fsMount_SystemSaveData(FsFileSystem* out, u64 saveID) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result fsOpenFileSystem(FsFileSystem* out, FsFileSystemType fsType, const char* contentPath) {
|
Result fsOpenFileSystem(FsFileSystem* out, FsFileSystemType fsType, const char* contentPath) {
|
||||||
char sendStr[FS_MAX_PATH] = {0};
|
return fsOpenFileSystemWithId(out, 0, fsType, contentPath);
|
||||||
strncpy(sendStr, contentPath, sizeof(sendStr)-1);
|
|
||||||
|
|
||||||
IpcCommand c;
|
|
||||||
ipcInitialize(&c);
|
|
||||||
ipcAddSendStatic(&c, sendStr, sizeof(sendStr), 0);
|
|
||||||
|
|
||||||
struct {
|
|
||||||
u64 magic;
|
|
||||||
u64 cmd_id;
|
|
||||||
u32 fsType;
|
|
||||||
} *raw;
|
|
||||||
|
|
||||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
|
||||||
|
|
||||||
raw->magic = SFCI_MAGIC;
|
|
||||||
raw->cmd_id = 0;
|
|
||||||
raw->fsType = fsType;
|
|
||||||
|
|
||||||
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 fsOpenFileSystemWithId(FsFileSystem* out, u64 titleId, FsFileSystemType fsType, const char* contentPath) {
|
Result fsOpenFileSystemWithId(FsFileSystem* out, u64 titleId, FsFileSystemType fsType, const char* contentPath) {
|
||||||
@ -481,19 +445,34 @@ Result fsOpenFileSystemWithId(FsFileSystem* out, u64 titleId, FsFileSystemType f
|
|||||||
ipcInitialize(&c);
|
ipcInitialize(&c);
|
||||||
ipcAddSendStatic(&c, sendStr, sizeof(sendStr), 0);
|
ipcAddSendStatic(&c, sendStr, sizeof(sendStr), 0);
|
||||||
|
|
||||||
struct {
|
if (kernelAbove200()) {
|
||||||
u64 magic;
|
struct {
|
||||||
u64 cmd_id;
|
u64 magic;
|
||||||
u32 fsType;
|
u64 cmd_id;
|
||||||
u64 titleId;
|
u32 fsType;
|
||||||
} *raw;
|
u64 titleId;
|
||||||
|
} *raw;
|
||||||
|
|
||||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||||
|
|
||||||
raw->magic = SFCI_MAGIC;
|
raw->magic = SFCI_MAGIC;
|
||||||
raw->cmd_id = 8;
|
raw->cmd_id = 8;
|
||||||
raw->fsType = fsType;
|
raw->fsType = fsType;
|
||||||
raw->titleId = titleId;
|
raw->titleId = titleId;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
struct {
|
||||||
|
u64 magic;
|
||||||
|
u64 cmd_id;
|
||||||
|
u32 fsType;
|
||||||
|
} *raw;
|
||||||
|
|
||||||
|
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||||
|
|
||||||
|
raw->magic = SFCI_MAGIC;
|
||||||
|
raw->cmd_id = 0;
|
||||||
|
raw->fsType = fsType;
|
||||||
|
}
|
||||||
|
|
||||||
Result rc = serviceIpcDispatch(&g_fsSrv);
|
Result rc = serviceIpcDispatch(&g_fsSrv);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user