From d6a33450bdb408264716b970ff0ac5053a895c84 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Wed, 18 Jul 2018 14:24:36 -0400 Subject: [PATCH] Fix puyo regression --- src/core/hle/service/filesystem/fsp_srv.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp index af9227ac89..1b003bd843 100644 --- a/src/core/hle/service/filesystem/fsp_srv.cpp +++ b/src/core/hle/service/filesystem/fsp_srv.cpp @@ -110,7 +110,7 @@ private: IPC::ResponseBuilder rb{ctx, 4}; rb.Push(RESULT_SUCCESS); - rb.Push(output.size()); + rb.Push(static_cast(output.size())); } void Write(Kernel::HLERequestContext& ctx) { @@ -134,12 +134,23 @@ private: } std::vector data = ctx.ReadBuffer(); - data.resize(length); + std::vector actual_data(length); + + ASSERT_MSG( + data.size() <= length, + "Attempting to write more data than requested (requested={:016X}, actual={:016X}).", + length, data.size()); + + std::copy(data.begin(), data.end(), actual_data.begin()); // Write the data to the Storage backend - auto res = MakeResult(backend->WriteBytes(data, offset)); + auto written = backend->WriteBytes(data, offset); + + ASSERT_MSG(written == length, + "Could not write all bytes to file (requested={:016X}, actual={:016X}).", length, + written); IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(res.Code()); + rb.Push(RESULT_SUCCESS); } void Flush(Kernel::HLERequestContext& ctx) { @@ -194,6 +205,7 @@ public: }; RegisterHandlers(functions); + // TODO(DarkLordZach): Verify that this is the correct behavior. // Build entry index now to save time later. BuildEntryIndex(entries, backend->GetFiles(), FileSys::File); BuildEntryIndex(entries, backend->GetSubdirectories(), FileSys::Directory);