| 18 | } |
| 19 | |
| 20 | int PartitionDevice::ReadAbsolute(uint64_t offset, uint32_t count, void* buffer){ |
| 21 | if(offset + count > (endLBA - startLBA) * parentDisk->blocksize) return 2; |
| 22 | |
| 23 | uint64_t lba = offset / parentDisk->blocksize; |
| 24 | uint64_t tempCount = offset + (offset % parentDisk->blocksize); // Account for that we read from start of block |
| 25 | uint8_t buf[tempCount]; |
| 26 | |
| 27 | if(int e = ReadBlock(lba, parentDisk->blocksize, buf)){ |
| 28 | return e; |
| 29 | } |
| 30 | |
| 31 | memcpy(buffer, buf + (offset % parentDisk->blocksize), count); |
| 32 | |
| 33 | return 0; |
| 34 | } |
| 35 | |
| 36 | int PartitionDevice::ReadBlock(uint64_t lba, uint32_t count, void* buffer){ |
| 37 | if(lba * parentDisk->blocksize + count > (endLBA - startLBA) * parentDisk->blocksize) return 2; |