IOS HLE: Clean up return codes

- Use an enum instead of defines.

- Only use the FS_ prefix for return codes which are actually related
  to FS stuff, not for everything.

- Remove duplicated error codes and clean up the names.
This commit is contained in:
Léo Lam 2016-12-09 20:29:12 +01:00
parent 7a5fe4b7ed
commit 7dcb3c5d55
11 changed files with 80 additions and 93 deletions

View File

@ -378,7 +378,7 @@ static s32 OpenDevice(const u32 address)
{ {
device = GetUnusedESDevice(); device = GetUnusedESDevice();
if (!device) if (!device)
return FS_EESEXHAUSTED; return IPC_EESEXHAUSTED;
} }
else if (device_name.find("/dev/") == 0) else if (device_name.find("/dev/") == 0)
{ {
@ -392,7 +392,7 @@ static s32 OpenDevice(const u32 address)
if (!device) if (!device)
{ {
ERROR_LOG(WII_IPC_HLE, "Unknown device: %s", device_name.c_str()); ERROR_LOG(WII_IPC_HLE, "Unknown device: %s", device_name.c_str());
return FS_ENOENT; return IPC_ENOENT;
} }
Memory::Write_U32(new_fd, address + 4); Memory::Write_U32(new_fd, address + 4);
@ -418,7 +418,7 @@ static IPCCommandResult HandleCommand(const u32 address)
const auto device = (fd >= 0 && fd < IPC_MAX_FDS) ? s_fdmap[fd] : nullptr; const auto device = (fd >= 0 && fd < IPC_MAX_FDS) ? s_fdmap[fd] : nullptr;
if (!device) if (!device)
{ {
Memory::Write_U32(FS_EINVAL, address + 4); Memory::Write_U32(IPC_EINVAL, address + 4);
return IWII_IPC_HLE_Device::GetDefaultReply(); return IWII_IPC_HLE_Device::GetDefaultReply();
} }
@ -426,8 +426,8 @@ static IPCCommandResult HandleCommand(const u32 address)
{ {
case IPC_CMD_CLOSE: case IPC_CMD_CLOSE:
s_fdmap[fd].reset(); s_fdmap[fd].reset();
// A close on a valid device returns FS_SUCCESS. // A close on a valid device returns IPC_SUCCESS.
Memory::Write_U32(FS_SUCCESS, address + 4); Memory::Write_U32(IPC_SUCCESS, address + 4);
return device->Close(address); return device->Close(address);
case IPC_CMD_READ: case IPC_CMD_READ:
return device->Read(address); return device->Read(address);

View File

@ -14,30 +14,32 @@
#include "Common/StringUtil.h" #include "Common/StringUtil.h"
#include "Core/IPC_HLE/WII_IPC_HLE.h" #include "Core/IPC_HLE/WII_IPC_HLE.h"
#define FS_SUCCESS (u32)0 // Success enum IOSReturnCode : s32
#define FS_EACCES (u32) - 1 // Permission denied {
#define FS_EEXIST (u32) - 2 // File exists IPC_SUCCESS = 0, // Success
#define FS_EINVAL (u32) - 4 // Invalid argument Invalid FD IPC_EACCES = -1, // Permission denied
#define FS_ENOENT (u32) - 6 // File not found IPC_EEXIST = -2, // File exists
#define FS_EBUSY (u32) - 8 // Resource busy IPC_EINVAL = -4, // Invalid argument or fd
#define FS_EIO (u32) - 12 // Returned on ECC error IPC_ENOENT = -6, // File not found
#define FS_ENOMEM (u32) - 22 // Alloc failed during request IPC_EQUEUEFULL = -8, // Queue full
#define FS_EFATAL (u32) - 101 // Fatal error IPC_EIO = -12, // ECC error
#define FS_EACCESS (u32) - 102 // Permission denied IPC_ENOMEM = -22, // Alloc failed during request
#define FS_ECORRUPT (u32) - 103 // returned for "corrupted" NAND FS_EINVAL = -101, // Invalid path
#define FS_EEXIST2 (u32) - 105 // File exists FS_EACCESS = -102, // Permission denied
#define FS_ENOENT2 (u32) - 106 // File not found FS_ECORRUPT = -103, // Corrupted NAND
#define FS_ENFILE (u32) - 107 // Too many fds open FS_EEXIST = -105, // File exists
#define FS_EFBIG (u32) - 108 // Max block count reached? FS_ENOENT = -106, // No such file or directory
#define FS_EFDEXHAUSTED (u32) - 109 // Too many fds open FS_ENFILE = -107, // Too many fds open
#define FS_ENAMELEN (u32) - 110 // Pathname is too long FS_EFBIG = -108, // Max block count reached?
#define FS_EFDOPEN (u32) - 111 // FD is already open FS_EFDEXHAUSTED = -109, // Too many fds open
#define FS_EIO2 (u32) - 114 // Returned on ECC error FS_ENAMELEN = -110, // Pathname is too long
#define FS_ENOTEMPTY (u32) - 115 // Directory not empty FS_EFDOPEN = -111, // FD is already open
#define FS_EDIRDEPTH (u32) - 116 // Max directory depth exceeded FS_EIO = -114, // ECC error
#define FS_EBUSY2 (u32) - 118 // Resource busy FS_ENOTEMPTY = -115, // Directory not empty
//#define FS_EFATAL (u32)-119 // Fatal error not used by IOS as fatal ERROR FS_EDIRDEPTH = -116, // Max directory depth exceeded
#define FS_EESEXHAUSTED (u32) - 1016 // Max of 2 ES handles at a time FS_EBUSY = -118, // Resource busy
IPC_EESEXHAUSTED = -1016, // Max of 2 ES handles exceeded
};
// A struct for IOS ioctlv calls // A struct for IOS ioctlv calls
struct SIOCtlVBuffer struct SIOCtlVBuffer

View File

@ -15,7 +15,6 @@
#include "Core/HW/Memmap.h" #include "Core/HW/Memmap.h"
#include "Core/IPC_HLE/WII_IPC_HLE.h" #include "Core/IPC_HLE/WII_IPC_HLE.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.h" #include "Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_fs.h"
static std::map<std::string, std::weak_ptr<File::IOFile>> openFiles; static std::map<std::string, std::weak_ptr<File::IOFile>> openFiles;
@ -108,7 +107,7 @@ IPCCommandResult CWII_IPC_HLE_Device_FileIO::Open(u32 command_address, u32 mode)
WARN_LOG(WII_IPC_FILEIO, "FileIO: Open (%s) failed - File doesn't exist %s", Modes[mode], WARN_LOG(WII_IPC_FILEIO, "FileIO: Open (%s) failed - File doesn't exist %s", Modes[mode],
m_filepath.c_str()); m_filepath.c_str());
if (command_address) if (command_address)
Memory::Write_U32(FS_FILE_NOT_EXIST, command_address + 4); Memory::Write_U32(FS_ENOENT, command_address + 4);
} }
m_Active = true; m_Active = true;
@ -161,13 +160,13 @@ void CWII_IPC_HLE_Device_FileIO::OpenFile()
IPCCommandResult CWII_IPC_HLE_Device_FileIO::Seek(u32 _CommandAddress) IPCCommandResult CWII_IPC_HLE_Device_FileIO::Seek(u32 _CommandAddress)
{ {
u32 ReturnValue = FS_RESULT_FATAL; u32 ReturnValue = FS_EINVAL;
const s32 SeekPosition = Memory::Read_U32(_CommandAddress + 0xC); const s32 SeekPosition = Memory::Read_U32(_CommandAddress + 0xC);
const s32 Mode = Memory::Read_U32(_CommandAddress + 0x10); const s32 Mode = Memory::Read_U32(_CommandAddress + 0x10);
if (m_file->IsOpen()) if (m_file->IsOpen())
{ {
ReturnValue = FS_RESULT_FATAL; ReturnValue = FS_EINVAL;
const s32 fileSize = (s32)m_file->GetSize(); const s32 fileSize = (s32)m_file->GetSize();
DEBUG_LOG(WII_IPC_FILEIO, "FileIO: Seek Pos: 0x%08x, Mode: %i (%s, Length=0x%08x)", DEBUG_LOG(WII_IPC_FILEIO, "FileIO: Seek Pos: 0x%08x, Mode: %i (%s, Length=0x%08x)",
@ -210,14 +209,14 @@ IPCCommandResult CWII_IPC_HLE_Device_FileIO::Seek(u32 _CommandAddress)
default: default:
{ {
PanicAlert("CWII_IPC_HLE_Device_FileIO Unsupported seek mode %i", Mode); PanicAlert("CWII_IPC_HLE_Device_FileIO Unsupported seek mode %i", Mode);
ReturnValue = FS_RESULT_FATAL; ReturnValue = FS_EINVAL;
break; break;
} }
} }
} }
else else
{ {
ReturnValue = FS_FILE_NOT_EXIST; ReturnValue = FS_ENOENT;
} }
Memory::Write_U32(ReturnValue, _CommandAddress + 0x4); Memory::Write_U32(ReturnValue, _CommandAddress + 0x4);
@ -259,7 +258,7 @@ IPCCommandResult CWII_IPC_HLE_Device_FileIO::Read(u32 _CommandAddress)
ERROR_LOG(WII_IPC_FILEIO, "FileIO: Failed to read from %s (Addr=0x%08x Size=0x%x) - file could " ERROR_LOG(WII_IPC_FILEIO, "FileIO: Failed to read from %s (Addr=0x%08x Size=0x%x) - file could "
"not be opened or does not exist", "not be opened or does not exist",
m_Name.c_str(), Address, Size); m_Name.c_str(), Address, Size);
ReturnValue = FS_FILE_NOT_EXIST; ReturnValue = FS_ENOENT;
} }
Memory::Write_U32(ReturnValue, _CommandAddress + 0x4); Memory::Write_U32(ReturnValue, _CommandAddress + 0x4);
@ -299,7 +298,7 @@ IPCCommandResult CWII_IPC_HLE_Device_FileIO::Write(u32 _CommandAddress)
ERROR_LOG(WII_IPC_FILEIO, "FileIO: Failed to read from %s (Addr=0x%08x Size=0x%x) - file could " ERROR_LOG(WII_IPC_FILEIO, "FileIO: Failed to read from %s (Addr=0x%08x Size=0x%x) - file could "
"not be opened or does not exist", "not be opened or does not exist",
m_Name.c_str(), Address, Size); m_Name.c_str(), Address, Size);
ReturnValue = FS_FILE_NOT_EXIST; ReturnValue = FS_ENOENT;
} }
Memory::Write_U32(ReturnValue, _CommandAddress + 0x4); Memory::Write_U32(ReturnValue, _CommandAddress + 0x4);
@ -332,7 +331,7 @@ IPCCommandResult CWII_IPC_HLE_Device_FileIO::IOCtl(u32 _CommandAddress)
} }
else else
{ {
ReturnValue = FS_FILE_NOT_EXIST; ReturnValue = FS_ENOENT;
} }
} }
break; break;

