kernel: lock block device before reading from it

This commit is contained in:
2023-07-11 21:26:22 +01:00
parent c696bdf122
commit c0f380ddca

View File

@@ -117,7 +117,10 @@ void kernel_init(uintptr_t arg)
struct device *disk_dev = cast_to_device(disk);
size_t nread = 0;
device_lock(disk_dev);
status = device_read(disk_dev, buf, 1, 32, &nread, 0);
device_unlock(disk_dev);
if (status == KERN_OK) {
printk("read %zu bytes from /dev/block/disk0:", nread);
for (int i = 0; i < sizeof buf; i++) {