[Kernel] Fix data race on XFile position

This commit is contained in:
Herman S.
2026-03-09 16:14:22 +09:00
parent 74ab7339a3
commit 50ef5c2691
2 changed files with 13 additions and 3 deletions

View File

@@ -35,6 +35,16 @@ XFile::~XFile() {
file_->Destroy();
}
uint64_t XFile::position() const {
std::lock_guard<std::mutex> lock(file_lock_);
return position_;
}
void XFile::set_position(uint64_t value) {
std::lock_guard<std::mutex> lock(file_lock_);
position_ = value;
}
X_STATUS XFile::QueryDirectory(X_FILE_DIRECTORY_INFORMATION* out_info,
size_t length, const std::string_view file_name,
bool restart) {

View File

@@ -143,8 +143,8 @@ class XFile : public XObject {
const std::string& path() const { return file_->entry()->path(); }
const std::string& name() const { return file_->entry()->name(); }
uint64_t position() const { return position_; }
void set_position(uint64_t value) { position_ = value; }
uint64_t position() const;
void set_position(uint64_t value);
X_STATUS QueryDirectory(X_FILE_DIRECTORY_INFORMATION* out_info, size_t length,
const std::string_view file_name, bool restart);
@@ -193,7 +193,7 @@ class XFile : public XObject {
vfs::File* file_ = nullptr;
std::unique_ptr<threading::Event> async_event_ = nullptr;
std::mutex file_lock_;
mutable std::mutex file_lock_;
std::mutex completion_port_lock_;
std::vector<std::pair<uint32_t, object_ref<XIOCompletion>>> completion_ports_;