Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOS/ES: Migrate to new filesystem interface #6772

Merged
merged 7 commits into from May 8, 2018

Conversation

leoetlino
Copy link
Member

@leoetlino leoetlino commented May 6, 2018

Followup for the migration work started in 8317a66

The goal is to make all accesses to the Wii filesystem go through the common interface so that we can switch to a different storage and keep track of things like metadata in the future.

This PR is a bit larger than past changesets because of how much ES uses the filesystem compared to other subsystems. ES is also responsible for setting permissions on most files and directories, which is something Dolphin didn't bother with before this PR (we currently have a workaround to make the DQX installer work without proper UID/GID values).

Commits are independent and can be reviewed individually.

Copy link
Member

@BhaaLseN BhaaLseN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It kinda bothers me that the majority of FS-calls hardcodes 0/0 for uid/gid, and also that FS itself doesn't utilitze those parameters at this point.

The latter isn't something that can be done until we actually make use of those metadata; but the former might be something to take care of now (at least in places where we already have them available) - unless you got some other plan for those.

{
if (code == ResultCode::Success)
return IPC_SUCCESS;
return static_cast<ReturnCode>(-(static_cast<s32>(code) + 100));

This comment was marked as off-topic.

This comment was marked as off-topic.

ERROR_LOG(IOS_ES, "Failed to create %s (at %s)", directory.path, path.c_str());

// TODO: Set permissions.
const auto result = m_ios.GetFS()->CreateDirectory(0, 0, directory.path, directory.attribute,

This comment was marked as off-topic.

This comment was marked as off-topic.

{"/shared2", 0, FS::Mode::ReadWrite, FS::Mode::ReadWrite, FS::Mode::ReadWrite, 0, 0},
{"/tmp", 0, FS::Mode::ReadWrite, FS::Mode::ReadWrite, FS::Mode::ReadWrite, 0, 0},
{"/import", 0, FS::Mode::ReadWrite, FS::Mode::ReadWrite, FS::Mode::None, 0, 0},
{"/meta", 0, FS::Mode::ReadWrite, FS::Mode::ReadWrite, FS::Mode::ReadWrite, 0x1000, 1},

This comment was marked as off-topic.

This comment was marked as off-topic.

@@ -341,12 +341,8 @@ void ES::DoState(PointerWrap& p)
p.Do(entry.m_opened);
p.Do(entry.m_title_id);
p.Do(entry.m_content);
p.Do(entry.m_position);
p.Do(entry.m_fd);

This comment was marked as off-topic.

This comment was marked as off-topic.

fs->SetMetadata(0, content_dir, 0, 0, 0, FS::Mode::ReadWrite, FS::Mode::ReadWrite,
FS::Mode::None) != FS::ResultCode::Success ||
fs->CreateFullPath(0, 0, import_content_dir + '/', 0, FS::Mode::ReadWrite,
FS::Mode::ReadWrite, FS::Mode::None) != FS::ResultCode::Success)

This comment was marked as off-topic.

This comment was marked as off-topic.


// Remove everything not listed in the TMD.
std::unordered_set<std::string> expected_entries = {"title.tmd"};
for (const auto& content_info : tmd.GetContents())
expected_entries.insert(StringFromFormat("%08x.app", content_info.id));
const auto entries = File::ScanDirectoryTree(import_content_dir, false);
for (const File::FSTEntry& entry : entries.children)
const auto entries = m_ios.GetFS()->ReadDirectory(0, 0, import_content_dir);

This comment was marked as off-topic.

This comment was marked as off-topic.

{
File::IOFile ticket_file(ticket_path, "wb");
if (!ticket_file || !ticket_file.WriteBytes(new_ticket.data(), new_ticket.size()))
const auto file = m_ios.GetFS()->OpenFile(0, 0, ticket_path, FS::Mode::ReadWrite);

This comment was marked as off-topic.

This comment was marked as off-topic.

ES makes extensive use of FS and most of the time returns its error
codes directly.
Copy link
Member Author

@leoetlino leoetlino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, I forgot that we have a constant for PID_KERNEL. I have replaced all the magic 0s with it.

And yes, currently the attributes cannot be saved, both because of backend limitations and because not everything passes metadata to the FS code yet.

(submitting this before pushing because GitHub will lose my comments otherwise)

{"/shared2", 0, FS::Mode::ReadWrite, FS::Mode::ReadWrite, FS::Mode::ReadWrite, 0, 0},
{"/tmp", 0, FS::Mode::ReadWrite, FS::Mode::ReadWrite, FS::Mode::ReadWrite, 0, 0},
{"/import", 0, FS::Mode::ReadWrite, FS::Mode::ReadWrite, FS::Mode::None, 0, 0},
{"/meta", 0, FS::Mode::ReadWrite, FS::Mode::ReadWrite, FS::Mode::ReadWrite, 0x1000, 1},

This comment was marked as off-topic.

ERROR_LOG(IOS_ES, "Failed to create %s (at %s)", directory.path, path.c_str());

// TODO: Set permissions.
const auto result = m_ios.GetFS()->CreateDirectory(0, 0, directory.path, directory.attribute,

This comment was marked as off-topic.

@@ -341,12 +341,8 @@ void ES::DoState(PointerWrap& p)
p.Do(entry.m_opened);
p.Do(entry.m_title_id);
p.Do(entry.m_content);
p.Do(entry.m_position);
p.Do(entry.m_fd);

This comment was marked as off-topic.

fs->SetMetadata(0, content_dir, 0, 0, 0, FS::Mode::ReadWrite, FS::Mode::ReadWrite,
FS::Mode::None) != FS::ResultCode::Success ||
fs->CreateFullPath(0, 0, import_content_dir + '/', 0, FS::Mode::ReadWrite,
FS::Mode::ReadWrite, FS::Mode::None) != FS::ResultCode::Success)

This comment was marked as off-topic.


// Remove everything not listed in the TMD.
std::unordered_set<std::string> expected_entries = {"title.tmd"};
for (const auto& content_info : tmd.GetContents())
expected_entries.insert(StringFromFormat("%08x.app", content_info.id));
const auto entries = File::ScanDirectoryTree(import_content_dir, false);
for (const File::FSTEntry& entry : entries.children)
const auto entries = m_ios.GetFS()->ReadDirectory(0, 0, import_content_dir);

This comment was marked as off-topic.

{
if (code == ResultCode::Success)
return IPC_SUCCESS;
return static_cast<ReturnCode>(-(static_cast<s32>(code) + 100));

This comment was marked as off-topic.

{
File::IOFile ticket_file(ticket_path, "wb");
if (!ticket_file || !ticket_file.WriteBytes(new_ticket.data(), new_ticket.size()))
const auto file = m_ios.GetFS()->OpenFile(0, 0, ticket_path, FS::Mode::ReadWrite);

This comment was marked as off-topic.

@leoetlino leoetlino merged commit 90f869e into dolphin-emu:master May 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants