mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-22 04:52:39 +02:00
Add fsOpenBisStorage and fsStorageGetSize (#130)
* add fsOpenBisStorage and fsStorageGetSize
This commit is contained in:
parent
eb93b232ef
commit
9530da3237
@ -144,6 +144,8 @@ void fsExit(void);
|
|||||||
|
|
||||||
Service* fsGetServiceSession(void);
|
Service* fsGetServiceSession(void);
|
||||||
|
|
||||||
|
Result fsOpenBisStorage(FsStorage* out, u32 PartitionId);
|
||||||
|
|
||||||
/// Do not call this directly, see fs_dev.h.
|
/// Do not call this directly, see fs_dev.h.
|
||||||
Result fsMountSdcard(FsFileSystem* out);
|
Result fsMountSdcard(FsFileSystem* out);
|
||||||
|
|
||||||
@ -196,6 +198,7 @@ void fsDirClose(FsDir* d);
|
|||||||
|
|
||||||
// IStorage
|
// IStorage
|
||||||
Result fsStorageRead(FsStorage* s, u64 off, void* buf, size_t len);
|
Result fsStorageRead(FsStorage* s, u64 off, void* buf, size_t len);
|
||||||
|
Result fsStorageGetSize(FsStorage* s, u64* out);
|
||||||
void fsStorageClose(FsStorage* s);
|
void fsStorageClose(FsStorage* s);
|
||||||
|
|
||||||
// ISaveDataInfoReader
|
// ISaveDataInfoReader
|
||||||
|
@ -64,6 +64,43 @@ Service* fsGetServiceSession(void) {
|
|||||||
return &g_fsSrv;
|
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) {
|
Result fsMountSdcard(FsFileSystem* out) {
|
||||||
IpcCommand c;
|
IpcCommand c;
|
||||||
ipcInitialize(&c);
|
ipcInitialize(&c);
|
||||||
@ -1106,6 +1143,39 @@ Result fsStorageRead(FsStorage* s, u64 off, void* buf, size_t len) {
|
|||||||
return rc;
|
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) {
|
void fsStorageClose(FsStorage* s) {
|
||||||
serviceClose(&s->s);
|
serviceClose(&s->s);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user