mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 12:21:18 +00:00
fs.mitm: fix some filesystem issues
This commit is contained in:
parent
106ae81614
commit
ad8acaefec
8 changed files with 22 additions and 10 deletions
|
@ -72,7 +72,7 @@ class IFile {
|
|||
}
|
||||
|
||||
Result Write(uint64_t offset, void *buffer, uint64_t size) {
|
||||
return Write(offset, buffer, size, false);
|
||||
return WriteImpl(offset, buffer, size, false);
|
||||
}
|
||||
|
||||
Result SetSize(uint64_t size) {
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
#include <switch.h>
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
#include "../utils.hpp"
|
||||
|
||||
#include "fs_results.hpp"
|
||||
#include "fs_filesystem_types.hpp"
|
||||
#include "fs_path_utils.hpp"
|
||||
|
@ -108,7 +110,7 @@ class IFileSystem {
|
|||
if (mode & ~DirectoryOpenMode_All) {
|
||||
return ResultFsInvalidArgument;
|
||||
}
|
||||
return OpenDirectory(out_dir, path, mode);
|
||||
return OpenDirectoryImpl(out_dir, path, mode);
|
||||
}
|
||||
|
||||
Result Commit() {
|
||||
|
@ -333,10 +335,12 @@ class IFileSystemInterface : public IServiceObject {
|
|||
}
|
||||
|
||||
rc = this->base_fs->OpenDirectory(out_dir, path, static_cast<DirectoryOpenMode>(mode));
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
out_intf.SetValue(std::make_shared<IDirectoryInterface>(std::move(out_dir)));
|
||||
/* TODO: Nintendo checks allocation success here, should we?. */
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
|
@ -150,13 +150,13 @@ Result FsPathUtils::IsNormalized(bool *out, const char *path) {
|
|||
case PathState::WindowsDriveLetter:
|
||||
return ResultFsInvalidPathFormat;
|
||||
case PathState::FirstSeparator:
|
||||
case PathState::Separator:
|
||||
*out = false;
|
||||
break;
|
||||
case PathState::Normal:
|
||||
*out = true;
|
||||
break;
|
||||
case PathState::CurrentDir:
|
||||
case PathState::ParentDir:
|
||||
*out = true;
|
||||
case PathState::Separator:
|
||||
*out = false;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <switch.h>
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
#include "../utils.hpp"
|
||||
#include "fs_subdirectory_filesystem.hpp"
|
||||
#include "fs_path_utils.hpp"
|
||||
|
||||
|
|
|
@ -111,7 +111,8 @@ Result FsMitmService::OpenHblWebContentFileSystem(Out<std::shared_ptr<IFileSyste
|
|||
|
||||
Result FsMitmService::OpenFileSystemWithPatch(Out<std::shared_ptr<IFileSystemInterface>> out_fs, u64 title_id, u32 filesystem_type) {
|
||||
FsDir d;
|
||||
if (filesystem_type != FsFileSystemType_ContentManual || !Utils::IsHblTid(title_id) || R_FAILED(Utils::OpenSdDir(AtmosphereHblWebContentDir, &d))) {
|
||||
if (!Utils::IsWebAppletTid(this->title_id) || filesystem_type != FsFileSystemType_ContentManual || !Utils::IsHblTid(title_id) ||
|
||||
R_FAILED(Utils::OpenSdDir(AtmosphereHblWebContentDir, &d))) {
|
||||
return RESULT_FORWARD_TO_SESSION;
|
||||
}
|
||||
fsDirClose(&d);
|
||||
|
@ -121,11 +122,12 @@ Result FsMitmService::OpenFileSystemWithPatch(Out<std::shared_ptr<IFileSystemInt
|
|||
|
||||
Result FsMitmService::OpenFileSystemWithId(Out<std::shared_ptr<IFileSystemInterface>> out_fs, InPointer<char> path, u64 title_id, u32 filesystem_type) {
|
||||
FsDir d;
|
||||
if (filesystem_type != FsFileSystemType_ContentManual || !Utils::IsHblTid(title_id) || R_FAILED(Utils::OpenSdDir(AtmosphereHblWebContentDir, &d))) {
|
||||
if (!Utils::IsWebAppletTid(this->title_id) || filesystem_type != FsFileSystemType_ContentManual || !Utils::IsHblTid(title_id) ||
|
||||
R_FAILED(Utils::OpenSdDir(AtmosphereHblWebContentDir, &d))) {
|
||||
return RESULT_FORWARD_TO_SESSION;
|
||||
}
|
||||
fsDirClose(&d);
|
||||
|
||||
|
||||
return this->OpenHblWebContentFileSystem(out_fs);
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ class FsMitmService : public IMitmServiceObject {
|
|||
DEFINE_SERVICE_DISPATCH_TABLE {
|
||||
/* TODO MakeServiceCommandMeta<FspSrvCmd_OpenFileSystemDeprecated, &FsMitmService::OpenFileSystemDeprecated>(), */
|
||||
MakeServiceCommandMeta<FspSrvCmd_OpenFileSystemWithPatch, &FsMitmService::OpenFileSystemWithPatch, FirmwareVersion_200>(),
|
||||
MakeServiceCommandMeta<FspSrvCmd_OpenFileSystemDeprecated, &FsMitmService::OpenFileSystemWithId, FirmwareVersion_200>(),
|
||||
MakeServiceCommandMeta<FspSrvCmd_OpenFileSystemWithId, &FsMitmService::OpenFileSystemWithId, FirmwareVersion_200>(),
|
||||
MakeServiceCommandMeta<FspSrvCmd_OpenBisStorage, &FsMitmService::OpenBisStorage>(),
|
||||
MakeServiceCommandMeta<FspSrvCmd_OpenDataStorageByCurrentProcess, &FsMitmService::OpenDataStorageByCurrentProcess>(),
|
||||
MakeServiceCommandMeta<FspSrvCmd_OpenDataStorageByDataId, &FsMitmService::OpenDataStorageByDataId>(),
|
||||
|
|
|
@ -383,6 +383,10 @@ bool Utils::IsHblTid(u64 tid) {
|
|||
return (g_hbl_override_config.override_any_app && IsApplicationTid(tid)) || (tid == g_hbl_override_config.title_id);
|
||||
}
|
||||
|
||||
bool Utils::IsWebAppletTid(u64 tid) {
|
||||
return tid == 0x010000000000100Aul || tid == 0x010000000000100Ful || tid == 0x0100000000001010ul || tid == 0x0100000000001011ul;
|
||||
}
|
||||
|
||||
bool Utils::HasTitleFlag(u64 tid, const char *flag) {
|
||||
if (IsSdInitialized()) {
|
||||
FsFile f;
|
||||
|
|
|
@ -65,6 +65,7 @@ class Utils {
|
|||
static void InitializeThreadFunc(void *args);
|
||||
|
||||
static bool IsHblTid(u64 tid);
|
||||
static bool IsWebAppletTid(u64 tid);
|
||||
|
||||
static bool HasTitleFlag(u64 tid, const char *flag);
|
||||
static bool HasHblFlag(const char *flag);
|
||||
|
|
Loading…
Reference in a new issue