From 03a98635d8f6e9b3f6349288654b38b50d223db7 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sun, 11 Apr 2021 02:54:38 -0700 Subject: [PATCH] fs: add (stubbed) OperateRangeWithBuffer implementation --- .../fssrv_filesystem_interface_adapter.hpp | 1 + .../stratosphere/fssrv/sf/fssrv_sf_ifile.hpp | 15 ++++++++------- .../fssrv/fssrv_filesystem_interface_adapter.cpp | 6 ++++++ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_filesystem_interface_adapter.hpp b/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_filesystem_interface_adapter.hpp index 8acf9c2f1..cd20979f3 100644 --- a/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_filesystem_interface_adapter.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_filesystem_interface_adapter.hpp @@ -56,6 +56,7 @@ namespace ams::fssrv::impl { Result SetSize(s64 size); Result GetSize(ams::sf::Out out); Result OperateRange(ams::sf::Out out, s32 op_id, s64 offset, s64 size); + Result OperateRangeWithBuffer(const ams::sf::OutNonSecureBuffer &out_buf, const ams::sf::InNonSecureBuffer &in_buf, s32 op_id, s64 offset, s64 size); }; static_assert(fssrv::sf::IsIFile); diff --git a/libraries/libstratosphere/include/stratosphere/fssrv/sf/fssrv_sf_ifile.hpp b/libraries/libstratosphere/include/stratosphere/fssrv/sf/fssrv_sf_ifile.hpp index a449ec32c..df5b010e6 100644 --- a/libraries/libstratosphere/include/stratosphere/fssrv/sf/fssrv_sf_ifile.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssrv/sf/fssrv_sf_ifile.hpp @@ -19,12 +19,13 @@ #include #include -#define AMS_FSSRV_I_FILE_INTERFACE_INFO(C, H) \ - AMS_SF_METHOD_INFO(C, H, 0, Result, Read, (ams::sf::Out out, s64 offset, const ams::sf::OutNonSecureBuffer &buffer, s64 size, ams::fs::ReadOption option), (out, offset, buffer, size, option)) \ - AMS_SF_METHOD_INFO(C, H, 1, Result, Write, (s64 offset, const ams::sf::InNonSecureBuffer &buffer, s64 size, ams::fs::WriteOption option), (offset, buffer, size, option)) \ - AMS_SF_METHOD_INFO(C, H, 2, Result, Flush, (), ()) \ - AMS_SF_METHOD_INFO(C, H, 3, Result, SetSize, (s64 size), (size)) \ - AMS_SF_METHOD_INFO(C, H, 4, Result, GetSize, (ams::sf::Out out), (out)) \ - AMS_SF_METHOD_INFO(C, H, 5, Result, OperateRange, (ams::sf::Out out, s32 op_id, s64 offset, s64 size), (out, op_id, offset, size), hos::Version_4_0_0) +#define AMS_FSSRV_I_FILE_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, Read, (ams::sf::Out out, s64 offset, const ams::sf::OutNonSecureBuffer &buffer, s64 size, ams::fs::ReadOption option), (out, offset, buffer, size, option)) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, Write, (s64 offset, const ams::sf::InNonSecureBuffer &buffer, s64 size, ams::fs::WriteOption option), (offset, buffer, size, option)) \ + AMS_SF_METHOD_INFO(C, H, 2, Result, Flush, (), ()) \ + AMS_SF_METHOD_INFO(C, H, 3, Result, SetSize, (s64 size), (size)) \ + AMS_SF_METHOD_INFO(C, H, 4, Result, GetSize, (ams::sf::Out out), (out)) \ + AMS_SF_METHOD_INFO(C, H, 5, Result, OperateRange, (ams::sf::Out out, s32 op_id, s64 offset, s64 size), (out, op_id, offset, size), hos::Version_4_0_0) \ + AMS_SF_METHOD_INFO(C, H, 6, Result, OperateRangeWithBuffer, (const ams::sf::OutNonSecureBuffer &out_buf, const ams::sf::InNonSecureBuffer &in_buf, s32 op_id, s64 offset, s64 size), (out_buf, in_buf, op_id, offset, size), hos::Version_12_0_0) AMS_SF_DEFINE_INTERFACE(ams::fssrv::sf, IFile, AMS_FSSRV_I_FILE_INTERFACE_INFO) diff --git a/libraries/libstratosphere/source/fssrv/fssrv_filesystem_interface_adapter.cpp b/libraries/libstratosphere/source/fssrv/fssrv_filesystem_interface_adapter.cpp index f465b79dc..5648e79de 100644 --- a/libraries/libstratosphere/source/fssrv/fssrv_filesystem_interface_adapter.cpp +++ b/libraries/libstratosphere/source/fssrv/fssrv_filesystem_interface_adapter.cpp @@ -89,6 +89,12 @@ namespace ams::fssrv::impl { return ResultSuccess(); } + Result FileInterfaceAdapter::OperateRangeWithBuffer(const ams::sf::OutNonSecureBuffer &out_buf, const ams::sf::InNonSecureBuffer &in_buf, s32 op_id, s64 offset, s64 size) { + /* TODO: Nintendo supports calling info OperateRange using the provided buffers, when op_id is 4/5/6 or a class member is set. */ + /* We should (in the future), determine what uses this, and mimic Nintendo's behavior to the extent that we can. */ + return fs::ResultPermissionDenied(); + } + DirectoryInterfaceAdapter::DirectoryInterfaceAdapter(std::unique_ptr &&dir, FileSystemInterfaceAdapter *parent, util::unique_lock &&sema) : parent_filesystem(parent, true), base_dir(std::move(dir)), open_count_semaphore(std::move(sema)) {