Kernel: Implement DevFileSystem::remove_device
This function cleanly removes the devices from the whole filesystem. USB devices are now removed from the filesystem as soon as they are destroyed.
This commit is contained in:
parent
0578d41500
commit
9d7f97ccd5
|
@ -18,6 +18,8 @@ namespace Kernel
|
||||||
void initialize_device_updater();
|
void initialize_device_updater();
|
||||||
|
|
||||||
void add_device(BAN::RefPtr<Device>);
|
void add_device(BAN::RefPtr<Device>);
|
||||||
|
void remove_device(BAN::RefPtr<Device>);
|
||||||
|
|
||||||
void add_inode(BAN::StringView path, BAN::RefPtr<TmpInode>);
|
void add_inode(BAN::StringView path, BAN::RefPtr<TmpInode>);
|
||||||
|
|
||||||
void initiate_sync(bool should_block);
|
void initiate_sync(bool should_block);
|
||||||
|
|
|
@ -112,6 +112,21 @@ namespace Kernel
|
||||||
MUST(m_devices.push_back(device));
|
MUST(m_devices.push_back(device));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DevFileSystem::remove_device(BAN::RefPtr<Device> device)
|
||||||
|
{
|
||||||
|
LockGuard _(m_device_lock);
|
||||||
|
ASSERT(!device->name().contains('/'));
|
||||||
|
MUST(static_cast<TmpDirectoryInode*>(root_inode().ptr())->unlink(device->name()));
|
||||||
|
for (size_t i = 0; i < m_devices.size(); i++)
|
||||||
|
{
|
||||||
|
if (m_devices[i] == device)
|
||||||
|
{
|
||||||
|
m_devices.remove(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DevFileSystem::add_inode(BAN::StringView path, BAN::RefPtr<TmpInode> inode)
|
void DevFileSystem::add_inode(BAN::StringView path, BAN::RefPtr<TmpInode> inode)
|
||||||
{
|
{
|
||||||
ASSERT(!inode->is_device());
|
ASSERT(!inode->is_device());
|
||||||
|
|
|
@ -78,7 +78,10 @@ namespace Kernel
|
||||||
{}
|
{}
|
||||||
|
|
||||||
USBHIDDriver::~USBHIDDriver()
|
USBHIDDriver::~USBHIDDriver()
|
||||||
{}
|
{
|
||||||
|
if (m_hid_device)
|
||||||
|
DevFileSystem::get().remove_device(m_hid_device);
|
||||||
|
}
|
||||||
|
|
||||||
BAN::ErrorOr<void> USBHIDDriver::initialize()
|
BAN::ErrorOr<void> USBHIDDriver::initialize()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue