kernel: Add reference counting for mounts
All checks were successful
continuous-integration/drone/push Build is passing

This will make sure we cannot unmount a file system while there is another one mounted inside it.
This commit is contained in:
apio 2023-05-18 16:22:31 +02:00
parent 3a73d49aa1
commit d7c563aebd
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 8 additions and 1 deletions

View File

@ -13,7 +13,14 @@ Result<SharedPtr<VFS::Inode>> MountInode::create(SharedPtr<VFS::Inode> source, S
auto parent = TRY(source->find("..")); auto parent = TRY(source->find(".."));
TRY(fs->set_mount_dir(parent)); TRY(fs->set_mount_dir(parent));
source->add_handle();
g_mounts.append(inode.ptr()); g_mounts.append(inode.ptr());
return (SharedPtr<VFS::Inode>)inode; return (SharedPtr<VFS::Inode>)inode;
} }
MountInode::~MountInode()
{
m_source->remove_handle();
}

View File

@ -137,7 +137,7 @@ class MountInode : public VFS::Inode, public LinkedListNode<MountInode>
return m_mount_root_inode->replace_entry(inode, name); return m_mount_root_inode->replace_entry(inode, name);
} }
virtual ~MountInode() = default; virtual ~MountInode();
private: private:
SharedPtr<VFS::Inode> m_source; SharedPtr<VFS::Inode> m_source;