View File

@ -73,7 +73,7 @@ static u64 ComputeTotalFileSize(const File::FSTEntry& parentEntry)
IPCCommandResult CWII_IPC_HLE_Device_fs::IOCtlV(u32 _CommandAddress) IPCCommandResult CWII_IPC_HLE_Device_fs::IOCtlV(u32 _CommandAddress)
{ {
u32 ReturnValue = FS_RESULT_OK; u32 ReturnValue = IPC_SUCCESS;
SIOCtlVBuffer CommandBuffer(_CommandAddress); SIOCtlVBuffer CommandBuffer(_CommandAddress);
// Prepare the out buffer(s) with zeros as a safety precaution // Prepare the out buffer(s) with zeros as a safety precaution
@ -94,7 +94,7 @@ IPCCommandResult CWII_IPC_HLE_Device_fs::IOCtlV(u32 _CommandAddress)
if (!IsValidWiiPath(relative_path)) if (!IsValidWiiPath(relative_path))
{ {
WARN_LOG(WII_IPC_FILEIO, "Not a valid path: %s", relative_path.c_str()); WARN_LOG(WII_IPC_FILEIO, "Not a valid path: %s", relative_path.c_str());
ReturnValue = FS_RESULT_FATAL; ReturnValue = FS_EINVAL;
break; break;
} }
@ -106,7 +106,7 @@ IPCCommandResult CWII_IPC_HLE_Device_fs::IOCtlV(u32 _CommandAddress)
if (!File::Exists(DirName)) if (!File::Exists(DirName))
{ {
WARN_LOG(WII_IPC_FILEIO, "FS: Search not found: %s", DirName.c_str()); WARN_LOG(WII_IPC_FILEIO, "FS: Search not found: %s", DirName.c_str());
ReturnValue = FS_FILE_NOT_EXIST; ReturnValue = FS_ENOENT;
break; break;
} }
else if (!File::IsDirectory(DirName)) else if (!File::IsDirectory(DirName))
@ -114,8 +114,8 @@ IPCCommandResult CWII_IPC_HLE_Device_fs::IOCtlV(u32 _CommandAddress)
// It's not a directory, so error. // It's not a directory, so error.
// Games don't usually seem to care WHICH error they get, as long as it's < // Games don't usually seem to care WHICH error they get, as long as it's <
// Well the system menu CARES! // Well the system menu CARES!
WARN_LOG(WII_IPC_FILEIO, "\tNot a directory - return FS_RESULT_FATAL"); WARN_LOG(WII_IPC_FILEIO, "\tNot a directory - return FS_EINVAL");
ReturnValue = FS_RESULT_FATAL; ReturnValue = FS_EINVAL;
break; break;
} }
@ -166,7 +166,7 @@ IPCCommandResult CWII_IPC_HLE_Device_fs::IOCtlV(u32 _CommandAddress)
Memory::Write_U32((u32)numFiles, CommandBuffer.PayloadBuffer[1].m_Address); Memory::Write_U32((u32)numFiles, CommandBuffer.PayloadBuffer[1].m_Address);
} }
ReturnValue = FS_RESULT_OK; ReturnValue = IPC_SUCCESS;
} }
break; break;
@ -185,7 +185,7 @@ IPCCommandResult CWII_IPC_HLE_Device_fs::IOCtlV(u32 _CommandAddress)
if (!IsValidWiiPath(relativepath)) if (!IsValidWiiPath(relativepath))
{ {
WARN_LOG(WII_IPC_FILEIO, "Not a valid path: %s", relativepath.c_str()); WARN_LOG(WII_IPC_FILEIO, "Not a valid path: %s", relativepath.c_str());
ReturnValue = FS_RESULT_FATAL; ReturnValue = FS_EINVAL;
break; break;
} }
@ -217,7 +217,7 @@ IPCCommandResult CWII_IPC_HLE_Device_fs::IOCtlV(u32 _CommandAddress)
fsBlocks = (u32)(totalSize / (16 * 1024)); // one bock is 16kb fsBlocks = (u32)(totalSize / (16 * 1024)); // one bock is 16kb
} }
ReturnValue = FS_RESULT_OK; ReturnValue = IPC_SUCCESS;
INFO_LOG(WII_IPC_FILEIO, "FS: fsBlock: %i, iNodes: %i", fsBlocks, iNodes); INFO_LOG(WII_IPC_FILEIO, "FS: fsBlock: %i, iNodes: %i", fsBlocks, iNodes);
} }
@ -225,7 +225,7 @@ IPCCommandResult CWII_IPC_HLE_Device_fs::IOCtlV(u32 _CommandAddress)
{ {
fsBlocks = 0; fsBlocks = 0;
iNodes = 0; iNodes = 0;
ReturnValue = FS_RESULT_OK; ReturnValue = IPC_SUCCESS;
WARN_LOG(WII_IPC_FILEIO, "FS: fsBlock failed, cannot find directory: %s", path.c_str()); WARN_LOG(WII_IPC_FILEIO, "FS: fsBlock failed, cannot find directory: %s", path.c_str());
} }
@ -290,7 +290,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
std::memcpy(Memory::GetPointer(_BufferOut), &fs, sizeof(NANDStat)); std::memcpy(Memory::GetPointer(_BufferOut), &fs, sizeof(NANDStat));
return FS_RESULT_OK; return IPC_SUCCESS;
} }
break; break;
@ -307,7 +307,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
if (!IsValidWiiPath(wii_path)) if (!IsValidWiiPath(wii_path))
{ {
WARN_LOG(WII_IPC_FILEIO, "Not a valid path: %s", wii_path.c_str()); WARN_LOG(WII_IPC_FILEIO, "Not a valid path: %s", wii_path.c_str());
return FS_RESULT_FATAL; return FS_EINVAL;
} }
std::string DirName(HLE_IPC_BuildFilename(wii_path)); std::string DirName(HLE_IPC_BuildFilename(wii_path));
Addr += 64; Addr += 64;
@ -322,7 +322,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
_dbg_assert_msg_(WII_IPC_FILEIO, File::IsDirectory(DirName), "FS: CREATE_DIR %s failed", _dbg_assert_msg_(WII_IPC_FILEIO, File::IsDirectory(DirName), "FS: CREATE_DIR %s failed",
DirName.c_str()); DirName.c_str());
return FS_RESULT_OK; return IPC_SUCCESS;
} }
break; break;
@ -338,7 +338,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
if (!IsValidWiiPath(wii_path)) if (!IsValidWiiPath(wii_path))
{ {
WARN_LOG(WII_IPC_FILEIO, "Not a valid path: %s", wii_path.c_str()); WARN_LOG(WII_IPC_FILEIO, "Not a valid path: %s", wii_path.c_str());
return FS_RESULT_FATAL; return FS_EINVAL;
} }
std::string Filename = HLE_IPC_BuildFilename(wii_path); std::string Filename = HLE_IPC_BuildFilename(wii_path);
Addr += 64; Addr += 64;
@ -359,7 +359,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
DEBUG_LOG(WII_IPC_FILEIO, " OtherPerm: 0x%02x", OtherPerm); DEBUG_LOG(WII_IPC_FILEIO, " OtherPerm: 0x%02x", OtherPerm);
DEBUG_LOG(WII_IPC_FILEIO, " Attributes: 0x%02x", Attributes); DEBUG_LOG(WII_IPC_FILEIO, " Attributes: 0x%02x", Attributes);
return FS_RESULT_OK; return IPC_SUCCESS;
} }
break; break;
@ -376,7 +376,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
if (!IsValidWiiPath(wii_path)) if (!IsValidWiiPath(wii_path))
{ {
WARN_LOG(WII_IPC_FILEIO, "Not a valid path: %s", wii_path.c_str()); WARN_LOG(WII_IPC_FILEIO, "Not a valid path: %s", wii_path.c_str());
return FS_RESULT_FATAL; return FS_EINVAL;
} }
std::string Filename = HLE_IPC_BuildFilename(wii_path); std::string Filename = HLE_IPC_BuildFilename(wii_path);
u8 OwnerPerm = 0x3; // read/write u8 OwnerPerm = 0x3; // read/write
@ -398,7 +398,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
else else
{ {
INFO_LOG(WII_IPC_FILEIO, "FS: GET_ATTR unknown %s", Filename.c_str()); INFO_LOG(WII_IPC_FILEIO, "FS: GET_ATTR unknown %s", Filename.c_str());
return FS_FILE_NOT_EXIST; return FS_ENOENT;
} }
} }
@ -422,7 +422,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
Addr += 1; Addr += 1;
} }
return FS_RESULT_OK; return IPC_SUCCESS;
} }
break; break;
@ -435,7 +435,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
if (!IsValidWiiPath(wii_path)) if (!IsValidWiiPath(wii_path))
{ {
WARN_LOG(WII_IPC_FILEIO, "Not a valid path: %s", wii_path.c_str()); WARN_LOG(WII_IPC_FILEIO, "Not a valid path: %s", wii_path.c_str());
return FS_RESULT_FATAL; return FS_EINVAL;
} }
std::string Filename = HLE_IPC_BuildFilename(wii_path); std::string Filename = HLE_IPC_BuildFilename(wii_path);
Offset += 64; Offset += 64;
@ -452,7 +452,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
WARN_LOG(WII_IPC_FILEIO, "FS: DeleteFile %s - failed!!!", Filename.c_str()); WARN_LOG(WII_IPC_FILEIO, "FS: DeleteFile %s - failed!!!", Filename.c_str());
} }
return FS_RESULT_OK; return IPC_SUCCESS;
} }
break; break;
@ -465,7 +465,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
if (!IsValidWiiPath(wii_path)) if (!IsValidWiiPath(wii_path))
{ {
WARN_LOG(WII_IPC_FILEIO, "Not a valid path: %s", wii_path.c_str()); WARN_LOG(WII_IPC_FILEIO, "Not a valid path: %s", wii_path.c_str());
return FS_RESULT_FATAL; return FS_EINVAL;
} }
std::string Filename = HLE_IPC_BuildFilename(wii_path); std::string Filename = HLE_IPC_BuildFilename(wii_path);
Offset += 64; Offset += 64;
@ -474,7 +474,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
if (!IsValidWiiPath(wii_path_rename)) if (!IsValidWiiPath(wii_path_rename))
{ {
WARN_LOG(WII_IPC_FILEIO, "Not a valid path: %s", wii_path_rename.c_str()); WARN_LOG(WII_IPC_FILEIO, "Not a valid path: %s", wii_path_rename.c_str());
return FS_RESULT_FATAL; return FS_EINVAL;
} }
std::string FilenameRename = HLE_IPC_BuildFilename(wii_path_rename); std::string FilenameRename = HLE_IPC_BuildFilename(wii_path_rename);
Offset += 64; Offset += 64;
@ -497,10 +497,10 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
{ {
ERROR_LOG(WII_IPC_FILEIO, "FS: Rename %s to %s - failed", Filename.c_str(), ERROR_LOG(WII_IPC_FILEIO, "FS: Rename %s to %s - failed", Filename.c_str(),
FilenameRename.c_str()); FilenameRename.c_str());
return FS_FILE_NOT_EXIST; return FS_ENOENT;
} }
return FS_RESULT_OK; return IPC_SUCCESS;
} }
break; break;
@ -517,7 +517,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
if (!IsValidWiiPath(wii_path)) if (!IsValidWiiPath(wii_path))
{ {
WARN_LOG(WII_IPC_FILEIO, "Not a valid path: %s", wii_path.c_str()); WARN_LOG(WII_IPC_FILEIO, "Not a valid path: %s", wii_path.c_str());
return FS_RESULT_FATAL; return FS_EINVAL;
} }
std::string Filename(HLE_IPC_BuildFilename(wii_path)); std::string Filename(HLE_IPC_BuildFilename(wii_path));
Addr += 64; Addr += 64;
@ -541,8 +541,8 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
// check if the file already exist // check if the file already exist
if (File::Exists(Filename)) if (File::Exists(Filename))
{ {
INFO_LOG(WII_IPC_FILEIO, "\tresult = FS_RESULT_EXISTS"); INFO_LOG(WII_IPC_FILEIO, "\tresult = FS_EEXIST");
return FS_FILE_EXIST; return FS_EEXIST;
} }
// create the file // create the file
@ -552,11 +552,11 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
{ {
ERROR_LOG(WII_IPC_FILEIO, "CWII_IPC_HLE_Device_fs: couldn't create new file"); ERROR_LOG(WII_IPC_FILEIO, "CWII_IPC_HLE_Device_fs: couldn't create new file");
PanicAlert("CWII_IPC_HLE_Device_fs: couldn't create new file"); PanicAlert("CWII_IPC_HLE_Device_fs: couldn't create new file");
return FS_RESULT_FATAL; return FS_EINVAL;
} }
INFO_LOG(WII_IPC_FILEIO, "\tresult = FS_RESULT_OK"); INFO_LOG(WII_IPC_FILEIO, "\tresult = IPC_SUCCESS");
return FS_RESULT_OK; return IPC_SUCCESS;
} }
break; break;
case IOCTL_SHUTDOWN: case IOCTL_SHUTDOWN:
@ -571,7 +571,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
break; break;
} }
return FS_RESULT_FATAL; return FS_EINVAL;
} }
void CWII_IPC_HLE_Device_fs::DoState(PointerWrap& p) void CWII_IPC_HLE_Device_fs::DoState(PointerWrap& p)

