feat: support for USB mass storage devices, hotplugging

This commit is contained in:
2026-05-18 17:47:12 +02:00
parent f8e8af1d78
commit 41d2841cc9
36 changed files with 1537 additions and 130 deletions
+3 -2
View File
@@ -62,7 +62,7 @@ namespace Montauk {
auto* dev = Drivers::Storage::GetBlockDevice(blockDev);
if (!dev) return -1;
if (lba + count > dev->SectorCount) return -1;
if (lba >= dev->SectorCount || count > dev->SectorCount - lba) return -1;
if (!UserMemory::Range((uint64_t)buffer, (uint64_t)count * dev->SectorSize, true)) return -1;
if (!dev->ReadSectors(dev->Ctx, lba, count, buffer)) return -1;
@@ -78,7 +78,7 @@ namespace Montauk {
auto* dev = Drivers::Storage::GetBlockDevice(blockDev);
if (!dev) return -1;
if (lba + count > dev->SectorCount) return -1;
if (lba >= dev->SectorCount || count > dev->SectorCount - lba) return -1;
if (!UserMemory::Range((uint64_t)buffer, (uint64_t)count * dev->SectorSize, false)) return -1;
if (!dev->WriteSectors(dev->Ctx, lba, count, buffer)) return -1;
@@ -88,6 +88,7 @@ namespace Montauk {
// Initialize a new GPT on a block device. Returns 0 on success, -1 on error.
static int64_t Sys_GptInit(int blockDev) {
Fs::FsProbe::UnmountPartitionsForBlockDevice(blockDev);
return (int64_t)Drivers::Storage::Gpt::InitializeGpt(blockDev);
}