From 44847e904224f58b4f4ad40dac90af9900146cfc Mon Sep 17 00:00:00 2001 From: gibbed Date: Thu, 23 Jan 2014 11:23:26 -0800 Subject: [PATCH] Moved QueryVolume and QueryFileSystemAttributes to Device from Entry. --- src/xenia/kernel/fs/device.h | 3 ++ .../kernel/fs/devices/disc_image_device.cc | 10 +++++ .../kernel/fs/devices/disc_image_device.h | 3 ++ .../kernel/fs/devices/disc_image_entry.cc | 10 ----- .../kernel/fs/devices/disc_image_entry.h | 2 - .../kernel/fs/devices/disc_image_file.cc | 5 ++- .../kernel/fs/devices/host_path_device.cc | 38 +++++++++++++++++++ .../kernel/fs/devices/host_path_device.h | 3 ++ .../kernel/fs/devices/host_path_entry.cc | 37 ------------------ src/xenia/kernel/fs/devices/host_path_entry.h | 2 - src/xenia/kernel/fs/devices/host_path_file.cc | 5 ++- .../fs/devices/stfs_container_device.cc | 11 ++++++ .../kernel/fs/devices/stfs_container_device.h | 3 ++ .../kernel/fs/devices/stfs_container_entry.cc | 10 ----- .../kernel/fs/devices/stfs_container_entry.h | 2 - .../kernel/fs/devices/stfs_container_file.cc | 11 +++--- src/xenia/kernel/fs/entry.h | 2 - 17 files changed, 83 insertions(+), 74 deletions(-) diff --git a/src/xenia/kernel/fs/device.h b/src/xenia/kernel/fs/device.h index 8ad650202..1c76b63f7 100644 --- a/src/xenia/kernel/fs/device.h +++ b/src/xenia/kernel/fs/device.h @@ -30,6 +30,9 @@ public: virtual Entry* ResolvePath(const char* path) = 0; + virtual X_STATUS QueryVolume(XVolumeInfo* out_info, size_t length) = 0; + virtual X_STATUS QueryFileSystemAttributes(XFileSystemAttributeInfo* out_info, size_t length) = 0; + protected: char* path_; }; diff --git a/src/xenia/kernel/fs/devices/disc_image_device.cc b/src/xenia/kernel/fs/devices/disc_image_device.cc index ca19c5663..f46e3e1d7 100644 --- a/src/xenia/kernel/fs/devices/disc_image_device.cc +++ b/src/xenia/kernel/fs/devices/disc_image_device.cc @@ -96,3 +96,13 @@ Entry* DiscImageDevice::ResolvePath(const char* path) { return new DiscImageEntry( type, this, path, mmap_, gdfx_entry); } + +X_STATUS DiscImageDevice::QueryVolume(XVolumeInfo* out_info, size_t length) { + XEASSERTALWAYS(); + return X_STATUS_NOT_IMPLEMENTED; +} + +X_STATUS DiscImageDevice::QueryFileSystemAttributes(XFileSystemAttributeInfo* out_info, size_t length) { + XEASSERTALWAYS(); + return X_STATUS_NOT_IMPLEMENTED; +} diff --git a/src/xenia/kernel/fs/devices/disc_image_device.h b/src/xenia/kernel/fs/devices/disc_image_device.h index 361affda0..05a65aabd 100644 --- a/src/xenia/kernel/fs/devices/disc_image_device.h +++ b/src/xenia/kernel/fs/devices/disc_image_device.h @@ -33,6 +33,9 @@ public: virtual Entry* ResolvePath(const char* path); + virtual X_STATUS QueryVolume(XVolumeInfo* out_info, size_t length); + virtual X_STATUS QueryFileSystemAttributes(XFileSystemAttributeInfo* out_info, size_t length); + private: xechar_t* local_path_; xe_mmap_ref mmap_; diff --git a/src/xenia/kernel/fs/devices/disc_image_entry.cc b/src/xenia/kernel/fs/devices/disc_image_entry.cc index 72573d1b3..2b4b51834 100644 --- a/src/xenia/kernel/fs/devices/disc_image_entry.cc +++ b/src/xenia/kernel/fs/devices/disc_image_entry.cc @@ -110,16 +110,6 @@ X_STATUS DiscImageEntry::QueryDirectory( return X_STATUS_SUCCESS; } -X_STATUS DiscImageEntry::QueryVolume(XVolumeInfo* out_info, size_t length) { - XEASSERTALWAYS(); - return X_STATUS_NOT_IMPLEMENTED; -} - -X_STATUS DiscImageEntry::QueryFileSystemAttributes(XFileSystemAttributeInfo* out_info, size_t length) { - XEASSERTALWAYS(); - return X_STATUS_NOT_IMPLEMENTED; -} - MemoryMapping* DiscImageEntry::CreateMemoryMapping( xe_file_mode file_mode, const size_t offset, const size_t length) { if (file_mode & kXEFileModeWrite) { diff --git a/src/xenia/kernel/fs/devices/disc_image_entry.h b/src/xenia/kernel/fs/devices/disc_image_entry.h index 913ff9df0..4ed31b5ef 100644 --- a/src/xenia/kernel/fs/devices/disc_image_entry.h +++ b/src/xenia/kernel/fs/devices/disc_image_entry.h @@ -35,8 +35,6 @@ public: virtual X_STATUS QueryInfo(XFileInfo* out_info); virtual X_STATUS QueryDirectory(XDirectoryInfo* out_info, size_t length, const char* file_name, bool restart); - virtual X_STATUS QueryVolume(XVolumeInfo* out_info, size_t length); - virtual X_STATUS QueryFileSystemAttributes(XFileSystemAttributeInfo* out_info, size_t length); virtual bool can_map() { return true; } virtual MemoryMapping* CreateMemoryMapping( diff --git a/src/xenia/kernel/fs/devices/disc_image_file.cc b/src/xenia/kernel/fs/devices/disc_image_file.cc index 8022606c8..d98919c62 100644 --- a/src/xenia/kernel/fs/devices/disc_image_file.cc +++ b/src/xenia/kernel/fs/devices/disc_image_file.cc @@ -12,6 +12,7 @@ #include #include +#include using namespace xe; using namespace xe::kernel; @@ -50,11 +51,11 @@ X_STATUS DiscImageFile::QueryDirectory(XDirectoryInfo* out_info, } X_STATUS DiscImageFile::QueryVolume(XVolumeInfo* out_info, size_t length) { - return entry_->QueryVolume(out_info, length); + return entry_->device()->QueryVolume(out_info, length); } X_STATUS DiscImageFile::QueryFileSystemAttributes(XFileSystemAttributeInfo* out_info, size_t length) { - return entry_->QueryFileSystemAttributes(out_info, length); + return entry_->device()->QueryFileSystemAttributes(out_info, length); } X_STATUS DiscImageFile::ReadSync( diff --git a/src/xenia/kernel/fs/devices/host_path_device.cc b/src/xenia/kernel/fs/devices/host_path_device.cc index 70e863206..675563416 100644 --- a/src/xenia/kernel/fs/devices/host_path_device.cc +++ b/src/xenia/kernel/fs/devices/host_path_device.cc @@ -11,6 +11,7 @@ #include +#include using namespace xe; using namespace xe::kernel; @@ -63,3 +64,40 @@ Entry* HostPathDevice::ResolvePath(const char* path) { HostPathEntry* entry = new HostPathEntry(type, this, path, full_path); return entry; } + +// TODO(gibbed): call into HostPathDevice? +X_STATUS HostPathDevice::QueryVolume(XVolumeInfo* out_info, size_t length) { + XEASSERTNOTNULL(out_info); + const char* name = "test"; // TODO(gibbed): actual value + + auto end = (uint8_t*)out_info + length; + size_t name_length = strlen(name); + if (((uint8_t*)&out_info->label[0]) + name_length > end) { + return X_STATUS_BUFFER_OVERFLOW; + } + + out_info->creation_time = 0; + out_info->serial_number = 12345678; + out_info->supports_objects = 0; + out_info->label_length = (uint32_t)name_length; + memcpy(out_info->label, name, name_length); + return X_STATUS_SUCCESS; +} + +// TODO(gibbed): call into HostPathDevice? +X_STATUS HostPathDevice::QueryFileSystemAttributes(XFileSystemAttributeInfo* out_info, size_t length) { + XEASSERTNOTNULL(out_info); + const char* name = "test"; // TODO(gibbed): actual value + + auto end = (uint8_t*)out_info + length; + size_t name_length = strlen(name); + if (((uint8_t*)&out_info->fs_name[0]) + name_length > end) { + return X_STATUS_BUFFER_OVERFLOW; + } + + out_info->attributes = 0; + out_info->maximum_component_name_length = 255; // TODO(gibbed): actual value + out_info->fs_name_length = (uint32_t)name_length; + memcpy(out_info->fs_name, name, name_length); + return X_STATUS_SUCCESS; +} diff --git a/src/xenia/kernel/fs/devices/host_path_device.h b/src/xenia/kernel/fs/devices/host_path_device.h index b45080459..f249911d2 100644 --- a/src/xenia/kernel/fs/devices/host_path_device.h +++ b/src/xenia/kernel/fs/devices/host_path_device.h @@ -28,6 +28,9 @@ public: virtual Entry* ResolvePath(const char* path); + virtual X_STATUS QueryVolume(XVolumeInfo* out_info, size_t length); + virtual X_STATUS QueryFileSystemAttributes(XFileSystemAttributeInfo* out_info, size_t length); + private: xechar_t* local_path_; }; diff --git a/src/xenia/kernel/fs/devices/host_path_entry.cc b/src/xenia/kernel/fs/devices/host_path_entry.cc index b07e81426..037563625 100644 --- a/src/xenia/kernel/fs/devices/host_path_entry.cc +++ b/src/xenia/kernel/fs/devices/host_path_entry.cc @@ -140,43 +140,6 @@ X_STATUS HostPathEntry::QueryDirectory( return X_STATUS_SUCCESS; } -// TODO(gibbed): call into HostPathDevice? -X_STATUS HostPathEntry::QueryVolume(XVolumeInfo* out_info, size_t length) { - XEASSERTNOTNULL(out_info); - const char* name = "test"; // TODO(gibbed): actual value - - auto end = (uint8_t*)out_info + length; - size_t name_length = strlen(name); - if (((uint8_t*)&out_info->label[0]) + name_length > end) { - return X_STATUS_BUFFER_OVERFLOW; - } - - out_info->creation_time = 0; - out_info->serial_number = 12345678; - out_info->supports_objects = 0; - out_info->label_length = (uint32_t)name_length; - memcpy(out_info->label, name, name_length); - return X_STATUS_SUCCESS; -} - -// TODO(gibbed): call into HostPathDevice? -X_STATUS HostPathEntry::QueryFileSystemAttributes(XFileSystemAttributeInfo* out_info, size_t length) { - XEASSERTNOTNULL(out_info); - const char* name = "test"; // TODO(gibbed): actual value - - auto end = (uint8_t*)out_info + length; - size_t name_length = strlen(name); - if (((uint8_t*)&out_info->fs_name[0]) + name_length > end) { - return X_STATUS_BUFFER_OVERFLOW; - } - - out_info->attributes = 0; - out_info->maximum_component_name_length = 255; // TODO(gibbed): actual value - out_info->fs_name_length = (uint32_t)name_length; - memcpy(out_info->fs_name, name, name_length); - return X_STATUS_SUCCESS; -} - MemoryMapping* HostPathEntry::CreateMemoryMapping( xe_file_mode file_mode, const size_t offset, const size_t length) { xe_mmap_ref mmap = xe_mmap_open(file_mode, local_path_, offset, length); diff --git a/src/xenia/kernel/fs/devices/host_path_entry.h b/src/xenia/kernel/fs/devices/host_path_entry.h index 9af676327..3406033b0 100644 --- a/src/xenia/kernel/fs/devices/host_path_entry.h +++ b/src/xenia/kernel/fs/devices/host_path_entry.h @@ -32,8 +32,6 @@ public: virtual X_STATUS QueryInfo(XFileInfo* out_info); virtual X_STATUS QueryDirectory(XDirectoryInfo* out_info, size_t length, const char* file_name, bool restart); - virtual X_STATUS QueryVolume(XVolumeInfo* out_info, size_t length); - virtual X_STATUS QueryFileSystemAttributes(XFileSystemAttributeInfo* out_info, size_t length); virtual bool can_map() { return true; } virtual MemoryMapping* CreateMemoryMapping( diff --git a/src/xenia/kernel/fs/devices/host_path_file.cc b/src/xenia/kernel/fs/devices/host_path_file.cc index 7f304caae..cf75e69e9 100644 --- a/src/xenia/kernel/fs/devices/host_path_file.cc +++ b/src/xenia/kernel/fs/devices/host_path_file.cc @@ -11,6 +11,7 @@ #include +#include using namespace xe; using namespace xe::kernel; @@ -50,11 +51,11 @@ X_STATUS HostPathFile::QueryDirectory(XDirectoryInfo* out_info, } X_STATUS HostPathFile::QueryVolume(XVolumeInfo* out_info, size_t length) { - return entry_->QueryVolume(out_info, length); + return entry_->device()->QueryVolume(out_info, length); } X_STATUS HostPathFile::QueryFileSystemAttributes(XFileSystemAttributeInfo* out_info, size_t length) { - return entry_->QueryFileSystemAttributes(out_info, length); + return entry_->device()->QueryFileSystemAttributes(out_info, length); } X_STATUS HostPathFile::ReadSync( diff --git a/src/xenia/kernel/fs/devices/stfs_container_device.cc b/src/xenia/kernel/fs/devices/stfs_container_device.cc index 081437e36..d557c2a1d 100644 --- a/src/xenia/kernel/fs/devices/stfs_container_device.cc +++ b/src/xenia/kernel/fs/devices/stfs_container_device.cc @@ -97,3 +97,14 @@ Entry* STFSContainerDevice::ResolvePath(const char* path) { return new STFSContainerEntry( type, this, path, mmap_, stfs_entry); } + + +X_STATUS STFSContainerDevice::QueryVolume(XVolumeInfo* out_info, size_t length) { + XEASSERTALWAYS(); + return X_STATUS_NOT_IMPLEMENTED; +} + +X_STATUS STFSContainerDevice::QueryFileSystemAttributes(XFileSystemAttributeInfo* out_info, size_t length) { + XEASSERTALWAYS(); + return X_STATUS_NOT_IMPLEMENTED; +} diff --git a/src/xenia/kernel/fs/devices/stfs_container_device.h b/src/xenia/kernel/fs/devices/stfs_container_device.h index a501abc3c..09e37fb36 100644 --- a/src/xenia/kernel/fs/devices/stfs_container_device.h +++ b/src/xenia/kernel/fs/devices/stfs_container_device.h @@ -33,6 +33,9 @@ public: virtual Entry* ResolvePath(const char* path); + virtual X_STATUS QueryVolume(XVolumeInfo* out_info, size_t length); + virtual X_STATUS QueryFileSystemAttributes(XFileSystemAttributeInfo* out_info, size_t length); + private: xechar_t* local_path_; xe_mmap_ref mmap_; diff --git a/src/xenia/kernel/fs/devices/stfs_container_entry.cc b/src/xenia/kernel/fs/devices/stfs_container_entry.cc index 16da2db05..a91d1234b 100644 --- a/src/xenia/kernel/fs/devices/stfs_container_entry.cc +++ b/src/xenia/kernel/fs/devices/stfs_container_entry.cc @@ -88,16 +88,6 @@ X_STATUS STFSContainerEntry::QueryDirectory( return X_STATUS_SUCCESS; } -X_STATUS STFSContainerEntry::QueryVolume(XVolumeInfo* out_info, size_t length) { - XEASSERTALWAYS(); - return X_STATUS_NOT_IMPLEMENTED; -} - -X_STATUS STFSContainerEntry::QueryFileSystemAttributes(XFileSystemAttributeInfo* out_info, size_t length) { - XEASSERTALWAYS(); - return X_STATUS_NOT_IMPLEMENTED; -} - X_STATUS STFSContainerEntry::Open( KernelState* kernel_state, uint32_t desired_access, bool async, diff --git a/src/xenia/kernel/fs/devices/stfs_container_entry.h b/src/xenia/kernel/fs/devices/stfs_container_entry.h index 40d77e848..2f9129595 100644 --- a/src/xenia/kernel/fs/devices/stfs_container_entry.h +++ b/src/xenia/kernel/fs/devices/stfs_container_entry.h @@ -35,8 +35,6 @@ public: virtual X_STATUS QueryInfo(XFileInfo* out_info); virtual X_STATUS QueryDirectory(XDirectoryInfo* out_info, size_t length, const char* file_name, bool restart); - virtual X_STATUS QueryVolume(XVolumeInfo* out_info, size_t length); - virtual X_STATUS QueryFileSystemAttributes(XFileSystemAttributeInfo* out_info, size_t length); virtual X_STATUS Open( KernelState* kernel_state, diff --git a/src/xenia/kernel/fs/devices/stfs_container_file.cc b/src/xenia/kernel/fs/devices/stfs_container_file.cc index a2e434fdc..05b1a21a8 100644 --- a/src/xenia/kernel/fs/devices/stfs_container_file.cc +++ b/src/xenia/kernel/fs/devices/stfs_container_file.cc @@ -12,6 +12,7 @@ #include #include +#include using namespace xe; using namespace xe::kernel; @@ -44,17 +45,17 @@ X_STATUS STFSContainerFile::QueryInfo(XFileInfo* out_info) { return entry_->QueryInfo(out_info); } -X_STATUS STFSContainerFile::QueryVolume(XVolumeInfo* out_info, size_t length) { - return entry_->QueryVolume(out_info, length); -} - X_STATUS STFSContainerFile::QueryDirectory(XDirectoryInfo* out_info, size_t length, const char* file_name, bool restart) { return entry_->QueryDirectory(out_info, length, file_name, restart); } +X_STATUS STFSContainerFile::QueryVolume(XVolumeInfo* out_info, size_t length) { + return entry_->device()->QueryVolume(out_info, length); +} + X_STATUS STFSContainerFile::QueryFileSystemAttributes(XFileSystemAttributeInfo* out_info, size_t length) { - return entry_->QueryFileSystemAttributes(out_info, length); + return entry_->device()->QueryFileSystemAttributes(out_info, length); } X_STATUS STFSContainerFile::ReadSync( diff --git a/src/xenia/kernel/fs/entry.h b/src/xenia/kernel/fs/entry.h index 7471bbc19..c21b57a16 100644 --- a/src/xenia/kernel/fs/entry.h +++ b/src/xenia/kernel/fs/entry.h @@ -64,8 +64,6 @@ public: virtual X_STATUS QueryInfo(XFileInfo* out_info) = 0; virtual X_STATUS QueryDirectory(XDirectoryInfo* out_info, size_t length, const char* file_name, bool restart) = 0; - virtual X_STATUS QueryVolume(XVolumeInfo* out_info, size_t length) = 0; - virtual X_STATUS QueryFileSystemAttributes(XFileSystemAttributeInfo* out_info, size_t length) = 0; virtual bool can_map() { return false; } virtual MemoryMapping* CreateMemoryMapping(