summaryrefslogtreecommitdiff
path: root/src/core/hle
diff options
context:
space:
mode:
authorGravatar Subv2015-12-28 10:03:09 -0500
committerGravatar Subv2016-03-20 14:28:17 -0500
commit96f0e32f836b19edb3d14ce4f87a7aed1ac6a8e1 (patch)
tree9eed35100efe7714f7ef5a39ff2c3bbf897f3dae /src/core/hle
parentHLE/FS: Corrected the error codes for DeleteFile (diff)
downloadyuzu-96f0e32f836b19edb3d14ce4f87a7aed1ac6a8e1.tar.gz
yuzu-96f0e32f836b19edb3d14ce4f87a7aed1ac6a8e1.tar.xz
yuzu-96f0e32f836b19edb3d14ce4f87a7aed1ac6a8e1.zip
HLE/FS: Return the proper error codes on file Read/Write operations.
These operations are limited by the open flags specified while opening the file.
Diffstat (limited to 'src/core/hle')
-rw-r--r--src/core/hle/result.h1
-rw-r--r--src/core/hle/service/fs/archive.cpp17
2 files changed, 16 insertions, 2 deletions
diff --git a/src/core/hle/result.h b/src/core/hle/result.h
index b9ee5f7d9..b68c0ff0d 100644
--- a/src/core/hle/result.h
+++ b/src/core/hle/result.h
@@ -21,6 +21,7 @@ enum class ErrorDescription : u32 {
21 WrongAddress = 53, 21 WrongAddress = 53,
22 FS_NotFound = 120, 22 FS_NotFound = 120,
23 FS_AlreadyExists = 190, 23 FS_AlreadyExists = 190,
24 FS_InvalidOpenFlags = 230,
24 FS_NotAFile = 250, 25 FS_NotAFile = 250,
25 FS_NotFormatted = 340, ///< This is used by the FS service when creating a SaveData archive 26 FS_NotFormatted = 340, ///< This is used by the FS service when creating a SaveData archive
26 InvalidSection = 1000, 27 InvalidSection = 1000,
diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp
index cb98fa7aa..8c38c3ba4 100644
--- a/src/core/hle/service/fs/archive.cpp
+++ b/src/core/hle/service/fs/archive.cpp
@@ -103,7 +103,14 @@ ResultVal<bool> File::SyncRequest() {
103 u32 address = cmd_buff[5]; 103 u32 address = cmd_buff[5];
104 LOG_TRACE(Service_FS, "Read %s %s: offset=0x%llx length=%d address=0x%x", 104 LOG_TRACE(Service_FS, "Read %s %s: offset=0x%llx length=%d address=0x%x",
105 GetTypeName().c_str(), GetName().c_str(), offset, length, address); 105 GetTypeName().c_str(), GetName().c_str(), offset, length, address);
106 cmd_buff[2] = static_cast<u32>(backend->Read(offset, length, Memory::GetPointer(address))); 106 if (offset + length > backend->GetSize())
107 LOG_ERROR(Service_FS, "Reading from out of bounds offset=0x%llX length=0x%08X file_size=0x%llX", offset, length, backend->GetSize());
108 ResultVal<size_t> read = backend->Read(offset, length, Memory::GetPointer(address));
109 if (read.Failed()) {
110 cmd_buff[1] = read.Code().raw;
111 return read.Code();
112 }
113 cmd_buff[2] = static_cast<u32>(read.MoveFrom());
107 break; 114 break;
108 } 115 }
109 116
@@ -116,7 +123,13 @@ ResultVal<bool> File::SyncRequest() {
116 u32 address = cmd_buff[6]; 123 u32 address = cmd_buff[6];
117 LOG_TRACE(Service_FS, "Write %s %s: offset=0x%llx length=%d address=0x%x, flush=0x%x", 124 LOG_TRACE(Service_FS, "Write %s %s: offset=0x%llx length=%d address=0x%x, flush=0x%x",
118 GetTypeName().c_str(), GetName().c_str(), offset, length, address, flush); 125 GetTypeName().c_str(), GetName().c_str(), offset, length, address, flush);
119 cmd_buff[2] = static_cast<u32>(backend->Write(offset, length, flush != 0, Memory::GetPointer(address))); 126
127 ResultVal<size_t> written = backend->Write(offset, length, flush != 0, Memory::GetPointer(address));
128 if (written.Failed()) {
129 cmd_buff[1] = written.Code().raw;
130 return written.Code();
131 }
132 cmd_buff[2] = static_cast<u32>(written.MoveFrom());
120 break; 133 break;
121 } 134 }
122 135