Add fsOpenBisStorage and fsStorageGetSize (#130)

* add fsOpenBisStorage and fsStorageGetSize
This commit is contained in:
tesnos 2018-07-19 11:16:38 -04:00 committed by yellows8
parent eb93b232ef
commit 9530da3237
2 changed files with 73 additions and 0 deletions

View File

@ -144,6 +144,8 @@ void fsExit(void);
Service* fsGetServiceSession(void);
Result fsOpenBisStorage(FsStorage* out, u32 PartitionId);
/// Do not call this directly, see fs_dev.h.
Result fsMountSdcard(FsFileSystem* out);
@ -196,6 +198,7 @@ void fsDirClose(FsDir* d);
// IStorage
Result fsStorageRead(FsStorage* s, u64 off, void* buf, size_t len);
Result fsStorageGetSize(FsStorage* s, u64* out);
void fsStorageClose(FsStorage* s);
// ISaveDataInfoReader

View File

@ -64,6 +64,43 @@ Service* fsGetServiceSession(void) {
return &g_fsSrv;
}
Result fsOpenBisStorage(FsStorage* out, u32 PartitionId) {
IpcCommand c;
ipcInitialize(&c);
struct {
u64 magic;
u64 cmd_id;
u32 PartitionId;
} *raw;
raw = ipcPrepareHeader(&c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
raw->cmd_id = 12;
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);
@ -1106,6 +1143,39 @@ Result fsStorageRead(FsStorage* s, u64 off, void* buf, size_t len) {
return rc;
}
Result fsStorageGetSize(FsStorage* s, u64* out) {
IpcCommand c;
ipcInitialize(&c);
struct {
u64 magic;
u64 cmd_id;
} *raw;
raw = ipcPrepareHeader(&c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
raw->cmd_id = 4;
Result rc = serviceIpcDispatch(&s->s);
if (R_SUCCEEDED(rc)) {
IpcParsedCommand r;
ipcParse(&r);
struct {
u64 magic;
u64 result;
u64 size;
} *resp = r.Raw;
rc = resp->result;
if (R_SUCCEEDED(rc) && out) *out = resp->size;
}
return rc;
}
void fsStorageClose(FsStorage* s) {
serviceClose(&s->s);
}