Files
serenity/Kernel/FileSystem/VirtualFileSystem.cpp
implicitfield 6a4ceb6bf2 Kernel: Avoid double-locking devices when trying to acquire them
Previously, you'd occasionally see this sort of construct (simplified):
```
return FooDevice::all_instances().with([&](auto& list) {
    for (auto& device : list) {
        if (/* search condition */)
            continue;
        return do_something_that_reacquires(device.index());
    }
    return ENOENT;
});
```

This would only work if the relevant `all_instances()` used a recursive
spinlock, since reacquiring the device would lock that again.

To get around this, a new helper has been added in `Device` through
which devices can be accessed whilst locking the device list, removing
the need to loop through the device type's `all_instances()`.
2025-06-05 22:02:40 +02:00

51 KiB