Fixing lock type in VFS.
This commit is contained in:
parent
6cf29b969d
commit
91ae97e558
|
@ -19,7 +19,7 @@ Device::Device(const std::string& mount_path) : mount_path_(mount_path) {}
|
||||||
Device::~Device() = default;
|
Device::~Device() = default;
|
||||||
|
|
||||||
void Device::Dump(StringBuffer* string_buffer) {
|
void Device::Dump(StringBuffer* string_buffer) {
|
||||||
std::lock_guard<xe::mutex> lock(mutex_);
|
std::lock_guard<xe::recursive_mutex> lock(mutex_);
|
||||||
root_entry_->Dump(string_buffer, 0);
|
root_entry_->Dump(string_buffer, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ class Device {
|
||||||
virtual bool Initialize() = 0;
|
virtual bool Initialize() = 0;
|
||||||
void Dump(StringBuffer* string_buffer);
|
void Dump(StringBuffer* string_buffer);
|
||||||
|
|
||||||
xe::mutex& mutex() { return mutex_; }
|
xe::recursive_mutex& mutex() { return mutex_; }
|
||||||
const std::string& mount_path() const { return mount_path_; }
|
const std::string& mount_path() const { return mount_path_; }
|
||||||
|
|
||||||
virtual bool is_read_only() const { return true; }
|
virtual bool is_read_only() const { return true; }
|
||||||
|
@ -41,7 +41,7 @@ class Device {
|
||||||
virtual uint32_t bytes_per_sector() const = 0;
|
virtual uint32_t bytes_per_sector() const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
xe::mutex mutex_;
|
xe::recursive_mutex mutex_;
|
||||||
std::string mount_path_;
|
std::string mount_path_;
|
||||||
std::unique_ptr<Entry> root_entry_;
|
std::unique_ptr<Entry> root_entry_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,8 +15,6 @@
|
||||||
#include "xenia/base/filesystem.h"
|
#include "xenia/base/filesystem.h"
|
||||||
#include "xenia/kernel/objects/xfile.h"
|
#include "xenia/kernel/objects/xfile.h"
|
||||||
|
|
||||||
typedef void* HANDLE;
|
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace vfs {
|
namespace vfs {
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ void Entry::Dump(xe::StringBuffer* string_buffer, int indent) {
|
||||||
bool Entry::is_read_only() const { return device_->is_read_only(); }
|
bool Entry::is_read_only() const { return device_->is_read_only(); }
|
||||||
|
|
||||||
Entry* Entry::GetChild(std::string name) {
|
Entry* Entry::GetChild(std::string name) {
|
||||||
std::lock_guard<xe::mutex> lock(device_->mutex());
|
std::lock_guard<xe::recursive_mutex> lock(device_->mutex());
|
||||||
// TODO(benvanik): a faster search
|
// TODO(benvanik): a faster search
|
||||||
for (auto& child : children_) {
|
for (auto& child : children_) {
|
||||||
if (strcasecmp(child->name().c_str(), name.c_str()) == 0) {
|
if (strcasecmp(child->name().c_str(), name.c_str()) == 0) {
|
||||||
|
@ -59,7 +59,7 @@ Entry* Entry::GetChild(std::string name) {
|
||||||
|
|
||||||
Entry* Entry::IterateChildren(const xe::filesystem::WildcardEngine& engine,
|
Entry* Entry::IterateChildren(const xe::filesystem::WildcardEngine& engine,
|
||||||
size_t* current_index) {
|
size_t* current_index) {
|
||||||
std::lock_guard<xe::mutex> lock(device_->mutex());
|
std::lock_guard<xe::recursive_mutex> lock(device_->mutex());
|
||||||
while (*current_index < children_.size()) {
|
while (*current_index < children_.size()) {
|
||||||
auto& child = children_[*current_index];
|
auto& child = children_[*current_index];
|
||||||
*current_index = *current_index + 1;
|
*current_index = *current_index + 1;
|
||||||
|
@ -74,7 +74,7 @@ Entry* Entry::CreateEntry(std::string name, uint32_t attributes) {
|
||||||
if (is_read_only()) {
|
if (is_read_only()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
std::lock_guard<xe::mutex> lock(device_->mutex());
|
std::lock_guard<xe::recursive_mutex> lock(device_->mutex());
|
||||||
if (GetChild(name)) {
|
if (GetChild(name)) {
|
||||||
// Already exists.
|
// Already exists.
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -93,7 +93,7 @@ bool Entry::Delete(Entry* entry) {
|
||||||
if (is_read_only()) {
|
if (is_read_only()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::lock_guard<xe::mutex> lock(device_->mutex());
|
std::lock_guard<xe::recursive_mutex> lock(device_->mutex());
|
||||||
if (entry->parent() != this) {
|
if (entry->parent() != this) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue