Merge pull request #6615 from leoetlino/sysconf
SysConf: Migrate to new filesystem interface
This commit is contained in:
commit
371f807e67
|
@ -34,7 +34,6 @@ add_library(common
|
||||||
SettingsHandler.cpp
|
SettingsHandler.cpp
|
||||||
StringUtil.cpp
|
StringUtil.cpp
|
||||||
SymbolDB.cpp
|
SymbolDB.cpp
|
||||||
SysConf.cpp
|
|
||||||
Thread.cpp
|
Thread.cpp
|
||||||
Timer.cpp
|
Timer.cpp
|
||||||
TraversalClient.cpp
|
TraversalClient.cpp
|
||||||
|
|
|
@ -147,7 +147,6 @@
|
||||||
<ClInclude Include="StringUtil.h" />
|
<ClInclude Include="StringUtil.h" />
|
||||||
<ClInclude Include="Swap.h" />
|
<ClInclude Include="Swap.h" />
|
||||||
<ClInclude Include="SymbolDB.h" />
|
<ClInclude Include="SymbolDB.h" />
|
||||||
<ClInclude Include="SysConf.h" />
|
|
||||||
<ClInclude Include="Thread.h" />
|
<ClInclude Include="Thread.h" />
|
||||||
<ClInclude Include="Timer.h" />
|
<ClInclude Include="Timer.h" />
|
||||||
<ClInclude Include="TraversalClient.h" />
|
<ClInclude Include="TraversalClient.h" />
|
||||||
|
@ -203,7 +202,6 @@
|
||||||
<ClCompile Include="SettingsHandler.cpp" />
|
<ClCompile Include="SettingsHandler.cpp" />
|
||||||
<ClCompile Include="StringUtil.cpp" />
|
<ClCompile Include="StringUtil.cpp" />
|
||||||
<ClCompile Include="SymbolDB.cpp" />
|
<ClCompile Include="SymbolDB.cpp" />
|
||||||
<ClCompile Include="SysConf.cpp" />
|
|
||||||
<ClCompile Include="Thread.cpp" />
|
<ClCompile Include="Thread.cpp" />
|
||||||
<ClCompile Include="Timer.cpp" />
|
<ClCompile Include="Timer.cpp" />
|
||||||
<ClCompile Include="TraversalClient.cpp" />
|
<ClCompile Include="TraversalClient.cpp" />
|
||||||
|
|
|
@ -67,7 +67,6 @@
|
||||||
<ClInclude Include="StringUtil.h" />
|
<ClInclude Include="StringUtil.h" />
|
||||||
<ClInclude Include="Swap.h" />
|
<ClInclude Include="Swap.h" />
|
||||||
<ClInclude Include="SymbolDB.h" />
|
<ClInclude Include="SymbolDB.h" />
|
||||||
<ClInclude Include="SysConf.h" />
|
|
||||||
<ClInclude Include="Thread.h" />
|
<ClInclude Include="Thread.h" />
|
||||||
<ClInclude Include="Timer.h" />
|
<ClInclude Include="Timer.h" />
|
||||||
<ClInclude Include="Version.h" />
|
<ClInclude Include="Version.h" />
|
||||||
|
@ -289,7 +288,6 @@
|
||||||
<ClCompile Include="SettingsHandler.cpp" />
|
<ClCompile Include="SettingsHandler.cpp" />
|
||||||
<ClCompile Include="StringUtil.cpp" />
|
<ClCompile Include="StringUtil.cpp" />
|
||||||
<ClCompile Include="SymbolDB.cpp" />
|
<ClCompile Include="SymbolDB.cpp" />
|
||||||
<ClCompile Include="SysConf.cpp" />
|
|
||||||
<ClCompile Include="Thread.cpp" />
|
<ClCompile Include="Thread.cpp" />
|
||||||
<ClCompile Include="Timer.cpp" />
|
<ClCompile Include="Timer.cpp" />
|
||||||
<ClCompile Include="Version.cpp" />
|
<ClCompile Include="Version.cpp" />
|
||||||
|
|
|
@ -16,6 +16,7 @@ add_library(core
|
||||||
NetPlayServer.cpp
|
NetPlayServer.cpp
|
||||||
PatchEngine.cpp
|
PatchEngine.cpp
|
||||||
State.cpp
|
State.cpp
|
||||||
|
SysConf.cpp
|
||||||
TitleDatabase.cpp
|
TitleDatabase.cpp
|
||||||
WiiRoot.cpp
|
WiiRoot.cpp
|
||||||
WiiUtils.cpp
|
WiiUtils.cpp
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include <variant>
|
#include <variant>
|
||||||
|
|
||||||
#include "Common/Config/Config.h"
|
#include "Common/Config/Config.h"
|
||||||
#include "Common/SysConf.h"
|
#include "Core/SysConf.h"
|
||||||
|
|
||||||
namespace Config
|
namespace Config
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,12 +17,13 @@
|
||||||
#include "Common/FileUtil.h"
|
#include "Common/FileUtil.h"
|
||||||
#include "Common/IniFile.h"
|
#include "Common/IniFile.h"
|
||||||
#include "Common/Logging/Log.h"
|
#include "Common/Logging/Log.h"
|
||||||
#include "Common/SysConf.h"
|
|
||||||
|
|
||||||
#include "Core/Config/SYSCONFSettings.h"
|
#include "Core/Config/SYSCONFSettings.h"
|
||||||
#include "Core/ConfigLoaders/IsSettingSaveable.h"
|
#include "Core/ConfigLoaders/IsSettingSaveable.h"
|
||||||
#include "Core/Core.h"
|
#include "Core/Core.h"
|
||||||
|
#include "Core/IOS/IOS.h"
|
||||||
#include "Core/IOS/USB/Bluetooth/BTBase.h"
|
#include "Core/IOS/USB/Bluetooth/BTBase.h"
|
||||||
|
#include "Core/SysConf.h"
|
||||||
|
|
||||||
namespace ConfigLoaders
|
namespace ConfigLoaders
|
||||||
{
|
{
|
||||||
|
@ -31,7 +32,8 @@ void SaveToSYSCONF(Config::LayerType layer)
|
||||||
if (Core::IsRunning())
|
if (Core::IsRunning())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SysConf sysconf{Common::FromWhichRoot::FROM_CONFIGURED_ROOT};
|
IOS::HLE::Kernel ios;
|
||||||
|
SysConf sysconf{ios.GetFS()};
|
||||||
|
|
||||||
for (const Config::SYSCONFSetting& setting : Config::SYSCONF_SETTINGS)
|
for (const Config::SYSCONFSetting& setting : Config::SYSCONF_SETTINGS)
|
||||||
{
|
{
|
||||||
|
@ -154,7 +156,8 @@ private:
|
||||||
if (Core::IsRunning())
|
if (Core::IsRunning())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SysConf sysconf{Common::FromWhichRoot::FROM_CONFIGURED_ROOT};
|
IOS::HLE::Kernel ios;
|
||||||
|
SysConf sysconf{ios.GetFS()};
|
||||||
for (const Config::SYSCONFSetting& setting : Config::SYSCONF_SETTINGS)
|
for (const Config::SYSCONFSetting& setting : Config::SYSCONF_SETTINGS)
|
||||||
{
|
{
|
||||||
std::visit(
|
std::visit(
|
||||||
|
|
|
@ -292,6 +292,7 @@
|
||||||
<ClCompile Include="PowerPC\PPCTables.cpp" />
|
<ClCompile Include="PowerPC\PPCTables.cpp" />
|
||||||
<ClCompile Include="PowerPC\Profiler.cpp" />
|
<ClCompile Include="PowerPC\Profiler.cpp" />
|
||||||
<ClCompile Include="State.cpp" />
|
<ClCompile Include="State.cpp" />
|
||||||
|
<ClCompile Include="SysConf.cpp" />
|
||||||
<ClCompile Include="TitleDatabase.cpp" />
|
<ClCompile Include="TitleDatabase.cpp" />
|
||||||
<ClCompile Include="WiiRoot.cpp" />
|
<ClCompile Include="WiiRoot.cpp" />
|
||||||
<ClCompile Include="WiiUtils.cpp" />
|
<ClCompile Include="WiiUtils.cpp" />
|
||||||
|
@ -530,6 +531,7 @@
|
||||||
<ClInclude Include="PowerPC\PPCTables.h" />
|
<ClInclude Include="PowerPC\PPCTables.h" />
|
||||||
<ClInclude Include="PowerPC\Profiler.h" />
|
<ClInclude Include="PowerPC\Profiler.h" />
|
||||||
<ClInclude Include="State.h" />
|
<ClInclude Include="State.h" />
|
||||||
|
<ClInclude Include="SysConf.h" />
|
||||||
<ClInclude Include="Titles.h" />
|
<ClInclude Include="Titles.h" />
|
||||||
<ClInclude Include="TitleDatabase.h" />
|
<ClInclude Include="TitleDatabase.h" />
|
||||||
<ClInclude Include="WiiRoot.h" />
|
<ClInclude Include="WiiRoot.h" />
|
||||||
|
|
|
@ -179,6 +179,7 @@
|
||||||
<ClCompile Include="NetPlayServer.cpp" />
|
<ClCompile Include="NetPlayServer.cpp" />
|
||||||
<ClCompile Include="PatchEngine.cpp" />
|
<ClCompile Include="PatchEngine.cpp" />
|
||||||
<ClCompile Include="State.cpp" />
|
<ClCompile Include="State.cpp" />
|
||||||
|
<ClCompile Include="SysConf.cpp" />
|
||||||
<ClCompile Include="TitleDatabase.cpp" />
|
<ClCompile Include="TitleDatabase.cpp" />
|
||||||
<ClCompile Include="WiiRoot.cpp" />
|
<ClCompile Include="WiiRoot.cpp" />
|
||||||
<ClCompile Include="WiiUtils.cpp" />
|
<ClCompile Include="WiiUtils.cpp" />
|
||||||
|
@ -912,6 +913,7 @@
|
||||||
<ClInclude Include="NetPlayServer.h" />
|
<ClInclude Include="NetPlayServer.h" />
|
||||||
<ClInclude Include="PatchEngine.h" />
|
<ClInclude Include="PatchEngine.h" />
|
||||||
<ClInclude Include="State.h" />
|
<ClInclude Include="State.h" />
|
||||||
|
<ClInclude Include="SysConf.h" />
|
||||||
<ClInclude Include="Titles.h" />
|
<ClInclude Include="Titles.h" />
|
||||||
<ClInclude Include="TitleDatabase.h" />
|
<ClInclude Include="TitleDatabase.h" />
|
||||||
<ClInclude Include="WiiRoot.h" />
|
<ClInclude Include="WiiRoot.h" />
|
||||||
|
|
|
@ -28,7 +28,7 @@ FileHandle::FileHandle(FileHandle&& other) : m_fs{other.m_fs}, m_fd{other.m_fd}
|
||||||
|
|
||||||
FileHandle& FileHandle::operator=(FileHandle&& other)
|
FileHandle& FileHandle::operator=(FileHandle&& other)
|
||||||
{
|
{
|
||||||
if (*this != other)
|
if (std::tie(m_fs, m_fd) != std::tie(other.m_fs, other.m_fd))
|
||||||
*this = std::move(other);
|
*this = std::move(other);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,16 @@ Fd FileHandle::Release()
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result<u32> FileHandle::Seek(u32 offset, SeekMode mode) const
|
||||||
|
{
|
||||||
|
return m_fs->SeekFile(*m_fd, offset, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
Result<FileStatus> FileHandle::GetStatus() const
|
||||||
|
{
|
||||||
|
return m_fs->GetFileStatus(*m_fd);
|
||||||
|
}
|
||||||
|
|
||||||
void FileSystem::Init()
|
void FileSystem::Init()
|
||||||
{
|
{
|
||||||
if (Delete(0, 0, "/tmp") == ResultCode::Success)
|
if (Delete(0, 0, "/tmp") == ResultCode::Success)
|
||||||
|
|
|
@ -108,10 +108,18 @@ public:
|
||||||
FileHandle& operator=(const FileHandle&) = delete;
|
FileHandle& operator=(const FileHandle&) = delete;
|
||||||
FileHandle& operator=(FileHandle&&);
|
FileHandle& operator=(FileHandle&&);
|
||||||
|
|
||||||
operator Fd() const { return m_fd.value(); }
|
|
||||||
/// Release the FD so that it is not automatically closed.
|
/// Release the FD so that it is not automatically closed.
|
||||||
Fd Release();
|
Fd Release();
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
Result<size_t> Read(T* ptr, size_t count) const;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
Result<size_t> Write(const T* ptr, size_t count) const;
|
||||||
|
|
||||||
|
Result<u32> Seek(u32 offset, SeekMode mode) const;
|
||||||
|
Result<FileStatus> GetStatus() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FileSystem* m_fs;
|
FileSystem* m_fs;
|
||||||
std::optional<Fd> m_fd;
|
std::optional<Fd> m_fd;
|
||||||
|
@ -140,26 +148,6 @@ public:
|
||||||
/// Get status for a file descriptor.
|
/// Get status for a file descriptor.
|
||||||
virtual Result<FileStatus> GetFileStatus(Fd fd) = 0;
|
virtual Result<FileStatus> GetFileStatus(Fd fd) = 0;
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
Result<u32> ReadFile(Fd fd, T* ptr, u32 count)
|
|
||||||
{
|
|
||||||
const Result<u32> bytes = ReadBytesFromFile(fd, reinterpret_cast<u8*>(ptr), sizeof(T) * count);
|
|
||||||
if (!bytes)
|
|
||||||
return bytes.Error();
|
|
||||||
if (*bytes != sizeof(T) * count)
|
|
||||||
return ResultCode::ShortRead;
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
Result<u32> WriteFile(Fd fd, const T* ptr, u32 count)
|
|
||||||
{
|
|
||||||
const auto result = WriteBytesToFile(fd, reinterpret_cast<const u8*>(ptr), sizeof(T) * count);
|
|
||||||
if (!result)
|
|
||||||
return result.Error();
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a file with the specified path and metadata.
|
/// Create a file with the specified path and metadata.
|
||||||
virtual ResultCode CreateFile(Uid caller_uid, Gid caller_gid, const std::string& path,
|
virtual ResultCode CreateFile(Uid caller_uid, Gid caller_gid, const std::string& path,
|
||||||
FileAttribute attribute, Mode owner_mode, Mode group_mode,
|
FileAttribute attribute, Mode owner_mode, Mode group_mode,
|
||||||
|
@ -195,6 +183,28 @@ protected:
|
||||||
void Init();
|
void Init();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
Result<size_t> FileHandle::Read(T* ptr, size_t count) const
|
||||||
|
{
|
||||||
|
const Result<u32> bytes = m_fs->ReadBytesFromFile(*m_fd, reinterpret_cast<u8*>(ptr),
|
||||||
|
static_cast<u32>(sizeof(T) * count));
|
||||||
|
if (!bytes)
|
||||||
|
return bytes.Error();
|
||||||
|
if (*bytes != sizeof(T) * count)
|
||||||
|
return ResultCode::ShortRead;
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
Result<size_t> FileHandle::Write(const T* ptr, size_t count) const
|
||||||
|
{
|
||||||
|
const auto result = m_fs->WriteBytesToFile(*m_fd, reinterpret_cast<const u8*>(ptr),
|
||||||
|
static_cast<u32>(sizeof(T) * count));
|
||||||
|
if (!result)
|
||||||
|
return result.Error();
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
enum class Location
|
enum class Location
|
||||||
{
|
{
|
||||||
Configured,
|
Configured,
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#include "Common/File.h"
|
#include "Common/File.h"
|
||||||
#include "Common/FileUtil.h"
|
#include "Common/FileUtil.h"
|
||||||
#include "Common/Logging/Log.h"
|
#include "Common/Logging/Log.h"
|
||||||
#include "Common/SysConf.h"
|
#include "Core/SysConf.h"
|
||||||
|
|
||||||
namespace IOS
|
namespace IOS
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#include "Common/MsgHandler.h"
|
#include "Common/MsgHandler.h"
|
||||||
#include "Common/NandPaths.h"
|
#include "Common/NandPaths.h"
|
||||||
#include "Common/StringUtil.h"
|
#include "Common/StringUtil.h"
|
||||||
#include "Common/SysConf.h"
|
|
||||||
#include "Core/Core.h"
|
#include "Core/Core.h"
|
||||||
#include "Core/CoreTiming.h"
|
#include "Core/CoreTiming.h"
|
||||||
#include "Core/Debugger/Debugger_SymbolMap.h"
|
#include "Core/Debugger/Debugger_SymbolMap.h"
|
||||||
|
@ -25,6 +24,7 @@
|
||||||
#include "Core/Host.h"
|
#include "Core/Host.h"
|
||||||
#include "Core/IOS/Device.h"
|
#include "Core/IOS/Device.h"
|
||||||
#include "Core/IOS/IOS.h"
|
#include "Core/IOS/IOS.h"
|
||||||
|
#include "Core/SysConf.h"
|
||||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||||
|
|
||||||
namespace IOS
|
namespace IOS
|
||||||
|
@ -42,8 +42,7 @@ namespace Device
|
||||||
BluetoothEmu::BluetoothEmu(Kernel& ios, const std::string& device_name)
|
BluetoothEmu::BluetoothEmu(Kernel& ios, const std::string& device_name)
|
||||||
: BluetoothBase(ios, device_name)
|
: BluetoothBase(ios, device_name)
|
||||||
{
|
{
|
||||||
SysConf sysconf{Core::WantsDeterminism() ? Common::FromWhichRoot::FROM_SESSION_ROOT :
|
SysConf sysconf{ios.GetFS()};
|
||||||
Common::FromWhichRoot::FROM_CONFIGURED_ROOT};
|
|
||||||
if (!Core::WantsDeterminism())
|
if (!Core::WantsDeterminism())
|
||||||
BackUpBTInfoSection(&sysconf);
|
BackUpBTInfoSection(&sysconf);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// Licensed under GPLv2+
|
// Licensed under GPLv2+
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include "Common/SysConf.h"
|
#include "Core/SysConf.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
@ -14,6 +14,7 @@
|
||||||
#include "Common/FileUtil.h"
|
#include "Common/FileUtil.h"
|
||||||
#include "Common/Logging/Log.h"
|
#include "Common/Logging/Log.h"
|
||||||
#include "Common/Swap.h"
|
#include "Common/Swap.h"
|
||||||
|
#include "Core/IOS/FS/FileSystem.h"
|
||||||
|
|
||||||
constexpr size_t SYSCONF_SIZE = 0x4000;
|
constexpr size_t SYSCONF_SIZE = 0x4000;
|
||||||
|
|
||||||
|
@ -35,9 +36,8 @@ static size_t GetNonArrayEntrySize(SysConf::Entry::Type type)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SysConf::SysConf(const Common::FromWhichRoot root_type)
|
SysConf::SysConf(std::shared_ptr<IOS::HLE::FS::FileSystem> fs) : m_fs{fs}
|
||||||
{
|
{
|
||||||
m_file_name = Common::RootUserPath(root_type) + DIR_SEP WII_SYSCONF_DIR DIR_SEP WII_SYSCONF;
|
|
||||||
Load();
|
Load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,39 +55,40 @@ void SysConf::Load()
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
|
|
||||||
if (File::GetSize(m_file_name) != SYSCONF_SIZE || !LoadFromFile(m_file_name))
|
const auto file = m_fs->OpenFile(IOS::HLE::FS::Uid{0}, IOS::HLE::FS::Gid{0},
|
||||||
|
"/shared2/sys/SYSCONF", IOS::HLE::FS::Mode::Read);
|
||||||
|
if (!file || file->GetStatus()->size != SYSCONF_SIZE || !LoadFromFile(*file))
|
||||||
{
|
{
|
||||||
WARN_LOG(CORE, "No valid SYSCONF detected. Creating a new one.");
|
WARN_LOG(CORE, "No valid SYSCONF detected. Creating a new one.");
|
||||||
InsertDefaultEntries();
|
InsertDefaultEntries();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SysConf::LoadFromFile(const std::string& file_name)
|
bool SysConf::LoadFromFile(const IOS::HLE::FS::FileHandle& file)
|
||||||
{
|
{
|
||||||
File::IOFile file(file_name, "rb");
|
file.Seek(4, IOS::HLE::FS::SeekMode::Set);
|
||||||
file.Seek(4, SEEK_SET);
|
|
||||||
u16 number_of_entries;
|
u16 number_of_entries;
|
||||||
file.ReadBytes(&number_of_entries, sizeof(number_of_entries));
|
file.Read(&number_of_entries, 1);
|
||||||
number_of_entries = Common::swap16(number_of_entries);
|
number_of_entries = Common::swap16(number_of_entries);
|
||||||
|
|
||||||
std::vector<u16> offsets(number_of_entries);
|
std::vector<u16> offsets(number_of_entries);
|
||||||
for (u16& offset : offsets)
|
for (u16& offset : offsets)
|
||||||
{
|
{
|
||||||
file.ReadBytes(&offset, sizeof(offset));
|
file.Read(&offset, 1);
|
||||||
offset = Common::swap16(offset);
|
offset = Common::swap16(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const u16 offset : offsets)
|
for (const u16 offset : offsets)
|
||||||
{
|
{
|
||||||
file.Seek(offset, SEEK_SET);
|
file.Seek(offset, IOS::HLE::FS::SeekMode::Set);
|
||||||
|
|
||||||
// Metadata
|
// Metadata
|
||||||
u8 description = 0;
|
u8 description = 0;
|
||||||
file.ReadBytes(&description, sizeof(description));
|
file.Read(&description, 1);
|
||||||
const Entry::Type type = static_cast<Entry::Type>((description & 0xe0) >> 5);
|
const Entry::Type type = static_cast<Entry::Type>((description & 0xe0) >> 5);
|
||||||
const u8 name_length = (description & 0x1f) + 1;
|
const u8 name_length = (description & 0x1f) + 1;
|
||||||
std::string name(name_length, '\0');
|
std::string name(name_length, '\0');
|
||||||
file.ReadBytes(&name[0], name.size());
|
file.Read(&name[0], name.size());
|
||||||
|
|
||||||
// Data
|
// Data
|
||||||
std::vector<u8> data;
|
std::vector<u8> data;
|
||||||
|
@ -96,7 +97,7 @@ bool SysConf::LoadFromFile(const std::string& file_name)
|
||||||
case Entry::Type::BigArray:
|
case Entry::Type::BigArray:
|
||||||
{
|
{
|
||||||
u16 data_length = 0;
|
u16 data_length = 0;
|
||||||
file.ReadBytes(&data_length, sizeof(data_length));
|
file.Read(&data_length, 1);
|
||||||
// The stored u16 is length - 1, not length.
|
// The stored u16 is length - 1, not length.
|
||||||
data.resize(Common::swap16(data_length) + 1);
|
data.resize(Common::swap16(data_length) + 1);
|
||||||
break;
|
break;
|
||||||
|
@ -104,7 +105,7 @@ bool SysConf::LoadFromFile(const std::string& file_name)
|
||||||
case Entry::Type::SmallArray:
|
case Entry::Type::SmallArray:
|
||||||
{
|
{
|
||||||
u8 data_length = 0;
|
u8 data_length = 0;
|
||||||
file.ReadBytes(&data_length, sizeof(data_length));
|
file.Read(&data_length, 1);
|
||||||
data.resize(data_length + 1);
|
data.resize(data_length + 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -121,7 +122,7 @@ bool SysConf::LoadFromFile(const std::string& file_name)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
file.ReadBytes(data.data(), data.size());
|
file.Read(data.data(), data.size());
|
||||||
AddEntry({type, name, std::move(data)});
|
AddEntry({type, name, std::move(data)});
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -194,14 +195,19 @@ bool SysConf::Save() const
|
||||||
std::copy(footer.cbegin(), footer.cend(), buffer.end() - footer.size());
|
std::copy(footer.cbegin(), footer.cend(), buffer.end() - footer.size());
|
||||||
|
|
||||||
// Write the new data.
|
// Write the new data.
|
||||||
const std::string temp_file = m_file_name + ".tmp";
|
const std::string temp_file = "/tmp/SYSCONF";
|
||||||
File::CreateFullPath(temp_file);
|
constexpr u32 SYSMENU_UID = 0x1000;
|
||||||
|
constexpr u16 SYSMENU_GID = 1;
|
||||||
|
constexpr auto rw_mode = IOS::HLE::FS::Mode::ReadWrite;
|
||||||
{
|
{
|
||||||
File::IOFile file(temp_file, "wb");
|
m_fs->CreateFile(SYSMENU_UID, SYSMENU_GID, temp_file, 0, rw_mode, rw_mode, rw_mode);
|
||||||
if (!file.WriteBytes(buffer.data(), buffer.size()))
|
auto file = m_fs->OpenFile(SYSMENU_UID, SYSMENU_GID, temp_file, IOS::HLE::FS::Mode::Write);
|
||||||
|
if (!file || !file->Write(buffer.data(), buffer.size()))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return File::RenameSync(temp_file, m_file_name);
|
m_fs->CreateDirectory(SYSMENU_UID, SYSMENU_GID, "/shared2/sys", 0, rw_mode, rw_mode, rw_mode);
|
||||||
|
const auto result = m_fs->Rename(SYSMENU_UID, SYSMENU_GID, temp_file, "/shared2/sys/SYSCONF");
|
||||||
|
return result == IOS::HLE::FS::ResultCode::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
SysConf::Entry::Entry(Type type_, const std::string& name_) : type(type_), name(name_)
|
SysConf::Entry::Entry(Type type_, const std::string& name_) : type(type_), name(name_)
|
|
@ -7,6 +7,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -14,10 +15,16 @@
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
#include "Common/NandPaths.h"
|
#include "Common/NandPaths.h"
|
||||||
|
|
||||||
|
namespace IOS::HLE::FS
|
||||||
|
{
|
||||||
|
class FileHandle;
|
||||||
|
class FileSystem;
|
||||||
|
}
|
||||||
|
|
||||||
class SysConf final
|
class SysConf final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit SysConf(Common::FromWhichRoot root_type);
|
explicit SysConf(std::shared_ptr<IOS::HLE::FS::FileSystem> fs);
|
||||||
~SysConf();
|
~SysConf();
|
||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
|
@ -85,8 +92,8 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void InsertDefaultEntries();
|
void InsertDefaultEntries();
|
||||||
bool LoadFromFile(const std::string& file_name);
|
bool LoadFromFile(const IOS::HLE::FS::FileHandle& file);
|
||||||
|
|
||||||
std::string m_file_name;
|
|
||||||
std::vector<Entry> m_entries;
|
std::vector<Entry> m_entries;
|
||||||
|
std::shared_ptr<IOS::HLE::FS::FileSystem> m_fs;
|
||||||
};
|
};
|
|
@ -11,10 +11,11 @@
|
||||||
#include "Common/Logging/Log.h"
|
#include "Common/Logging/Log.h"
|
||||||
#include "Common/NandPaths.h"
|
#include "Common/NandPaths.h"
|
||||||
#include "Common/StringUtil.h"
|
#include "Common/StringUtil.h"
|
||||||
#include "Common/SysConf.h"
|
|
||||||
#include "Core/ConfigManager.h"
|
#include "Core/ConfigManager.h"
|
||||||
|
#include "Core/IOS/IOS.h"
|
||||||
#include "Core/Movie.h"
|
#include "Core/Movie.h"
|
||||||
#include "Core/NetPlayClient.h"
|
#include "Core/NetPlayClient.h"
|
||||||
|
#include "Core/SysConf.h"
|
||||||
|
|
||||||
namespace Core
|
namespace Core
|
||||||
{
|
{
|
||||||
|
@ -64,7 +65,7 @@ void InitializeWiiRoot(bool use_temporary)
|
||||||
WARN_LOG(IOS_FS, "Using temporary directory %s for minimal Wii FS", s_temp_wii_root.c_str());
|
WARN_LOG(IOS_FS, "Using temporary directory %s for minimal Wii FS", s_temp_wii_root.c_str());
|
||||||
File::SetUserPath(D_SESSION_WIIROOT_IDX, s_temp_wii_root);
|
File::SetUserPath(D_SESSION_WIIROOT_IDX, s_temp_wii_root);
|
||||||
// Generate a SYSCONF with default settings for the temporary Wii NAND.
|
// Generate a SYSCONF with default settings for the temporary Wii NAND.
|
||||||
SysConf sysconf{Common::FromWhichRoot::FROM_SESSION_ROOT};
|
SysConf sysconf{IOS::HLE::Kernel{}.GetFS()};
|
||||||
sysconf.Save();
|
sysconf.Save();
|
||||||
|
|
||||||
InitializeDeterministicWiiSaves();
|
InitializeDeterministicWiiSaves();
|
||||||
|
|
|
@ -29,13 +29,13 @@
|
||||||
#include "Common/NandPaths.h"
|
#include "Common/NandPaths.h"
|
||||||
#include "Common/StringUtil.h"
|
#include "Common/StringUtil.h"
|
||||||
#include "Common/Swap.h"
|
#include "Common/Swap.h"
|
||||||
#include "Common/SysConf.h"
|
|
||||||
#include "Core/CommonTitles.h"
|
#include "Core/CommonTitles.h"
|
||||||
#include "Core/ConfigManager.h"
|
#include "Core/ConfigManager.h"
|
||||||
#include "Core/IOS/Device.h"
|
#include "Core/IOS/Device.h"
|
||||||
#include "Core/IOS/ES/ES.h"
|
#include "Core/IOS/ES/ES.h"
|
||||||
#include "Core/IOS/ES/Formats.h"
|
#include "Core/IOS/ES/Formats.h"
|
||||||
#include "Core/IOS/IOS.h"
|
#include "Core/IOS/IOS.h"
|
||||||
|
#include "Core/SysConf.h"
|
||||||
#include "DiscIO/DiscExtractor.h"
|
#include "DiscIO/DiscExtractor.h"
|
||||||
#include "DiscIO/Enums.h"
|
#include "DiscIO/Enums.h"
|
||||||
#include "DiscIO/Filesystem.h"
|
#include "DiscIO/Filesystem.h"
|
||||||
|
@ -136,7 +136,7 @@ bool InstallWAD(IOS::HLE::Kernel& ios, const DiscIO::WiiWAD& wad, InstallType in
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete a previous temporary title, if it exists.
|
// Delete a previous temporary title, if it exists.
|
||||||
SysConf sysconf{Common::FROM_SESSION_ROOT};
|
SysConf sysconf{ios.GetFS()};
|
||||||
SysConf::Entry* tid_entry = sysconf.GetOrAddEntry("IPL.TID", SysConf::Entry::Type::LongLong);
|
SysConf::Entry* tid_entry = sysconf.GetOrAddEntry("IPL.TID", SysConf::Entry::Type::LongLong);
|
||||||
if (const u64 previous_temporary_title_id = Common::swap64(tid_entry->GetData<u64>(0)))
|
if (const u64 previous_temporary_title_id = Common::swap64(tid_entry->GetData<u64>(0)))
|
||||||
ios.GetES()->DeleteTitleContent(previous_temporary_title_id);
|
ios.GetES()->DeleteTitleContent(previous_temporary_title_id);
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
#include "Common/FileUtil.h"
|
#include "Common/FileUtil.h"
|
||||||
#include "Common/StringUtil.h"
|
#include "Common/StringUtil.h"
|
||||||
#include "Common/SysConf.h"
|
|
||||||
#include "Common/Thread.h"
|
#include "Common/Thread.h"
|
||||||
#include "Core/Boot/Boot.h"
|
#include "Core/Boot/Boot.h"
|
||||||
#include "Core/Config/NetplaySettings.h"
|
#include "Core/Config/NetplaySettings.h"
|
||||||
|
@ -48,6 +47,7 @@
|
||||||
#include "Core/HW/DVD/DVDInterface.h"
|
#include "Core/HW/DVD/DVDInterface.h"
|
||||||
#include "Core/HW/WiiSaveCrypted.h"
|
#include "Core/HW/WiiSaveCrypted.h"
|
||||||
#include "Core/Movie.h"
|
#include "Core/Movie.h"
|
||||||
|
#include "Core/SysConf.h"
|
||||||
#include "Core/TitleDatabase.h"
|
#include "Core/TitleDatabase.h"
|
||||||
#include "Core/WiiUtils.h"
|
#include "Core/WiiUtils.h"
|
||||||
#include "DiscIO/Blob.h"
|
#include "DiscIO/Blob.h"
|
||||||
|
|
|
@ -24,10 +24,10 @@
|
||||||
|
|
||||||
#include "Common/Assert.h"
|
#include "Common/Assert.h"
|
||||||
#include "Common/FileUtil.h"
|
#include "Common/FileUtil.h"
|
||||||
#include "Common/SysConf.h"
|
|
||||||
#include "Core/Config/SYSCONFSettings.h"
|
#include "Core/Config/SYSCONFSettings.h"
|
||||||
#include "Core/ConfigManager.h"
|
#include "Core/ConfigManager.h"
|
||||||
#include "Core/Core.h"
|
#include "Core/Core.h"
|
||||||
|
#include "Core/SysConf.h"
|
||||||
#include "DolphinWX/DolphinSlider.h"
|
#include "DolphinWX/DolphinSlider.h"
|
||||||
#include "DolphinWX/Frame.h"
|
#include "DolphinWX/Frame.h"
|
||||||
#include "DolphinWX/Main.h"
|
#include "DolphinWX/Main.h"
|
||||||
|
|
Loading…
Reference in New Issue