Replacing vfs memory mapping with base memory mapping.

Progress on #294.
This commit is contained in:
Ben Vanik
2015-06-27 18:02:20 -07:00
parent 23f91b58f3
commit 1ac19f1b08
10 changed files with 57 additions and 90 deletions

View File

@@ -17,15 +17,6 @@
namespace xe {
namespace vfs {
class HostPathMemoryMapping : public MemoryMapping {
public:
HostPathMemoryMapping(std::unique_ptr<MappedMemory> mmap)
: MemoryMapping(mmap->data(), mmap->size()), mmap_(std::move(mmap)) {}
private:
std::unique_ptr<MappedMemory> mmap_;
};
HostPathEntry::HostPathEntry(Device* device, const char* path,
const std::wstring& local_path)
: Entry(device, path),
@@ -125,19 +116,6 @@ X_STATUS HostPathEntry::QueryDirectory(X_FILE_DIRECTORY_INFORMATION* out_info,
return X_STATUS_SUCCESS;
}
std::unique_ptr<MemoryMapping> HostPathEntry::CreateMemoryMapping(
Mode map_mode, const size_t offset, const size_t length) {
auto mmap = MappedMemory::Open(
local_path_, map_mode == Mode::READ ? MappedMemory::Mode::kRead
: MappedMemory::Mode::kReadWrite,
offset, length);
if (!mmap) {
return nullptr;
}
return std::make_unique<HostPathMemoryMapping>(std::move(mmap));
}
X_STATUS HostPathEntry::Open(KernelState* kernel_state, Mode mode, bool async,
XFile** out_file) {
// TODO(benvanik): plumb through proper disposition/access mode.
@@ -176,5 +154,11 @@ X_STATUS HostPathEntry::Open(KernelState* kernel_state, Mode mode, bool async,
return X_STATUS_SUCCESS;
}
std::unique_ptr<MappedMemory> HostPathEntry::OpenMapped(MappedMemory::Mode mode,
size_t offset,
size_t length) {
return MappedMemory::Open(local_path_, mode, offset, length);
}
} // namespace vfs
} // namespace xe