View File

@ -23,18 +23,6 @@ struct NANDStat
u32 Used_Inodes; u32 Used_Inodes;
}; };
enum
{
FS_RESULT_OK = 0,
FS_INVALID = -4,
FS_DIRFILE_NOT_FOUND = -6,
FS_RESULT_FATAL = -101,
FS_NO_ACCESS = -102,
FS_FILE_EXIST = -105,
FS_FILE_NOT_EXIST = -106,
FS_NO_HANDLE = -106,
};
class CWII_IPC_HLE_Device_fs : public IWII_IPC_HLE_Device class CWII_IPC_HLE_Device_fs : public IWII_IPC_HLE_Device
{ {
public: public:

View File

@ -56,7 +56,7 @@ void CWII_IPC_HLE_Device_hid::checkUsbUpdates(CWII_IPC_HLE_Device_hid* hid)
void CWII_IPC_HLE_Device_hid::handleUsbUpdates(struct libusb_transfer* transfer) void CWII_IPC_HLE_Device_hid::handleUsbUpdates(struct libusb_transfer* transfer)
{ {
int ret = HIDERR_NO_DEVICE_FOUND; int ret = IPC_EINVAL;
u32 replyAddress = (u32)(size_t)transfer->user_data; u32 replyAddress = (u32)(size_t)transfer->user_data;
if (transfer->status == LIBUSB_TRANSFER_COMPLETED) if (transfer->status == LIBUSB_TRANSFER_COMPLETED)
{ {
@ -169,7 +169,7 @@ IPCCommandResult CWII_IPC_HLE_Device_hid::IOCtl(u32 _CommandAddress)
u16 wLength = Memory::Read_U16(BufferIn + 0x1A); u16 wLength = Memory::Read_U16(BufferIn + 0x1A);
u32 data = Memory::Read_U32(BufferIn + 0x1C); u32 data = Memory::Read_U32(BufferIn + 0x1C);
ReturnValue = HIDERR_NO_DEVICE_FOUND; ReturnValue = IPC_EINVAL;
libusb_device_handle* dev_handle = GetDeviceByDevNum(dev_num); libusb_device_handle* dev_handle = GetDeviceByDevNum(dev_num);
@ -204,7 +204,7 @@ IPCCommandResult CWII_IPC_HLE_Device_hid::IOCtl(u32 _CommandAddress)
u32 data = Memory::Read_U32(BufferIn + 0x1C); u32 data = Memory::Read_U32(BufferIn + 0x1C);
ReturnValue = HIDERR_NO_DEVICE_FOUND; ReturnValue = IPC_EINVAL;
libusb_device_handle* dev_handle = GetDeviceByDevNum(dev_num); libusb_device_handle* dev_handle = GetDeviceByDevNum(dev_num);

View File

@ -31,8 +31,6 @@ struct libusb_transfer;
#define HID_ID_MASK 0x0000FFFFFFFFFFFF #define HID_ID_MASK 0x0000FFFFFFFFFFFF
#define MAX_HID_INTERFACES 1 #define MAX_HID_INTERFACES 1
#define HIDERR_NO_DEVICE_FOUND -4
class CWII_IPC_HLE_Device_hid : public IWII_IPC_HLE_Device class CWII_IPC_HLE_Device_hid : public IWII_IPC_HLE_Device
{ {
public: public:

View File

@ -42,11 +42,11 @@ IPCCommandResult CWII_IPC_HLE_Device_stm_immediate::IOCtl(u32 command_address)
case IOCTL_STM_RELEASE_EH: case IOCTL_STM_RELEASE_EH:
if (s_event_hook_address == 0) if (s_event_hook_address == 0)
{ {
return_value = FS_ENOENT; return_value = IPC_ENOENT;
break; break;
} }
Memory::Write_U32(0, Memory::Read_U32(s_event_hook_address + 0x18)); Memory::Write_U32(0, Memory::Read_U32(s_event_hook_address + 0x18));
Memory::Write_U32(FS_SUCCESS, s_event_hook_address + 4); Memory::Write_U32(IPC_SUCCESS, s_event_hook_address + 4);
WII_IPC_HLE_Interface::EnqueueReply(s_event_hook_address); WII_IPC_HLE_Interface::EnqueueReply(s_event_hook_address);
s_event_hook_address = 0; s_event_hook_address = 0;
break; break;
@ -102,7 +102,7 @@ IPCCommandResult CWII_IPC_HLE_Device_stm_eventhook::IOCtl(u32 command_address)
if (parameter != IOCTL_STM_EVENTHOOK) if (parameter != IOCTL_STM_EVENTHOOK)
{ {
ERROR_LOG(WII_IPC_STM, "Bad IOCtl in CWII_IPC_HLE_Device_stm_eventhook"); ERROR_LOG(WII_IPC_STM, "Bad IOCtl in CWII_IPC_HLE_Device_stm_eventhook");
Memory::Write_U32(FS_EINVAL, command_address + 4); Memory::Write_U32(IPC_EINVAL, command_address + 4);
return GetDefaultReply(); return GetDefaultReply();
} }
@ -129,7 +129,7 @@ void CWII_IPC_HLE_Device_stm_eventhook::TriggerEvent(const u32 event) const
u32 buffer_out = Memory::Read_U32(s_event_hook_address + 0x18); u32 buffer_out = Memory::Read_U32(s_event_hook_address + 0x18);
Memory::Write_U32(event, buffer_out); Memory::Write_U32(event, buffer_out);
Memory::Write_U32(FS_SUCCESS, s_event_hook_address + 4); Memory::Write_U32(IPC_SUCCESS, s_event_hook_address + 4);
WII_IPC_HLE_Interface::EnqueueReply(s_event_hook_address); WII_IPC_HLE_Interface::EnqueueReply(s_event_hook_address);
s_event_hook_address = 0; s_event_hook_address = 0;
} }

View File

@ -28,13 +28,13 @@ IPCCommandResult CWII_IPC_HLE_Device_stub::Close(u32 command_address, bool force
IPCCommandResult CWII_IPC_HLE_Device_stub::IOCtl(u32 command_address) IPCCommandResult CWII_IPC_HLE_Device_stub::IOCtl(u32 command_address)
{ {
WARN_LOG(WII_IPC_HLE, "%s faking IOCtl()", m_Name.c_str()); WARN_LOG(WII_IPC_HLE, "%s faking IOCtl()", m_Name.c_str());
Memory::Write_U32(FS_SUCCESS, command_address + 4); Memory::Write_U32(IPC_SUCCESS, command_address + 4);
return GetDefaultReply(); return GetDefaultReply();
} }
IPCCommandResult CWII_IPC_HLE_Device_stub::IOCtlV(u32 command_address) IPCCommandResult CWII_IPC_HLE_Device_stub::IOCtlV(u32 command_address)
{ {
WARN_LOG(WII_IPC_HLE, "%s faking IOCtlV()", m_Name.c_str()); WARN_LOG(WII_IPC_HLE, "%s faking IOCtlV()", m_Name.c_str());
Memory::Write_U32(FS_SUCCESS, command_address + 4); Memory::Write_U32(IPC_SUCCESS, command_address + 4);
return GetDefaultReply(); return GetDefaultReply();
} }

View File

@ -54,7 +54,7 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_oh1_57e_305_base::IOCtl(u32 command_add
{ {
// NeoGamma (homebrew) is known to use this path. // NeoGamma (homebrew) is known to use this path.
ERROR_LOG(WII_IPC_WIIMOTE, "Bad IOCtl to /dev/usb/oh1/57e/305"); ERROR_LOG(WII_IPC_WIIMOTE, "Bad IOCtl to /dev/usb/oh1/57e/305");
Memory::Write_U32(FS_EINVAL, command_address + 4); Memory::Write_U32(IPC_EINVAL, command_address + 4);
return GetDefaultReply(); return GetDefaultReply();
} }

View File

@ -176,7 +176,7 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::IOCtl(u32 _CommandAddr
{ {
// NeoGamma (homebrew) is known to use this path. // NeoGamma (homebrew) is known to use this path.
ERROR_LOG(WII_IPC_WIIMOTE, "Bad IOCtl in CWII_IPC_HLE_Device_usb_oh1_57e_305"); ERROR_LOG(WII_IPC_WIIMOTE, "Bad IOCtl in CWII_IPC_HLE_Device_usb_oh1_57e_305");
Memory::Write_U32(FS_EINVAL, _CommandAddress + 4); Memory::Write_U32(IPC_EINVAL, _CommandAddress + 4);
return GetDefaultReply(); return GetDefaultReply();
} }