Moving code out of vfs/ that doesn't need to be there.
Progress on #294.
This commit is contained in:
@@ -9,8 +9,6 @@
|
||||
|
||||
#include "xenia/vfs/device.h"
|
||||
|
||||
#include "xenia/kernel/objects/xfile.h"
|
||||
|
||||
namespace xe {
|
||||
namespace vfs {
|
||||
|
||||
@@ -18,55 +16,5 @@ Device::Device(const std::string& mount_path) : mount_path_(mount_path) {}
|
||||
|
||||
Device::~Device() = default;
|
||||
|
||||
// TODO(gibbed): make virtual + move implementation into HostPathDevice/etc.
|
||||
X_STATUS Device::QueryVolumeInfo(X_FILE_FS_VOLUME_INFORMATION* out_info,
|
||||
size_t length) {
|
||||
assert_not_null(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): make virtual + move implementation into HostPathDevice/etc.
|
||||
X_STATUS Device::QuerySizeInfo(X_FILE_FS_SIZE_INFORMATION* out_info,
|
||||
size_t length) {
|
||||
assert_not_null(out_info);
|
||||
out_info->total_allocation_units = 1234; // TODO(gibbed): actual value
|
||||
out_info->available_allocation_units = 0; // TODO(gibbed): actual value
|
||||
out_info->sectors_per_allocation_unit = 1; // TODO(gibbed): actual value
|
||||
out_info->bytes_per_sector = 1024; // TODO(gibbed): actual value
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// TODO(gibbed): make virtual + move implementation into HostPathDevice/etc.
|
||||
X_STATUS Device::QueryAttributeInfo(X_FILE_FS_ATTRIBUTE_INFORMATION* out_info,
|
||||
size_t length) {
|
||||
assert_not_null(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;
|
||||
}
|
||||
|
||||
} // namespace vfs
|
||||
} // namespace xe
|
||||
|
||||
@@ -29,12 +29,10 @@ class Device {
|
||||
|
||||
virtual std::unique_ptr<Entry> ResolvePath(const char* path) = 0;
|
||||
|
||||
virtual X_STATUS QueryVolumeInfo(X_FILE_FS_VOLUME_INFORMATION* out_info,
|
||||
size_t length);
|
||||
virtual X_STATUS QuerySizeInfo(X_FILE_FS_SIZE_INFORMATION* out_info,
|
||||
size_t length);
|
||||
virtual X_STATUS QueryAttributeInfo(X_FILE_FS_ATTRIBUTE_INFORMATION* out_info,
|
||||
size_t length);
|
||||
virtual uint32_t total_allocation_units() const = 0;
|
||||
virtual uint32_t available_allocation_units() const = 0;
|
||||
virtual uint32_t sectors_per_allocation_unit() const = 0;
|
||||
virtual uint32_t bytes_per_sector() const = 0;
|
||||
|
||||
protected:
|
||||
std::string mount_path_;
|
||||
|
||||
@@ -31,6 +31,14 @@ class DiscImageDevice : public Device {
|
||||
|
||||
std::unique_ptr<Entry> ResolvePath(const char* path) override;
|
||||
|
||||
uint32_t total_allocation_units() const override {
|
||||
return uint32_t(mmap_->size() / sectors_per_allocation_unit() /
|
||||
bytes_per_sector());
|
||||
}
|
||||
uint32_t available_allocation_units() const override { return 0; }
|
||||
uint32_t sectors_per_allocation_unit() const override { return 1; }
|
||||
uint32_t bytes_per_sector() const override { return 2 * 1024; }
|
||||
|
||||
private:
|
||||
std::wstring local_path_;
|
||||
std::unique_ptr<MappedMemory> mmap_;
|
||||
|
||||
@@ -27,6 +27,11 @@ class HostPathDevice : public Device {
|
||||
|
||||
std::unique_ptr<Entry> ResolvePath(const char* path) override;
|
||||
|
||||
uint32_t total_allocation_units() const override { return 128 * 1024; }
|
||||
uint32_t available_allocation_units() const override { return 128 * 1024; }
|
||||
uint32_t sectors_per_allocation_unit() const override { return 1; }
|
||||
uint32_t bytes_per_sector() const override { return 2 * 1024; }
|
||||
|
||||
private:
|
||||
std::wstring local_path_;
|
||||
bool read_only_;
|
||||
|
||||
@@ -31,6 +31,14 @@ class STFSContainerDevice : public Device {
|
||||
|
||||
std::unique_ptr<Entry> ResolvePath(const char* path) override;
|
||||
|
||||
uint32_t total_allocation_units() const override {
|
||||
return uint32_t(mmap_->size() / sectors_per_allocation_unit() /
|
||||
bytes_per_sector());
|
||||
}
|
||||
uint32_t available_allocation_units() const override { return 0; }
|
||||
uint32_t sectors_per_allocation_unit() const override { return 1; }
|
||||
uint32_t bytes_per_sector() const override { return 4 * 1024; }
|
||||
|
||||
private:
|
||||
std::wstring local_path_;
|
||||
std::unique_ptr<MappedMemory> mmap_;
|
||||
|
||||
@@ -21,9 +21,6 @@ class KernelState;
|
||||
class XFile;
|
||||
struct X_FILE_NETWORK_OPEN_INFORMATION;
|
||||
class X_FILE_DIRECTORY_INFORMATION;
|
||||
class X_FILE_FS_ATTRIBUTE_INFORMATION;
|
||||
class X_FILE_FS_SIZE_INFORMATION;
|
||||
class X_FILE_FS_VOLUME_INFORMATION;
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
Reference in New Issue
Block a user