mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-25 18:52:22 -05:00
e6284a8774
The SpinLock was all backwards and didn't actually work. Fixing it exposed how wrong most of the locking here is. I need to come up with a better granularity here.
43 lines
1.1 KiB
C++
43 lines
1.1 KiB
C++
#include "DiskDevice.h"
|
|
|
|
DiskDevice::DiskDevice()
|
|
{
|
|
}
|
|
|
|
DiskDevice::~DiskDevice()
|
|
{
|
|
}
|
|
|
|
bool DiskDevice::read(DiskOffset offset, unsigned length, byte* out) const
|
|
{
|
|
//kprintf("DD::read %u x%u\n", offset, length);
|
|
ASSERT((offset % blockSize()) == 0);
|
|
ASSERT((length % blockSize()) == 0);
|
|
dword firstBlock = offset / blockSize();
|
|
dword endBlock = (offset + length) / blockSize();
|
|
byte* outptr = out;
|
|
for (unsigned bi = firstBlock; bi < endBlock; ++bi) {
|
|
if (!readBlock(bi, outptr))
|
|
return false;
|
|
outptr += blockSize();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool DiskDevice::write(DiskOffset offset, unsigned length, const byte* in)
|
|
{
|
|
ASSERT((offset % blockSize()) == 0);
|
|
ASSERT((length % blockSize()) == 0);
|
|
dword firstBlock = offset / blockSize();
|
|
dword endBlock = (offset + length) / blockSize();
|
|
ASSERT(firstBlock <= 0xffffffff);
|
|
ASSERT(endBlock <= 0xffffffff);
|
|
const byte* inptr = in;
|
|
for (unsigned bi = firstBlock; bi < endBlock; ++bi) {
|
|
if (!writeBlock(bi, inptr))
|
|
return false;
|
|
inptr += blockSize();
|
|
}
|
|
return true;
|
|
}
|
|
|