mirror of
https://github.com/switchbrew/libnx.git
synced 2025-07-23 18:52:14 +02:00
fs: update bindings for 16.0.0 changes
fs: add new ContentAttributes enum fs: add version check fs: use hosversionBetween
This commit is contained in:
parent
6175293d0f
commit
b5e47b6b67
@ -328,6 +328,12 @@ typedef enum {
|
||||
FsPriority_Background = 3,
|
||||
} FsPriority;
|
||||
|
||||
/// FsContentAttributes
|
||||
typedef enum {
|
||||
FsContentAttributes_None = 0x0,
|
||||
FsContentAttributes_All = 0xF,
|
||||
} FsContentAttributes;
|
||||
|
||||
/// For use with fsOpenHostFileSystemWithOption
|
||||
typedef enum {
|
||||
FsMountHostOptionFlag_None = 0, ///< Host filesystem will be case insensitive.
|
||||
@ -350,7 +356,7 @@ void fsSetPriority(FsPriority prio);
|
||||
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 fsOpenFileSystemWithId(FsFileSystem* out, u64 id, FsFileSystemType fsType, const char* contentPath, FsContentAttributes attr); ///< works on all firmwares, id is ignored on [1.0.0], attr is ignored before [16.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);
|
||||
@ -399,11 +405,11 @@ Result fsOpenSdCardDetectionEventNotifier(FsEventNotifier* out);
|
||||
|
||||
Result fsIsSignedSystemPartitionOnSdCardValid(bool *out);
|
||||
|
||||
/// Retrieves the rights id corresponding to the content path. Only available on [2.0.0+].
|
||||
/// Retrieves the rights id corresponding to the content path. Only available on [2.0.0-15.0.1].
|
||||
Result fsGetRightsIdByPath(const char* path, FsRightsId* out_rights_id);
|
||||
|
||||
/// Retrieves the rights id and key generation corresponding to the content path. Only available on [3.0.0+].
|
||||
Result fsGetRightsIdAndKeyGenerationByPath(const char* path, u8* out_key_generation, FsRightsId* out_rights_id);
|
||||
/// Retrieves the rights id and key generation corresponding to the content path. Only available on [3.0.0+], attr is ignored before [16.0.0].
|
||||
Result fsGetRightsIdAndKeyGenerationByPath(const char* path, FsContentAttributes attr, u8* out_key_generation, FsRightsId* out_rights_id);
|
||||
|
||||
Result fsDisableAutoSaveDataCreation(void);
|
||||
|
||||
|
@ -26,5 +26,5 @@ void fsldrExit(void);
|
||||
/// Gets the Service object for the actual fsp-ldr service session.
|
||||
Service* fsldrGetServiceSession(void);
|
||||
|
||||
Result fsldrOpenCodeFileSystem(FsCodeInfo* out_code_info, u64 tid, const char *path, FsFileSystem* out);
|
||||
Result fsldrOpenCodeFileSystem(FsCodeInfo* out_code_info, u64 tid, const char *path, FsContentAttributes attr, FsFileSystem* out);
|
||||
Result fsldrIsArchivedProgram(u64 pid, bool *out);
|
||||
|
@ -133,7 +133,7 @@ static Result _fsCmdNoInOutBool(Service* srv, bool *out, u32 cmd_id) {
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
Result fsOpenFileSystem(FsFileSystem* out, FsFileSystemType fsType, const char* contentPath) {
|
||||
return fsOpenFileSystemWithId(out, 0, fsType, contentPath);
|
||||
return fsOpenFileSystemWithId(out, 0, fsType, contentPath, FsContentAttributes_None);
|
||||
}
|
||||
|
||||
static Result _fsOpenFileSystem(FsFileSystem* out, FsFileSystemType fsType, const char* contentPath) {
|
||||
@ -165,7 +165,21 @@ Result fsOpenFileSystemWithPatch(FsFileSystem* out, u64 id, FsFileSystemType fsT
|
||||
);
|
||||
}
|
||||
|
||||
static Result _fsOpenFileSystemWithId(FsFileSystem* out, u64 id, FsFileSystemType fsType, const char* contentPath) {
|
||||
static Result _fsOpenFileSystemWithId(FsFileSystem* out, u64 id, FsFileSystemType fsType, const char* contentPath, FsContentAttributes attr) {
|
||||
if (hosversionAtLeast(16,0,0)) {
|
||||
const struct {
|
||||
u8 attr;
|
||||
u32 fsType;
|
||||
u64 id;
|
||||
} in = { attr, fsType, id };
|
||||
|
||||
return _fsObjectDispatchIn(&g_fsSrv, 10, in,
|
||||
.buffer_attrs = { SfBufferAttr_HipcPointer | SfBufferAttr_In },
|
||||
.buffers = { { contentPath, FS_MAX_PATH } },
|
||||
.out_num_objects = 1,
|
||||
.out_objects = &out->s,
|
||||
);
|
||||
} else {
|
||||
const struct {
|
||||
u32 fsType;
|
||||
u64 id;
|
||||
@ -177,6 +191,7 @@ static Result _fsOpenFileSystemWithId(FsFileSystem* out, u64 id, FsFileSystemTyp
|
||||
.out_num_objects = 1,
|
||||
.out_objects = &out->s,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Result fsOpenDataFileSystemByProgramId(FsFileSystem *out, u64 program_id) {
|
||||
@ -189,12 +204,12 @@ Result fsOpenDataFileSystemByProgramId(FsFileSystem *out, u64 program_id) {
|
||||
);
|
||||
}
|
||||
|
||||
Result fsOpenFileSystemWithId(FsFileSystem* out, u64 id, FsFileSystemType fsType, const char* contentPath) {
|
||||
Result fsOpenFileSystemWithId(FsFileSystem* out, u64 id, FsFileSystemType fsType, const char* contentPath, FsContentAttributes attr) {
|
||||
char sendStr[FS_MAX_PATH] = {0};
|
||||
strncpy(sendStr, contentPath, sizeof(sendStr)-1);
|
||||
|
||||
if (hosversionAtLeast(2,0,0))
|
||||
return _fsOpenFileSystemWithId(out, id, fsType, sendStr);
|
||||
return _fsOpenFileSystemWithId(out, id, fsType, sendStr, attr);
|
||||
else
|
||||
return _fsOpenFileSystem(out, fsType, sendStr);
|
||||
}
|
||||
@ -520,7 +535,7 @@ Result fsIsSignedSystemPartitionOnSdCardValid(bool *out) {
|
||||
}
|
||||
|
||||
Result fsGetRightsIdByPath(const char* path, FsRightsId* out_rights_id) {
|
||||
if (hosversionBefore(2,0,0))
|
||||
if (!hosversionBetween(2, 16))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
|
||||
char send_path[FS_MAX_PATH] = {0};
|
||||
@ -532,23 +547,33 @@ Result fsGetRightsIdByPath(const char* path, FsRightsId* out_rights_id) {
|
||||
);
|
||||
}
|
||||
|
||||
Result fsGetRightsIdAndKeyGenerationByPath(const char* path, u8* out_key_generation, FsRightsId* out_rights_id) {
|
||||
Result fsGetRightsIdAndKeyGenerationByPath(const char* path, FsContentAttributes attr, u8* out_key_generation, FsRightsId* out_rights_id) {
|
||||
if (hosversionBefore(3,0,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
|
||||
char send_path[FS_MAX_PATH] = {0};
|
||||
strncpy(send_path, path, FS_MAX_PATH-1);
|
||||
|
||||
const u8 in = attr;
|
||||
|
||||
struct {
|
||||
u8 key_generation;
|
||||
u8 padding[0x7];
|
||||
FsRightsId rights_id;
|
||||
} out;
|
||||
|
||||
Result rc = _fsObjectDispatchOut(&g_fsSrv, 610, out,
|
||||
Result rc;
|
||||
if (hosversionAtLeast(16,0,0)) {
|
||||
rc = _fsObjectDispatchInOut(&g_fsSrv, 610, in, out,
|
||||
.buffer_attrs = { SfBufferAttr_HipcPointer | SfBufferAttr_In },
|
||||
.buffers = { { send_path, sizeof(send_path) } },
|
||||
);
|
||||
} else {
|
||||
rc = _fsObjectDispatchOut(&g_fsSrv, 610, out,
|
||||
.buffer_attrs = { SfBufferAttr_HipcPointer | SfBufferAttr_In },
|
||||
.buffers = { { send_path, sizeof(send_path) } },
|
||||
);
|
||||
}
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
if (out_key_generation) *out_key_generation = out.key_generation;
|
||||
|
@ -32,13 +32,32 @@ Service* fsldrGetServiceSession(void) {
|
||||
return &g_fsldrSrv;
|
||||
}
|
||||
|
||||
Result fsldrOpenCodeFileSystem(FsCodeInfo* out_code_info, u64 tid, const char *path, FsFileSystem* out) {
|
||||
Result fsldrOpenCodeFileSystem(FsCodeInfo* out_code_info, u64 tid, const char *path, FsContentAttributes attr, FsFileSystem* out) {
|
||||
memset(out_code_info, 0, sizeof(*out_code_info));
|
||||
|
||||
char send_path[FS_MAX_PATH]={0};
|
||||
strncpy(send_path, path, FS_MAX_PATH-1);
|
||||
|
||||
if (hosversionAtLeast(10,0,0)) {
|
||||
if (hosversionAtLeast(16,0,0)) {
|
||||
const struct {
|
||||
u8 attr;
|
||||
u64 tid;
|
||||
} in = { attr, tid };
|
||||
|
||||
serviceAssumeDomain(&g_fsldrSrv);
|
||||
return serviceDispatchIn(&g_fsldrSrv, 0, in,
|
||||
.buffer_attrs = {
|
||||
SfBufferAttr_FixedSize | SfBufferAttr_HipcPointer | SfBufferAttr_Out,
|
||||
SfBufferAttr_FixedSize | SfBufferAttr_HipcPointer | SfBufferAttr_In,
|
||||
},
|
||||
.buffers = {
|
||||
{ out_code_info, sizeof(*out_code_info) },
|
||||
{ send_path, FS_MAX_PATH },
|
||||
},
|
||||
.out_num_objects = 1,
|
||||
.out_objects = &out->s,
|
||||
);
|
||||
} else if (hosversionAtLeast(10,0,0)) {
|
||||
serviceAssumeDomain(&g_fsldrSrv);
|
||||
return serviceDispatchIn(&g_fsldrSrv, 0, tid,
|
||||
.buffer_attrs = {
|
||||
|
Loading…
Reference in New Issue
Block a user