Compare commits

...

2 Commits

Author SHA1 Message Date
d7c563aebd
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.
2023-05-18 16:22:31 +02:00
3a73d49aa1
kernel: Remove a mount from the mountpoint list after unmounting it 2023-05-18 16:18:09 +02:00
3 changed files with 9 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(".."));
TRY(fs->set_mount_dir(parent));
source->add_handle();
g_mounts.append(inode.ptr());
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);
}
virtual ~MountInode() = default;
virtual ~MountInode();
private:
SharedPtr<VFS::Inode> m_source;

View File

@ -183,6 +183,7 @@ namespace VFS
auto mount = (MountInode*)inode.ptr();
TRY(parent_inode->replace_entry(mount->source(), child.chars()));
g_mounts.remove(mount);
return {};
}