From 2f905c086412628fc7e438fac5b478dabda190a5 Mon Sep 17 00:00:00 2001 From: gibbed Date: Sun, 24 May 2015 02:34:47 -0500 Subject: [PATCH] Added device(), removed absolute_path() on XFile. NtCreateFile now uses the file's device to resolve root directory requests. --- src/xenia/kernel/fs/devices/disc_image_file.cc | 6 ++---- src/xenia/kernel/fs/devices/disc_image_file.h | 3 ++- src/xenia/kernel/fs/devices/host_path_file.cc | 6 ++---- src/xenia/kernel/fs/devices/host_path_file.h | 3 ++- src/xenia/kernel/fs/devices/stfs_container_file.cc | 6 ++---- src/xenia/kernel/fs/devices/stfs_container_file.h | 3 ++- src/xenia/kernel/objects/xfile.h | 3 ++- src/xenia/kernel/xboxkrnl_io.cc | 10 ++++++---- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/xenia/kernel/fs/devices/disc_image_file.cc b/src/xenia/kernel/fs/devices/disc_image_file.cc index d7c7cebb4..b643fb61a 100644 --- a/src/xenia/kernel/fs/devices/disc_image_file.cc +++ b/src/xenia/kernel/fs/devices/disc_image_file.cc @@ -27,12 +27,10 @@ DiscImageFile::~DiscImageFile() { delete entry_; } const std::string& DiscImageFile::path() const { return entry_->path(); } -const std::string& DiscImageFile::absolute_path() const { - return entry_->absolute_path(); -} - const std::string& DiscImageFile::name() const { return entry_->name(); } +Device* DiscImageFile::device() const { return entry_->device(); } + X_STATUS DiscImageFile::QueryInfo(XFileInfo* out_info) { return entry_->QueryInfo(out_info); } diff --git a/src/xenia/kernel/fs/devices/disc_image_file.h b/src/xenia/kernel/fs/devices/disc_image_file.h index cb041d15f..5c08475d5 100644 --- a/src/xenia/kernel/fs/devices/disc_image_file.h +++ b/src/xenia/kernel/fs/devices/disc_image_file.h @@ -25,9 +25,10 @@ class DiscImageFile : public XFile { ~DiscImageFile() override; const std::string& path() const override; - const std::string& absolute_path() const override; const std::string& name() const override; + Device* device() const override; + X_STATUS QueryInfo(XFileInfo* out_info) override; X_STATUS QueryDirectory(XDirectoryInfo* out_info, size_t length, const char* file_name, bool restart) override; diff --git a/src/xenia/kernel/fs/devices/host_path_file.cc b/src/xenia/kernel/fs/devices/host_path_file.cc index 161e7e77b..73d95bfb8 100644 --- a/src/xenia/kernel/fs/devices/host_path_file.cc +++ b/src/xenia/kernel/fs/devices/host_path_file.cc @@ -27,12 +27,10 @@ HostPathFile::~HostPathFile() { const std::string& HostPathFile::path() const { return entry_->path(); } -const std::string& HostPathFile::absolute_path() const { - return entry_->absolute_path(); -} - const std::string& HostPathFile::name() const { return entry_->name(); } +Device* HostPathFile::device() const { return entry_->device(); } + X_STATUS HostPathFile::QueryInfo(XFileInfo* out_info) { return entry_->QueryInfo(out_info); } diff --git a/src/xenia/kernel/fs/devices/host_path_file.h b/src/xenia/kernel/fs/devices/host_path_file.h index 0921059ec..3527441ff 100644 --- a/src/xenia/kernel/fs/devices/host_path_file.h +++ b/src/xenia/kernel/fs/devices/host_path_file.h @@ -27,9 +27,10 @@ class HostPathFile : public XFile { ~HostPathFile() override; const std::string& path() const override; - const std::string& absolute_path() const override; const std::string& name() const override; + Device* device() const override; + X_STATUS QueryInfo(XFileInfo* out_info) override; X_STATUS QueryDirectory(XDirectoryInfo* out_info, size_t length, const char* file_name, bool restart) override; diff --git a/src/xenia/kernel/fs/devices/stfs_container_file.cc b/src/xenia/kernel/fs/devices/stfs_container_file.cc index 77ef51b3d..993b33551 100644 --- a/src/xenia/kernel/fs/devices/stfs_container_file.cc +++ b/src/xenia/kernel/fs/devices/stfs_container_file.cc @@ -27,12 +27,10 @@ STFSContainerFile::~STFSContainerFile() { delete entry_; } const std::string& STFSContainerFile::path() const { return entry_->path(); } -const std::string& STFSContainerFile::absolute_path() const { - return entry_->absolute_path(); -} - const std::string& STFSContainerFile::name() const { return entry_->name(); } +Device* STFSContainerFile::device() const { return entry_->device(); } + X_STATUS STFSContainerFile::QueryInfo(XFileInfo* out_info) { return entry_->QueryInfo(out_info); } diff --git a/src/xenia/kernel/fs/devices/stfs_container_file.h b/src/xenia/kernel/fs/devices/stfs_container_file.h index 7c91092cd..76d0950e5 100644 --- a/src/xenia/kernel/fs/devices/stfs_container_file.h +++ b/src/xenia/kernel/fs/devices/stfs_container_file.h @@ -25,9 +25,10 @@ class STFSContainerFile : public XFile { ~STFSContainerFile() override; const std::string& path() const override; - const std::string& absolute_path() const override; const std::string& name() const override; + Device* device() const override; + X_STATUS QueryInfo(XFileInfo* out_info) override; X_STATUS QueryDirectory(XDirectoryInfo* out_info, size_t length, const char* file_name, bool restart) override; diff --git a/src/xenia/kernel/objects/xfile.h b/src/xenia/kernel/objects/xfile.h index 02a2aee74..6597082bc 100644 --- a/src/xenia/kernel/objects/xfile.h +++ b/src/xenia/kernel/objects/xfile.h @@ -146,9 +146,10 @@ class XFile : public XObject { virtual ~XFile(); virtual const std::string& path() const = 0; - virtual const std::string& absolute_path() const = 0; virtual const std::string& name() const = 0; + virtual fs::Device* device() const = 0; + size_t position() const { return position_; } void set_position(size_t value) { position_ = value; } diff --git a/src/xenia/kernel/xboxkrnl_io.cc b/src/xenia/kernel/xboxkrnl_io.cc index 148bb3916..cab02898a 100644 --- a/src/xenia/kernel/xboxkrnl_io.cc +++ b/src/xenia/kernel/xboxkrnl_io.cc @@ -11,6 +11,7 @@ #include "xenia/base/memory.h" #include "xenia/kernel/async_request.h" #include "xenia/kernel/kernel_state.h" +#include "xenia/kernel/fs/device.h" #include "xenia/kernel/objects/xevent.h" #include "xenia/kernel/objects/xfile.h" #include "xenia/kernel/util/shim_utils.h" @@ -95,9 +96,10 @@ X_STATUS NtCreateFile(PPCContext* ppc_state, KernelState* state, assert_true(XSUCCEEDED(result)); assert_true(root_file->type() == XObject::Type::kTypeFile); - auto root_path = root_file->absolute_path(); - auto target_path = xe::join_paths(root_path, object_name); - entry = fs->ResolvePath(target_path); + // Resolve the file using the device the root directory is part of. + auto device = root_file->device(); + auto target_path = xe::join_paths(root_file->path(), object_name); + entry = device->ResolvePath(target_path.c_str()); } else { // Resolve the file using the virtual file system. entry = fs->ResolvePath(object_name); @@ -482,7 +484,7 @@ SHIM_CALL NtQueryInformationFile_shim(PPCContext* ppc_state, info = 8; // TODO(benvanik): use pointer to fs:: entry? SHIM_SET_MEM_64(file_info_ptr, - xe::hash_combine(0, file->absolute_path())); + xe::hash_combine(0, file->path())); break; case XFilePositionInformation: // struct FILE_POSITION_INFORMATION {