diff --git a/Kernel/DevPtsFS.cpp b/Kernel/DevPtsFS.cpp index 72738a8ed2..ee7cb2bddd 100644 --- a/Kernel/DevPtsFS.cpp +++ b/Kernel/DevPtsFS.cpp @@ -59,13 +59,11 @@ RetainPtr DevPtsFS::create_slave_pty_device_file(unsigned index) void DevPtsFS::register_slave_pty(SlavePTY& slave_pty) { - InterruptDisabler disabler; auto inode_id = add_file(create_slave_pty_device_file(slave_pty.index())); slave_pty.set_devpts_inode_id(inode_id); } void DevPtsFS::unregister_slave_pty(SlavePTY& slave_pty) { - InterruptDisabler disabler; remove_file(slave_pty.devpts_inode_id().index()); } diff --git a/Kernel/SyntheticFileSystem.cpp b/Kernel/SyntheticFileSystem.cpp index fd396731b5..221168ee52 100644 --- a/Kernel/SyntheticFileSystem.cpp +++ b/Kernel/SyntheticFileSystem.cpp @@ -87,7 +87,7 @@ RetainPtr SynthFS::create_generated_file(String&& name, Function&& file, InodeIndex parent) { - ASSERT_INTERRUPTS_DISABLED(); + LOCKER(m_lock); ASSERT(file); auto it = m_inodes.find(parent); ASSERT(it != m_inodes.end()); @@ -101,7 +101,7 @@ InodeIdentifier SynthFS::add_file(RetainPtr&& file, InodeIndex par bool SynthFS::remove_file(InodeIndex inode) { - ASSERT_INTERRUPTS_DISABLED(); + LOCKER(m_lock); auto it = m_inodes.find(inode); if (it == m_inodes.end()) return false; @@ -158,16 +158,19 @@ RetainPtr SynthFS::create_directory(InodeIdentifier, const String&, mode_ auto SynthFS::generate_inode_index() -> InodeIndex { + LOCKER(m_lock); return m_next_inode_index++; } RetainPtr SynthFSInode::parent() const { + LOCKER(m_lock); return fs().get_inode(m_parent); } RetainPtr SynthFS::get_inode(InodeIdentifier inode) const { + LOCKER(m_lock); auto it = m_inodes.find(inode.index()); if (it == m_inodes.end()) return { }; @@ -191,6 +194,7 @@ InodeMetadata SynthFSInode::metadata() const ssize_t SynthFSInode::read_bytes(off_t offset, size_t count, byte* buffer, FileDescriptor* descriptor) const { + LOCKER(m_lock); #ifdef SYNTHFS_DEBUG kprintf("SynthFS: read_bytes %u\n", index()); #endif @@ -218,6 +222,7 @@ ssize_t SynthFSInode::read_bytes(off_t offset, size_t count, byte* buffer, FileD bool SynthFSInode::traverse_as_directory(Function callback) const { + LOCKER(m_lock); #ifdef SYNTHFS_DEBUG kprintf("SynthFS: traverse_as_directory %u\n", index()); #endif @@ -235,6 +240,7 @@ bool SynthFSInode::traverse_as_directory(Functionidentifier() == child_id) @@ -263,6 +270,7 @@ void SynthFSInode::flush_metadata() ssize_t SynthFSInode::write_bytes(off_t offset, size_t size, const byte* buffer, FileDescriptor*) { + LOCKER(m_lock); if (!m_write_callback) return -EPERM; // FIXME: Being able to write into SynthFS at a non-zero offset seems like something we should support.. @@ -296,6 +304,7 @@ SynthFSInodeCustomData::~SynthFSInodeCustomData() size_t SynthFSInode::directory_entry_count() const { + LOCKER(m_lock); ASSERT(is_directory()); // NOTE: The 2 is for '.' and '..' return m_children.size() + 2; diff --git a/Kernel/SyntheticFileSystem.h b/Kernel/SyntheticFileSystem.h index a001c5b913..f1cc853785 100644 --- a/Kernel/SyntheticFileSystem.h +++ b/Kernel/SyntheticFileSystem.h @@ -37,6 +37,7 @@ protected: private: InodeIndex m_next_inode_index { 2 }; HashMap> m_inodes; + mutable Lock m_lock; }; struct SynthFSInodeCustomData {