fix: various kernel bug fixes
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include <Fs/FsProbe.hpp>
|
||||
#include <Fs/Fat32.hpp>
|
||||
#include <Fs/Ext2.hpp>
|
||||
#include <Api/UserMemory.hpp>
|
||||
|
||||
#include "Syscall.hpp"
|
||||
|
||||
@@ -25,6 +26,7 @@ namespace Montauk {
|
||||
// Fill a user buffer with partition info. Returns the number of entries written.
|
||||
static int Sys_PartList(PartInfo* buf, int maxCount) {
|
||||
if (buf == nullptr || maxCount <= 0) return 0;
|
||||
if (!UserMemory::Range((uint64_t)buf, (uint64_t)maxCount * sizeof(PartInfo), true)) return -1;
|
||||
|
||||
int total = Drivers::Storage::Gpt::GetPartitionCount();
|
||||
int count = total < maxCount ? total : maxCount;
|
||||
@@ -61,6 +63,7 @@ namespace Montauk {
|
||||
if (!dev) return -1;
|
||||
|
||||
if (lba + count > dev->SectorCount) 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;
|
||||
|
||||
@@ -76,6 +79,7 @@ namespace Montauk {
|
||||
if (!dev) return -1;
|
||||
|
||||
if (lba + count > dev->SectorCount) 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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user