fs.mitm: mitm StorageForBatchRead as well as previously missing FileSystem/DataStorage commands

This commit is contained in:
hexkyz committed 2026-10-09 20:09:52 +01:00
1 parent 36cc9a9f49
commit 0e9cd964c0
16 files changed
+717 -139

No files matched your search

@@ -18,10 +18,12 @@
#include <stratosphere/fs/fs_query_range.hpp>
#include <stratosphere/fssystem/fssystem_utility.hpp>
#include <stratosphere/fssrv/sf/fssrv_sf_istorage.hpp>
#include <stratosphere/fssrv/sf/fssrv_sf_istorage_for_batch_read.hpp>
namespace ams::fs {
class IStorage;
class IStorageForBatchRead;
}
@@ -44,6 +46,16 @@ namespace ams::fssrv::impl {
Result OperateRange(ams::sf::Out<fs::StorageQueryRangeInfo> out, s32 op_id, s64 offset, s64 size);
};
static_assert(fssrv::sf::IsIStorage<StorageInterfaceAdapter>);
class StorageInterfaceAdapterForBatchRead : public StorageInterfaceAdapter {
NON_COPYABLE(StorageInterfaceAdapterForBatchRead);
public:
explicit StorageInterfaceAdapterForBatchRead(std::shared_ptr<fs::IStorageForBatchRead> &&storage) : StorageInterfaceAdapter(storage) { /* ... */ }
public:
/* Command API. */
Result BatchRead(const ams::sf::OutNonSecureBuffer &out0, const ams::sf::OutNonSecureBuffer &out1, const ams::sf::OutNonSecureBuffer &out2, const ams::sf::OutNonSecureBuffer &out3, const ams::sf::OutNonSecureBuffer &out4, const ams::sf::OutNonSecureBuffer &out5, const ams::sf::OutNonSecureBuffer &out6, const ams::sf::InBuffer &in);
};
static_assert(fssrv::sf::IsIStorageForBatchRead<StorageInterfaceAdapterForBatchRead>);
#if defined(ATMOSPHERE_OS_HORIZON)
class RemoteStorage {
@@ -82,6 +94,47 @@ namespace ams::fssrv::impl {
}
};
static_assert(fssrv::sf::IsIStorage<RemoteStorage>);
class RemoteStorageForBatchRead {
NON_COPYABLE(RemoteStorageForBatchRead);
NON_MOVEABLE(RemoteStorageForBatchRead);
private:
::FsStorageForBatchRead m_base_storage;
public:
RemoteStorageForBatchRead(::FsStorageForBatchRead &s) : m_base_storage(s) { /* ... */}
virtual ~RemoteStorageForBatchRead() { fsStorageForBatchReadClose(std::addressof(m_base_storage)); }
public:
Result Read(s64 offset, const ams::sf::OutNonSecureBuffer &buffer, s64 size) {
R_RETURN(fsStorageForBatchReadRead(std::addressof(m_base_storage), offset, buffer.GetPointer(), size));
}
Result Write(s64 offset, const ams::sf::InNonSecureBuffer &buffer, s64 size) {
R_RETURN(fsStorageForBatchReadWrite(std::addressof(m_base_storage), offset, buffer.GetPointer(), size));
}
Result Flush(){
R_RETURN(fsStorageForBatchReadFlush(std::addressof(m_base_storage)));
}
Result SetSize(s64 size) {
R_RETURN(fsStorageForBatchReadSetSize(std::addressof(m_base_storage), size));
}
Result GetSize(ams::sf::Out<s64> out) {
R_RETURN(fsStorageForBatchReadGetSize(std::addressof(m_base_storage), out.GetPointer()));
}
Result OperateRange(ams::sf::Out<fs::StorageQueryRangeInfo> out, s32 op_id, s64 offset, s64 size) {
static_assert(sizeof(::FsRangeInfo) == sizeof(fs::StorageQueryRangeInfo));
R_RETURN(fsStorageForBatchReadOperateRange(std::addressof(m_base_storage), static_cast<::FsOperationId>(op_id), offset, size, reinterpret_cast<::FsRangeInfo *>(out.GetPointer())));
}
Result BatchRead(const ams::sf::OutNonSecureBuffer &out0, const ams::sf::OutNonSecureBuffer &out1, const ams::sf::OutNonSecureBuffer &out2, const ams::sf::OutNonSecureBuffer &out3, const ams::sf::OutNonSecureBuffer &out4, const ams::sf::OutNonSecureBuffer &out5, const ams::sf::OutNonSecureBuffer &out6, const ams::sf::InBuffer &in) {
R_RETURN(fsStorageForBatchReadBatchRead(std::addressof(m_base_storage), out0.GetPointer(), out1.GetPointer(), out2.GetPointer(), out3.GetPointer(), out4.GetPointer(), out5.GetPointer(), out6.GetPointer(), in.GetPointer()));
}
};
static_assert(fssrv::sf::IsIStorageForBatchRead<RemoteStorageForBatchRead>);
#endif
}