fs/fs_dev: Added FsFileSystemQueryId_IsValidSignedSystemPartitionOnSdCard, fsFsIsValidSignedSystemPartitionOnSdCard, and fsdevIsValidSignedSystemPartitionOnSdCard. Improved docs.

This commit is contained in:
yellows8 2019-11-28 18:51:52 -05:00
parent dea3f140f1
commit 5182b57a1d
No known key found for this signature in database
GPG Key ID: 0AF90DA3F1E60E43
4 changed files with 30 additions and 1 deletions

View File

@ -56,6 +56,9 @@ int fsdevTranslatePath(const char *path, FsFileSystem** device, char *outpath);
/// This calls fsFsSetConcatenationFileAttribute on the filesystem specified by the input path (as used in stdio).
Result fsdevSetConcatenationFileAttribute(const char *path);
// Uses \ref fsFsIsValidSignedSystemPartitionOnSdCard with the specified device.
Result fsdevIsValidSignedSystemPartitionOnSdCard(const char *name, bool *out);
/// This calls fsFsCreateFile on the filesystem specified by the input path (as used in stdio).
Result fsdevCreateFile(const char* path, size_t size, u32 flags);

View File

@ -272,8 +272,10 @@ typedef enum {
FsFileSystemType_RegisteredUpdate = 8, ///< [4.0.0+] RegisteredUpdate
} FsFileSystemType;
/// FileSystemQueryId
typedef enum {
FsFileSystemQueryId_SetConcatenationFileAttribute = 0,
FsFileSystemQueryId_SetConcatenationFileAttribute = 0, ///< [4.0.0+]
FsFileSystemQueryId_IsValidSignedSystemPartitionOnSdCard = 2, ///< [8.0.0+]
} FsFileSystemQueryId;
/// FsPriority
@ -380,6 +382,10 @@ void fsFsClose(FsFileSystem* fs);
/// This will cause HOS to treat the directory as if it were a file containing the directory's concatenated contents.
Result fsFsSetConcatenationFileAttribute(FsFileSystem* fs, const char *path);
/// Wrapper for fsFsQueryEntry with FsFileSystemQueryId_IsValidSignedSystemPartitionOnSdCard.
/// Only available on [8.0.0+].
Result fsFsIsValidSignedSystemPartitionOnSdCard(FsFileSystem* fs, bool *out);
// IFile
Result fsFileRead(FsFile* f, s64 off, void* buf, u64 read_size, u32 option, u64* bytes_read);
Result fsFileWrite(FsFile* f, s64 off, const void* buf, u64 write_size, u32 option);

View File

@ -407,6 +407,16 @@ Result fsdevSetConcatenationFileAttribute(const char *path) {
return fsFsSetConcatenationFileAttribute(&device->fs, fs_path);
}
Result fsdevIsValidSignedSystemPartitionOnSdCard(const char *name, bool *out) {
fsdev_fsdevice *device;
device = fsdevFindDevice(name);
if(device==NULL)
return MAKERESULT(Module_Libnx, LibnxError_NotFound);
return fsFsIsValidSignedSystemPartitionOnSdCard(&device->fs, out);
}
Result fsdevCreateFile(const char* path, size_t size, u32 flags) {
char *fs_path = __nx_dev_path_buf;
fsdev_fsdevice *device = NULL;

View File

@ -635,6 +635,16 @@ Result fsFsSetConcatenationFileAttribute(FsFileSystem* fs, const char *path) {
return fsFsQueryEntry(fs, NULL, 0, NULL, 0, path, FsFileSystemQueryId_SetConcatenationFileAttribute);
}
Result fsFsIsValidSignedSystemPartitionOnSdCard(FsFileSystem* fs, bool *out) {
if (hosversionBefore(8,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
u8 tmp=0;
Result rc = fsFsQueryEntry(fs, &tmp, sizeof(tmp), NULL, 0, "/", FsFileSystemQueryId_IsValidSignedSystemPartitionOnSdCard);
if (R_SUCCEEDED(rc) && out) *out = tmp & 1;
return rc;
}
void fsFsClose(FsFileSystem* fs) {
_fsObjectClose(&fs->s);
}