mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 12:32:40 +02:00
add commands for accessing process storage (#485)
This commit is contained in:
parent
eb9d377320
commit
ac468913e4
@ -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 romfsMountDataStorageFromProgram(u64 program_id, const char *name);
|
||||
|
||||
/**
|
||||
* @brief Mounts RomFS from a file path in a mounted fsdev device.
|
||||
* @param path File path.
|
||||
|
@ -313,9 +313,10 @@ void fsSetPriority(FsPriority prio);
|
||||
|
||||
/// Mount requested filesystem type from content file
|
||||
Result fsOpenFileSystem(FsFileSystem* out, FsFileSystemType fsType, const char* contentPath); ///< same as calling fsOpenFileSystemWithId with 0 as id
|
||||
Result fsOpenDataFileSystemByCurrentProcess(FsFileSystem *out);
|
||||
Result fsOpenFileSystemWithPatch(FsFileSystem* out, u64 id, FsFileSystemType fsType); ///< [2.0.0+], like OpenFileSystemWithId but without content path.
|
||||
Result fsOpenFileSystemWithId(FsFileSystem* out, u64 id, FsFileSystemType fsType, const char* contentPath); ///< works on all firmwares, id is ignored on [1.0.0]
|
||||
|
||||
Result fsOpenDataFileSystemByProgramId(FsFileSystem *out, u64 program_id); ///< [3.0.0+]
|
||||
Result fsOpenBisFileSystem(FsFileSystem* out, FsBisPartitionId partitionId, const char* string);
|
||||
Result fsOpenBisStorage(FsStorage* out, FsBisPartitionId partitionId);
|
||||
|
||||
@ -346,7 +347,9 @@ Result fsOpenContentStorageFileSystem(FsFileSystem* out, FsContentStorageId cont
|
||||
Result fsOpenCustomStorageFileSystem(FsFileSystem* out, FsCustomStorageId custom_storage_id); ///< [7.0.0+]
|
||||
|
||||
Result fsOpenDataStorageByCurrentProcess(FsStorage* out);
|
||||
Result fsOpenDataStorageByProgramId(FsStorage *out, u64 program_id); /// <[3.0.0+]
|
||||
Result fsOpenDataStorageByDataId(FsStorage* out, u64 dataId, NcmStorageId storageId);
|
||||
Result fsOpenPatchDataStorageByCurrentProcess(FsStorage* out);
|
||||
|
||||
Result fsOpenDeviceOperator(FsDeviceOperator* out);
|
||||
Result fsOpenSdCardDetectionEventNotifier(FsEventNotifier* out);
|
||||
|
@ -342,6 +342,16 @@ Result romfsMountFromCurrentProcess(const char *name) {
|
||||
return romfsMountFromStorage(storage, 0, name);
|
||||
}
|
||||
|
||||
Result romfsMountDataStorageFromProgram(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;
|
||||
|
@ -146,6 +146,10 @@ static Result _fsOpenFileSystem(FsFileSystem* out, FsFileSystemType fsType, cons
|
||||
);
|
||||
}
|
||||
|
||||
Result fsOpenDataFileSystemByCurrentProcess(FsFileSystem *out) {
|
||||
return _fsCmdGetSession(&g_fsSrv, &out->s, 2);
|
||||
}
|
||||
|
||||
Result fsOpenFileSystemWithPatch(FsFileSystem* out, u64 id, FsFileSystemType fsType) {
|
||||
if (hosversionBefore(2,0,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
@ -175,6 +179,16 @@ static Result _fsOpenFileSystemWithId(FsFileSystem* out, u64 id, FsFileSystemTyp
|
||||
);
|
||||
}
|
||||
|
||||
Result fsOpenDataFileSystemByProgramId(FsFileSystem *out, u64 program_id) {
|
||||
if (hosversionBefore(3,0,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
|
||||
return _fsObjectDispatchIn(&g_fsSrv, 9, program_id,
|
||||
.out_num_objects = 1,
|
||||
.out_objects = &out->s,
|
||||
);
|
||||
}
|
||||
|
||||
Result fsOpenFileSystemWithId(FsFileSystem* out, u64 id, FsFileSystemType fsType, const char* contentPath) {
|
||||
char sendStr[FS_MAX_PATH] = {0};
|
||||
strncpy(sendStr, contentPath, sizeof(sendStr)-1);
|
||||
@ -398,6 +412,16 @@ Result fsOpenDataStorageByCurrentProcess(FsStorage* out) {
|
||||
return _fsCmdGetSession(&g_fsSrv, &out->s, 200);
|
||||
}
|
||||
|
||||
Result fsOpenDataStorageByProgramId(FsStorage *out, u64 program_id) {
|
||||
if (hosversionBefore(3,0,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
|
||||
return _fsObjectDispatchIn(&g_fsSrv, 201, program_id,
|
||||
.out_num_objects = 1,
|
||||
.out_objects = &out->s,
|
||||
);
|
||||
}
|
||||
|
||||
Result fsOpenDataStorageByDataId(FsStorage* out, u64 dataId, NcmStorageId storageId) {
|
||||
const struct {
|
||||
u8 storage_id;
|
||||
@ -410,6 +434,10 @@ Result fsOpenDataStorageByDataId(FsStorage* out, u64 dataId, NcmStorageId storag
|
||||
);
|
||||
}
|
||||
|
||||
Result fsOpenPatchDataStorageByCurrentProcess(FsStorage* out) {
|
||||
return _fsCmdGetSession(&g_fsSrv, &out->s, 203);
|
||||
}
|
||||
|
||||
Result fsOpenDeviceOperator(FsDeviceOperator* out) {
|
||||
return _fsCmdGetSession(&g_fsSrv, &out->s, 400);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user