mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-22 21:02:39 +02:00
Fix fsOpenFileSystem (#153)
* Fix fsOpenFileSystem * Make fsOpenFileSystem and fsOpenFileSystemWithId work on all firmware versions * Add some comments for fsOpenFileSystem(WithId)
This commit is contained in:
parent
122fec028c
commit
dcdb5c28a4
@ -179,8 +179,8 @@ typedef enum
|
||||
} FsFileSystemType;
|
||||
|
||||
/// Mount requested filesystem type from content file
|
||||
Result fsOpenFileSystem(FsFileSystem* out, u64 titleId, FsFileSystemType fsType); /// only on 1.0.0, only works with registered content
|
||||
Result fsOpenFileSystemWithId(FsFileSystem* out, u64 titleId, FsFileSystemType fsType, const char* contentPath); /// 2.0.0+, contentPath must be resolved manually
|
||||
Result fsOpenFileSystem(FsFileSystem* out, FsFileSystemType fsType, const char* contentPath); /// same as calling fsOpenFileSystemWithId with 0 as titleId
|
||||
Result fsOpenFileSystemWithId(FsFileSystem* out, u64 titleId, FsFileSystemType fsType, const char* contentPath); /// works on all firmwares, titleId is ignored on 1.0.0
|
||||
|
||||
// IFileSystem
|
||||
Result fsFsCreateFile(FsFileSystem* fs, const char* path, size_t size, int flags);
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "result.h"
|
||||
#include "arm/atomics.h"
|
||||
#include "kernel/ipc.h"
|
||||
#include "kernel/detect.h"
|
||||
#include "services/fs.h"
|
||||
#include "services/sm.h"
|
||||
|
||||
@ -432,43 +433,8 @@ Result fsMount_SystemSaveData(FsFileSystem* out, u64 saveID) {
|
||||
return fsMountSystemSaveData(out, FsSaveDataSpaceId_NandSystem, &save);
|
||||
}
|
||||
|
||||
Result fsOpenFileSystem(FsFileSystem* out, u64 titleId, FsFileSystemType fsType) {
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
u32 fsType;
|
||||
u64 titleId;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 0;
|
||||
raw->fsType = fsType;
|
||||
raw->titleId = titleId;
|
||||
|
||||
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 fsOpenFileSystem(FsFileSystem* out, FsFileSystemType fsType, const char* contentPath) {
|
||||
return fsOpenFileSystemWithId(out, 0, fsType, contentPath);
|
||||
}
|
||||
|
||||
Result fsOpenFileSystemWithId(FsFileSystem* out, u64 titleId, FsFileSystemType fsType, const char* contentPath) {
|
||||
@ -479,19 +445,34 @@ Result fsOpenFileSystemWithId(FsFileSystem* out, u64 titleId, FsFileSystemType f
|
||||
ipcInitialize(&c);
|
||||
ipcAddSendStatic(&c, sendStr, sizeof(sendStr), 0);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
u32 fsType;
|
||||
u64 titleId;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 8;
|
||||
raw->fsType = fsType;
|
||||
raw->titleId = titleId;
|
||||
if (kernelAbove200()) {
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
u32 fsType;
|
||||
u64 titleId;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 8;
|
||||
raw->fsType = fsType;
|
||||
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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user