diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/hle/service/filesystem/fsp_srv.cpp | 15 | ||||
| -rw-r--r-- | src/core/hle/service/filesystem/fsp_srv.h | 12 | ||||
| -rw-r--r-- | src/core/reporter.cpp | 36 | ||||
| -rw-r--r-- | src/core/reporter.h | 9 |
4 files changed, 38 insertions, 34 deletions
diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp index 3af9881c2..db4d44c12 100644 --- a/src/core/hle/service/filesystem/fsp_srv.cpp +++ b/src/core/hle/service/filesystem/fsp_srv.cpp | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | #include "common/common_types.h" | 13 | #include "common/common_types.h" |
| 14 | #include "common/hex_util.h" | 14 | #include "common/hex_util.h" |
| 15 | #include "common/logging/log.h" | 15 | #include "common/logging/log.h" |
| 16 | #include "common/settings.h" | ||
| 16 | #include "common/string_util.h" | 17 | #include "common/string_util.h" |
| 17 | #include "core/core.h" | 18 | #include "core/core.h" |
| 18 | #include "core/file_sys/directory.h" | 19 | #include "core/file_sys/directory.h" |
| @@ -785,6 +786,10 @@ FSP_SRV::FSP_SRV(Core::System& system_) | |||
| 785 | }; | 786 | }; |
| 786 | // clang-format on | 787 | // clang-format on |
| 787 | RegisterHandlers(functions); | 788 | RegisterHandlers(functions); |
| 789 | |||
| 790 | if (Settings::values.enable_fs_access_log) { | ||
| 791 | access_log_mode = AccessLogMode::SdCard; | ||
| 792 | } | ||
| 788 | } | 793 | } |
| 789 | 794 | ||
| 790 | FSP_SRV::~FSP_SRV() = default; | 795 | FSP_SRV::~FSP_SRV() = default; |
| @@ -1041,9 +1046,9 @@ void FSP_SRV::DisableAutoSaveDataCreation(Kernel::HLERequestContext& ctx) { | |||
| 1041 | 1046 | ||
| 1042 | void FSP_SRV::SetGlobalAccessLogMode(Kernel::HLERequestContext& ctx) { | 1047 | void FSP_SRV::SetGlobalAccessLogMode(Kernel::HLERequestContext& ctx) { |
| 1043 | IPC::RequestParser rp{ctx}; | 1048 | IPC::RequestParser rp{ctx}; |
| 1044 | log_mode = rp.PopEnum<LogMode>(); | 1049 | access_log_mode = rp.PopEnum<AccessLogMode>(); |
| 1045 | 1050 | ||
| 1046 | LOG_DEBUG(Service_FS, "called, log_mode={:08X}", log_mode); | 1051 | LOG_DEBUG(Service_FS, "called, access_log_mode={}", access_log_mode); |
| 1047 | 1052 | ||
| 1048 | IPC::ResponseBuilder rb{ctx, 2}; | 1053 | IPC::ResponseBuilder rb{ctx, 2}; |
| 1049 | rb.Push(ResultSuccess); | 1054 | rb.Push(ResultSuccess); |
| @@ -1054,7 +1059,7 @@ void FSP_SRV::GetGlobalAccessLogMode(Kernel::HLERequestContext& ctx) { | |||
| 1054 | 1059 | ||
| 1055 | IPC::ResponseBuilder rb{ctx, 3}; | 1060 | IPC::ResponseBuilder rb{ctx, 3}; |
| 1056 | rb.Push(ResultSuccess); | 1061 | rb.Push(ResultSuccess); |
| 1057 | rb.PushEnum(log_mode); | 1062 | rb.PushEnum(access_log_mode); |
| 1058 | } | 1063 | } |
| 1059 | 1064 | ||
| 1060 | void FSP_SRV::OutputAccessLogToSdCard(Kernel::HLERequestContext& ctx) { | 1065 | void FSP_SRV::OutputAccessLogToSdCard(Kernel::HLERequestContext& ctx) { |
| @@ -1062,9 +1067,9 @@ void FSP_SRV::OutputAccessLogToSdCard(Kernel::HLERequestContext& ctx) { | |||
| 1062 | auto log = Common::StringFromFixedZeroTerminatedBuffer( | 1067 | auto log = Common::StringFromFixedZeroTerminatedBuffer( |
| 1063 | reinterpret_cast<const char*>(raw.data()), raw.size()); | 1068 | reinterpret_cast<const char*>(raw.data()), raw.size()); |
| 1064 | 1069 | ||
| 1065 | LOG_DEBUG(Service_FS, "called, log='{}'", log); | 1070 | LOG_DEBUG(Service_FS, "called"); |
| 1066 | 1071 | ||
| 1067 | reporter.SaveFilesystemAccessReport(log_mode, std::move(log)); | 1072 | reporter.SaveFSAccessLog(log); |
| 1068 | 1073 | ||
| 1069 | IPC::ResponseBuilder rb{ctx, 2}; | 1074 | IPC::ResponseBuilder rb{ctx, 2}; |
| 1070 | rb.Push(ResultSuccess); | 1075 | rb.Push(ResultSuccess); |
diff --git a/src/core/hle/service/filesystem/fsp_srv.h b/src/core/hle/service/filesystem/fsp_srv.h index ff7455a20..556708284 100644 --- a/src/core/hle/service/filesystem/fsp_srv.h +++ b/src/core/hle/service/filesystem/fsp_srv.h | |||
| @@ -24,11 +24,10 @@ enum class AccessLogVersion : u32 { | |||
| 24 | Latest = V7_0_0, | 24 | Latest = V7_0_0, |
| 25 | }; | 25 | }; |
| 26 | 26 | ||
| 27 | enum class LogMode : u32 { | 27 | enum class AccessLogMode : u32 { |
| 28 | Off, | 28 | None, |
| 29 | Log, | 29 | Log, |
| 30 | RedirectToSdCard, | 30 | SdCard, |
| 31 | LogToSdCard = Log | RedirectToSdCard, | ||
| 32 | }; | 31 | }; |
| 33 | 32 | ||
| 34 | class FSP_SRV final : public ServiceFramework<FSP_SRV> { | 33 | class FSP_SRV final : public ServiceFramework<FSP_SRV> { |
| @@ -59,13 +58,12 @@ private: | |||
| 59 | 58 | ||
| 60 | FileSystemController& fsc; | 59 | FileSystemController& fsc; |
| 61 | const FileSys::ContentProvider& content_provider; | 60 | const FileSys::ContentProvider& content_provider; |
| 61 | const Core::Reporter& reporter; | ||
| 62 | 62 | ||
| 63 | FileSys::VirtualFile romfs; | 63 | FileSys::VirtualFile romfs; |
| 64 | u64 current_process_id = 0; | 64 | u64 current_process_id = 0; |
| 65 | u32 access_log_program_index = 0; | 65 | u32 access_log_program_index = 0; |
| 66 | LogMode log_mode = LogMode::LogToSdCard; | 66 | AccessLogMode access_log_mode = AccessLogMode::None; |
| 67 | |||
| 68 | const Core::Reporter& reporter; | ||
| 69 | }; | 67 | }; |
| 70 | 68 | ||
| 71 | } // namespace Service::FileSystem | 69 | } // namespace Service::FileSystem |
diff --git a/src/core/reporter.cpp b/src/core/reporter.cpp index ec2a16e62..82b0f535a 100644 --- a/src/core/reporter.cpp +++ b/src/core/reporter.cpp | |||
| @@ -195,7 +195,9 @@ json GetHLERequestContextData(Kernel::HLERequestContext& ctx, Core::Memory::Memo | |||
| 195 | 195 | ||
| 196 | namespace Core { | 196 | namespace Core { |
| 197 | 197 | ||
| 198 | Reporter::Reporter(System& system_) : system(system_) {} | 198 | Reporter::Reporter(System& system_) : system(system_) { |
| 199 | ClearFSAccessLog(); | ||
| 200 | } | ||
| 199 | 201 | ||
| 200 | Reporter::~Reporter() = default; | 202 | Reporter::~Reporter() = default; |
| 201 | 203 | ||
| @@ -362,22 +364,12 @@ void Reporter::SaveErrorReport(u64 title_id, ResultCode result, | |||
| 362 | SaveToFile(std::move(out), GetPath("error_report", title_id, timestamp)); | 364 | SaveToFile(std::move(out), GetPath("error_report", title_id, timestamp)); |
| 363 | } | 365 | } |
| 364 | 366 | ||
| 365 | void Reporter::SaveFilesystemAccessReport(Service::FileSystem::LogMode log_mode, | 367 | void Reporter::SaveFSAccessLog(std::string_view log_message) const { |
| 366 | std::string log_message) const { | 368 | const auto access_log_path = |
| 367 | if (!IsReportingEnabled()) | 369 | Common::FS::GetYuzuPath(Common::FS::YuzuPath::SDMCDir) / "FsAccessLog.txt"; |
| 368 | return; | ||
| 369 | |||
| 370 | const auto timestamp = GetTimestamp(); | ||
| 371 | const auto title_id = system.CurrentProcess()->GetTitleID(); | ||
| 372 | json out; | ||
| 373 | 370 | ||
| 374 | out["yuzu_version"] = GetYuzuVersionData(); | 371 | void(Common::FS::AppendStringToFile(access_log_path, Common::FS::FileType::TextFile, |
| 375 | out["report_common"] = GetReportCommonData(title_id, ResultSuccess, timestamp); | 372 | log_message)); |
| 376 | |||
| 377 | out["log_mode"] = fmt::format("{:08X}", static_cast<u32>(log_mode)); | ||
| 378 | out["log_message"] = std::move(log_message); | ||
| 379 | |||
| 380 | SaveToFile(std::move(out), GetPath("filesystem_access_report", title_id, timestamp)); | ||
| 381 | } | 373 | } |
| 382 | 374 | ||
| 383 | void Reporter::SaveUserReport() const { | 375 | void Reporter::SaveUserReport() const { |
| @@ -392,6 +384,18 @@ void Reporter::SaveUserReport() const { | |||
| 392 | GetPath("user_report", title_id, timestamp)); | 384 | GetPath("user_report", title_id, timestamp)); |
| 393 | } | 385 | } |
| 394 | 386 | ||
| 387 | void Reporter::ClearFSAccessLog() const { | ||
| 388 | const auto access_log_path = | ||
| 389 | Common::FS::GetYuzuPath(Common::FS::YuzuPath::SDMCDir) / "FsAccessLog.txt"; | ||
| 390 | |||
| 391 | Common::FS::IOFile access_log_file{access_log_path, Common::FS::FileAccessMode::Write, | ||
| 392 | Common::FS::FileType::TextFile}; | ||
| 393 | |||
| 394 | if (!access_log_file.IsOpen()) { | ||
| 395 | LOG_ERROR(Common_Filesystem, "Failed to clear the filesystem access log."); | ||
| 396 | } | ||
| 397 | } | ||
| 398 | |||
| 395 | bool Reporter::IsReportingEnabled() const { | 399 | bool Reporter::IsReportingEnabled() const { |
| 396 | return Settings::values.reporting_services; | 400 | return Settings::values.reporting_services; |
| 397 | } | 401 | } |
diff --git a/src/core/reporter.h b/src/core/reporter.h index 6fb6ebffa..6e9edeea3 100644 --- a/src/core/reporter.h +++ b/src/core/reporter.h | |||
| @@ -16,10 +16,6 @@ namespace Kernel { | |||
| 16 | class HLERequestContext; | 16 | class HLERequestContext; |
| 17 | } // namespace Kernel | 17 | } // namespace Kernel |
| 18 | 18 | ||
| 19 | namespace Service::FileSystem { | ||
| 20 | enum class LogMode : u32; | ||
| 21 | } | ||
| 22 | |||
| 23 | namespace Service::LM { | 19 | namespace Service::LM { |
| 24 | struct LogMessage; | 20 | struct LogMessage; |
| 25 | } // namespace Service::LM | 21 | } // namespace Service::LM |
| @@ -69,14 +65,15 @@ public: | |||
| 69 | std::optional<std::string> custom_text_main = {}, | 65 | std::optional<std::string> custom_text_main = {}, |
| 70 | std::optional<std::string> custom_text_detail = {}) const; | 66 | std::optional<std::string> custom_text_detail = {}) const; |
| 71 | 67 | ||
| 72 | void SaveFilesystemAccessReport(Service::FileSystem::LogMode log_mode, | 68 | void SaveFSAccessLog(std::string_view log_message) const; |
| 73 | std::string log_message) const; | ||
| 74 | 69 | ||
| 75 | // Can be used anywhere to generate a backtrace and general info report at any point during | 70 | // Can be used anywhere to generate a backtrace and general info report at any point during |
| 76 | // execution. Not intended to be used for anything other than debugging or testing. | 71 | // execution. Not intended to be used for anything other than debugging or testing. |
| 77 | void SaveUserReport() const; | 72 | void SaveUserReport() const; |
| 78 | 73 | ||
| 79 | private: | 74 | private: |
| 75 | void ClearFSAccessLog() const; | ||
| 76 | |||
| 80 | bool IsReportingEnabled() const; | 77 | bool IsReportingEnabled() const; |
| 81 | 78 | ||
| 82 | System& system; | 79 | System& system; |