summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Kernel/FileSystem/FileDescription.cpp9
-rw-r--r--Kernel/FileSystem/FileDescription.h2
2 files changed, 11 insertions, 0 deletions
diff --git a/Kernel/FileSystem/FileDescription.cpp b/Kernel/FileSystem/FileDescription.cpp
index ad7be299f7..27443230ab 100644
--- a/Kernel/FileSystem/FileDescription.cpp
+++ b/Kernel/FileSystem/FileDescription.cpp
@@ -67,6 +67,7 @@ KResult FileDescription::fstat(stat& buffer)
off_t FileDescription::seek(off_t offset, int whence)
{
+ LOCKER(m_lock);
if (!m_file->is_seekable())
return -EINVAL;
@@ -103,6 +104,7 @@ off_t FileDescription::seek(off_t offset, int whence)
ssize_t FileDescription::read(u8* buffer, ssize_t count)
{
+ LOCKER(m_lock);
SmapDisabler disabler;
int nread = m_file->read(*this, buffer, count);
if (nread > 0 && m_file->is_seekable())
@@ -112,6 +114,7 @@ ssize_t FileDescription::read(u8* buffer, ssize_t count)
ssize_t FileDescription::write(const u8* data, ssize_t size)
{
+ LOCKER(m_lock);
SmapDisabler disabler;
int nwritten = m_file->write(*this, data, size);
if (nwritten > 0 && m_file->is_seekable())
@@ -140,6 +143,7 @@ ByteBuffer FileDescription::read_entire_file()
ssize_t FileDescription::get_dir_entries(u8* buffer, ssize_t size)
{
+ LOCKER(m_lock);
if (!is_directory())
return -ENOTDIR;
@@ -245,11 +249,13 @@ InodeMetadata FileDescription::metadata() const
KResultOr<Region*> FileDescription::mmap(Process& process, VirtualAddress vaddr, size_t offset, size_t size, int prot)
{
+ LOCKER(m_lock);
return m_file->mmap(process, *this, vaddr, offset, size, prot);
}
KResult FileDescription::truncate(off_t length)
{
+ LOCKER(m_lock);
return m_file->truncate(length);
}
@@ -286,6 +292,7 @@ const Socket* FileDescription::socket() const
void FileDescription::set_file_flags(u32 flags)
{
+ LOCKER(m_lock);
m_is_blocking = !(flags & O_NONBLOCK);
m_should_append = flags & O_APPEND;
m_direct = flags & O_DIRECT;
@@ -294,10 +301,12 @@ void FileDescription::set_file_flags(u32 flags)
KResult FileDescription::chmod(mode_t mode)
{
+ LOCKER(m_lock);
return m_file->chmod(mode);
}
KResult FileDescription::chown(uid_t uid, gid_t gid)
{
+ LOCKER(m_lock);
return m_file->chown(uid, gid);
}
diff --git a/Kernel/FileSystem/FileDescription.h b/Kernel/FileSystem/FileDescription.h
index d56d8f3619..0375432a55 100644
--- a/Kernel/FileSystem/FileDescription.h
+++ b/Kernel/FileSystem/FileDescription.h
@@ -140,4 +140,6 @@ private:
bool m_should_append { false };
bool m_direct { false };
FIFO::Direction m_fifo_direction { FIFO::Direction::Neither };
+
+ Lock m_lock { "FileDescription" };
};