From 4b4e48818914d7c2b961428f03ca696801b70b2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Wed, 16 Aug 2017 22:24:24 +0200 Subject: [PATCH] WFS: Use a separate log type for WFS related logs Makes it easier to turn off general IOS messages that can be distracting (e.g. /dev/net/ssl being opened hundreds of time...) without losing the ability to view WFS messages. --- Source/Core/Common/Logging/Log.h | 1 + Source/Core/Common/Logging/LogManager.cpp | 1 + Source/Core/Core/IOS/WFS/WFSI.cpp | 34 ++++++++--------- Source/Core/Core/IOS/WFS/WFSSRV.cpp | 46 +++++++++++------------ 4 files changed, 42 insertions(+), 40 deletions(-) diff --git a/Source/Core/Common/Logging/Log.h b/Source/Core/Common/Logging/Log.h index 43451767df..7db7b39c9b 100644 --- a/Source/Core/Common/Logging/Log.h +++ b/Source/Core/Common/Logging/Log.h @@ -38,6 +38,7 @@ enum LOG_TYPE IOS_STM, IOS_USB, IOS_WC24, + IOS_WFS, IOS_WIIMOTE, MASTER_LOG, MEMMAP, diff --git a/Source/Core/Common/Logging/LogManager.cpp b/Source/Core/Common/Logging/LogManager.cpp index a18397a976..a4c7adb49a 100644 --- a/Source/Core/Common/Logging/LogManager.cpp +++ b/Source/Core/Common/Logging/LogManager.cpp @@ -106,6 +106,7 @@ LogManager::LogManager() m_log[LogTypes::IOS_NET] = {"IOS_NET", "IOS - Network"}; m_log[LogTypes::IOS_USB] = {"IOS_USB", "IOS - USB"}; m_log[LogTypes::IOS_WC24] = {"IOS_WC24", "IOS - WiiConnect24"}; + m_log[LogTypes::IOS_WFS] = {"IOS_WFS", "IOS - WFS"}; m_log[LogTypes::IOS_WIIMOTE] = {"IOS_WIIMOTE", "IOS - Wii Remote"}; m_log[LogTypes::MASTER_LOG] = {"*", "Master Log"}; m_log[LogTypes::MEMCARD_MANAGER] = {"MemCard Manager", "MemCard Manager"}; diff --git a/Source/Core/Core/IOS/WFS/WFSI.cpp b/Source/Core/Core/IOS/WFS/WFSI.cpp index 9059269308..a2e856831e 100644 --- a/Source/Core/Core/IOS/WFS/WFSI.cpp +++ b/Source/Core/Core/IOS/WFS/WFSI.cpp @@ -39,7 +39,7 @@ void ARCUnpacker::Extract(const WriteCallback& callback) u32 fourcc = Common::swap32(m_whole_file.data()); if (fourcc != 0x55AA382D) { - ERROR_LOG(IOS, "ARCUnpacker: invalid fourcc (%08x)", fourcc); + ERROR_LOG(IOS_WFS, "ARCUnpacker: invalid fourcc (%08x)", fourcc); return; } @@ -97,12 +97,12 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request) u32 tmd_addr = Memory::Read_U32(request.buffer_in); u32 tmd_size = Memory::Read_U32(request.buffer_in + 4); - INFO_LOG(IOS, "IOCTL_WFSI_PREPARE_DEVICE"); + INFO_LOG(IOS_WFS, "IOCTL_WFSI_PREPARE_DEVICE"); constexpr u32 MAX_TMD_SIZE = 0x4000; if (tmd_size > MAX_TMD_SIZE) { - ERROR_LOG(IOS, "IOCTL_WFSI_PREPARE_DEVICE: TMD size too large (%d)", tmd_size); + ERROR_LOG(IOS_WFS, "IOCTL_WFSI_PREPARE_DEVICE: TMD size too large (%d)", tmd_size); return_error_code = IPC_EINVAL; break; } @@ -139,7 +139,7 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request) IOS::ES::Content content_info; if (!m_tmd.FindContentById(content_id, &content_info)) { - WARN_LOG(IOS, "%s: Content id %08x not found", ioctl_name, content_id); + WARN_LOG(IOS_WFS, "%s: Content id %08x not found", ioctl_name, content_id); return_error_code = -10003; break; } @@ -147,7 +147,7 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request) memset(m_aes_iv, 0, sizeof(m_aes_iv)); m_aes_iv[0] = content_info.index >> 8; m_aes_iv[1] = content_info.index & 0xFF; - INFO_LOG(IOS, "%s: Content id %08x found at index %d", ioctl_name, content_id, + INFO_LOG(IOS_WFS, "%s: Content id %08x found at index %d", ioctl_name, content_id, content_info.index); m_arc_unpacker.Reset(); @@ -164,7 +164,7 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request) u32 content_id = Memory::Read_U32(request.buffer_in + 0xC); u32 input_ptr = Memory::Read_U32(request.buffer_in + 0x10); u32 input_size = Memory::Read_U32(request.buffer_in + 0x14); - INFO_LOG(IOS, "%s: %08x bytes of data at %08x from content id %d", ioctl_name, input_size, + INFO_LOG(IOS_WFS, "%s: %08x bytes of data at %08x from content id %d", ioctl_name, input_size, input_ptr, content_id); std::vector decrypted(input_size); @@ -181,17 +181,17 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request) const char* ioctl_name = request.request == IOCTL_WFSI_FINALIZE_PROFILE ? "IOCTL_WFSI_FINALIZE_PROFILE" : "IOCTL_WFSI_FINALIZE_CONTENT"; - INFO_LOG(IOS, "%s", ioctl_name); + INFO_LOG(IOS_WFS, "%s", ioctl_name); auto callback = [this](const std::string& filename, const std::vector& bytes) { - INFO_LOG(IOS, "Extract: %s (%zd bytes)", filename.c_str(), bytes.size()); + INFO_LOG(IOS_WFS, "Extract: %s (%zd bytes)", filename.c_str(), bytes.size()); std::string path = WFS::NativePath(m_base_extract_path + "/" + filename); File::CreateFullPath(path); File::IOFile f(path, "wb"); if (!f) { - ERROR_LOG(IOS, "Could not extract %s to %s", filename.c_str(), path.c_str()); + ERROR_LOG(IOS_WFS, "Could not extract %s to %s", filename.c_str(), path.c_str()); return; } f.WriteBytes(bytes.data(), bytes.size()); @@ -208,19 +208,19 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request) // Bytes 0-4: ?? // Bytes 4-8: game id // Bytes 1c-1e: title id? - WARN_LOG(IOS, "IOCTL_WFSI_DELETE_TITLE: unimplemented"); + WARN_LOG(IOS_WFS, "IOCTL_WFSI_DELETE_TITLE: unimplemented"); break; case IOCTL_WFSI_IMPORT_TITLE: - WARN_LOG(IOS, "IOCTL_WFSI_IMPORT_TITLE: unimplemented"); + WARN_LOG(IOS_WFS, "IOCTL_WFSI_IMPORT_TITLE: unimplemented"); break; case IOCTL_WFSI_INIT: { - INFO_LOG(IOS, "IOCTL_WFSI_INIT"); + INFO_LOG(IOS_WFS, "IOCTL_WFSI_INIT"); if (GetIOS()->GetES()->GetTitleId(&m_title_id) < 0) { - ERROR_LOG(IOS, "IOCTL_WFSI_INIT: Could not get title id."); + ERROR_LOG(IOS_WFS, "IOCTL_WFSI_INIT: Could not get title id."); return_error_code = IPC_EINVAL; break; } @@ -235,12 +235,12 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request) } case IOCTL_WFSI_SET_DEVICE_NAME: - INFO_LOG(IOS, "IOCTL_WFSI_SET_DEVICE_NAME"); + INFO_LOG(IOS_WFS, "IOCTL_WFSI_SET_DEVICE_NAME"); m_device_name = Memory::GetString(request.buffer_in); break; case IOCTL_WFSI_APPLY_TITLE_PROFILE: - INFO_LOG(IOS, "IOCTL_WFSI_APPLY_TITLE_PROFILE"); + INFO_LOG(IOS_WFS, "IOCTL_WFSI_APPLY_TITLE_PROFILE"); m_base_extract_path = StringFromFormat("/vol/%s/_install/%s/content", m_device_name.c_str(), m_title_id_str.c_str()); @@ -266,13 +266,13 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request) path += StringFromFormat("/extension%d.dol", dol_extension_id); } - INFO_LOG(IOS, "IOCTL_WFSI_LOAD_DOL: loading %s at address %08x (size %d)", path.c_str(), + INFO_LOG(IOS_WFS, "IOCTL_WFSI_LOAD_DOL: loading %s at address %08x (size %d)", path.c_str(), dol_addr, max_dol_size); File::IOFile fp(WFS::NativePath(path), "rb"); if (!fp) { - WARN_LOG(IOS, "IOCTL_WFSI_LOAD_DOL: no such file or directory: %s", path.c_str()); + WARN_LOG(IOS_WFS, "IOCTL_WFSI_LOAD_DOL: no such file or directory: %s", path.c_str()); return_error_code = WFSI_ENOENT; break; } diff --git a/Source/Core/Core/IOS/WFS/WFSSRV.cpp b/Source/Core/Core/IOS/WFS/WFSSRV.cpp index b714a821a6..08315c48c6 100644 --- a/Source/Core/Core/IOS/WFS/WFSSRV.cpp +++ b/Source/Core/Core/IOS/WFS/WFSSRV.cpp @@ -42,18 +42,18 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request) { case IOCTL_WFS_INIT: // TODO(wfs): Implement. - INFO_LOG(IOS, "IOCTL_WFS_INIT"); + INFO_LOG(IOS_WFS, "IOCTL_WFS_INIT"); break; case IOCTL_WFS_UNKNOWN_8: // TODO(wfs): Figure out what this actually does. - INFO_LOG(IOS, "IOCTL_WFS_UNKNOWN_8"); + INFO_LOG(IOS_WFS, "IOCTL_WFS_UNKNOWN_8"); Memory::Write_U8(7, request.buffer_out); Memory::CopyToEmu(request.buffer_out + 1, "msc01\x00\x00\x00", 8); break; case IOCTL_WFS_SHUTDOWN: - INFO_LOG(IOS, "IOCTL_WFS_SHUTDOWN"); + INFO_LOG(IOS_WFS, "IOCTL_WFS_SHUTDOWN"); // Close all hanging attach/detach ioctls with an appropriate error code. for (auto address : m_hanging) @@ -67,14 +67,14 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request) break; case IOCTL_WFS_DEVICE_INFO: - INFO_LOG(IOS, "IOCTL_WFS_DEVICE_INFO"); + INFO_LOG(IOS_WFS, "IOCTL_WFS_DEVICE_INFO"); Memory::Write_U64(16ull << 30, request.buffer_out); // 16GB storage. Memory::Write_U8(4, request.buffer_out + 8); break; case IOCTL_WFS_GET_DEVICE_NAME: { - INFO_LOG(IOS, "IOCTL_WFS_GET_DEVICE_NAME"); + INFO_LOG(IOS_WFS, "IOCTL_WFS_GET_DEVICE_NAME"); Memory::Write_U8(static_cast(m_device_name.size()), request.buffer_out); Memory::CopyToEmu(request.buffer_out + 1, m_device_name.data(), m_device_name.size()); break; @@ -82,14 +82,14 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request) case IOCTL_WFS_ATTACH_DETACH_2: // TODO(wfs): Implement. - INFO_LOG(IOS, "IOCTL_WFS_ATTACH_DETACH_2(%u)", request.request); + INFO_LOG(IOS_WFS, "IOCTL_WFS_ATTACH_DETACH_2(%u)", request.request); Memory::Write_U32(1, request.buffer_out); Memory::Write_U32(0, request.buffer_out + 4); // device id? Memory::Write_U32(0, request.buffer_out + 8); break; case IOCTL_WFS_ATTACH_DETACH: - INFO_LOG(IOS, "IOCTL_WFS_ATTACH_DETACH(%u)", request.request); + INFO_LOG(IOS_WFS, "IOCTL_WFS_ATTACH_DETACH(%u)", request.request); // Leave hanging, but we need to acknowledge the request at shutdown time. m_hanging.push_back(request.address); @@ -97,41 +97,41 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request) case IOCTL_WFS_FLUSH: // Nothing to do. - INFO_LOG(IOS, "IOCTL_WFS_FLUSH: doing nothing"); + INFO_LOG(IOS_WFS, "IOCTL_WFS_FLUSH: doing nothing"); break; // TODO(wfs): Globbing is not really implemented, we just fake the one case // (listing /vol/*) which is required to get the installer to work. case IOCTL_WFS_GLOB_START: - INFO_LOG(IOS, "IOCTL_WFS_GLOB_START(%u)", request.request); + INFO_LOG(IOS_WFS, "IOCTL_WFS_GLOB_START(%u)", request.request); Memory::Memset(request.buffer_out, 0, request.buffer_out_size); Memory::CopyToEmu(request.buffer_out + 0x14, m_device_name.data(), m_device_name.size()); break; case IOCTL_WFS_GLOB_NEXT: - INFO_LOG(IOS, "IOCTL_WFS_GLOB_NEXT(%u)", request.request); + INFO_LOG(IOS_WFS, "IOCTL_WFS_GLOB_NEXT(%u)", request.request); return_error_code = WFS_ENOENT; break; case IOCTL_WFS_GLOB_END: - INFO_LOG(IOS, "IOCTL_WFS_GLOB_END(%u)", request.request); + INFO_LOG(IOS_WFS, "IOCTL_WFS_GLOB_END(%u)", request.request); Memory::Memset(request.buffer_out, 0, request.buffer_out_size); break; case IOCTL_WFS_SET_HOMEDIR: m_home_directory = Memory::GetString(request.buffer_in + 2, Memory::Read_U16(request.buffer_in)); - INFO_LOG(IOS, "IOCTL_WFS_SET_HOMEDIR: %s", m_home_directory.c_str()); + INFO_LOG(IOS_WFS, "IOCTL_WFS_SET_HOMEDIR: %s", m_home_directory.c_str()); break; case IOCTL_WFS_CHDIR: m_current_directory = Memory::GetString(request.buffer_in + 2, Memory::Read_U16(request.buffer_in)); - INFO_LOG(IOS, "IOCTL_WFS_CHDIR: %s", m_current_directory.c_str()); + INFO_LOG(IOS_WFS, "IOCTL_WFS_CHDIR: %s", m_current_directory.c_str()); break; case IOCTL_WFS_GET_HOMEDIR: - INFO_LOG(IOS, "IOCTL_WFS_GET_HOMEDIR: %s", m_home_directory.c_str()); + INFO_LOG(IOS_WFS, "IOCTL_WFS_GET_HOMEDIR: %s", m_home_directory.c_str()); Memory::Write_U16(static_cast(m_home_directory.size()), request.buffer_out); Memory::CopyToEmu(request.buffer_out + 2, m_home_directory.data(), m_home_directory.size()); break; @@ -153,13 +153,13 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request) if (!fd_obj->Open()) { - ERROR_LOG(IOS, "IOCTL_WFS_OPEN(%s, %d): error opening file", path.c_str(), mode); + ERROR_LOG(IOS_WFS, "IOCTL_WFS_OPEN(%s, %d): error opening file", path.c_str(), mode); ReleaseFileDescriptor(fd); return_error_code = WFS_ENOENT; break; } - INFO_LOG(IOS, "IOCTL_WFS_OPEN(%s, %d) -> %d", path.c_str(), mode, fd); + INFO_LOG(IOS_WFS, "IOCTL_WFS_OPEN(%s, %d) -> %d", path.c_str(), mode, fd); Memory::Write_U16(fd, request.buffer_out + 0x14); break; } @@ -170,17 +170,17 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request) FileDescriptor* fd_obj = FindFileDescriptor(fd); if (fd_obj == nullptr) { - ERROR_LOG(IOS, "IOCTL_WFS_GET_SIZE: invalid file descriptor %d", fd); + ERROR_LOG(IOS_WFS, "IOCTL_WFS_GET_SIZE: invalid file descriptor %d", fd); return_error_code = WFS_EBADFD; break; } u64 size = fd_obj->file.GetSize(); u32 truncated_size = static_cast(size); - INFO_LOG(IOS, "IOCTL_WFS_GET_SIZE(%d) -> %d", fd, truncated_size); + INFO_LOG(IOS_WFS, "IOCTL_WFS_GET_SIZE(%d) -> %d", fd, truncated_size); if (size != truncated_size) { - ERROR_LOG(IOS, "IOCTL_WFS_GET_SIZE: file %d too large (%" PRIu64 ")", fd, size); + ERROR_LOG(IOS_WFS, "IOCTL_WFS_GET_SIZE: file %d too large (%" PRIu64 ")", fd, size); } Memory::Write_U32(truncated_size, request.buffer_out); break; @@ -189,7 +189,7 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request) case IOCTL_WFS_CLOSE: { u16 fd = Memory::Read_U16(request.buffer_in + 0x4); - INFO_LOG(IOS, "IOCTL_WFS_CLOSE(%d)", fd); + INFO_LOG(IOS_WFS, "IOCTL_WFS_CLOSE(%d)", fd); ReleaseFileDescriptor(fd); break; } @@ -207,7 +207,7 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request) FileDescriptor* fd_obj = FindFileDescriptor(fd); if (fd_obj == nullptr) { - ERROR_LOG(IOS, "IOCTL_WFS_READ: invalid file descriptor %d", fd); + ERROR_LOG(IOS_WFS, "IOCTL_WFS_READ: invalid file descriptor %d", fd); return_error_code = WFS_EBADFD; break; } @@ -229,7 +229,7 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request) fd_obj->position += read_bytes; } - INFO_LOG(IOS, "IOCTL_WFS_READ: read %zd bytes from FD %d (%s)", read_bytes, fd, + INFO_LOG(IOS_WFS, "IOCTL_WFS_READ: read %zd bytes from FD %d (%s)", read_bytes, fd, fd_obj->path.c_str()); return_error_code = static_cast(read_bytes); break; @@ -338,7 +338,7 @@ bool WFSSRV::FileDescriptor::Open() } else { - ERROR_LOG(IOS, "WFSOpen: invalid mode %d", mode); + ERROR_LOG(IOS_WFS, "WFSOpen: invalid mode %d", mode); return false; }