MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / ReadAbsolute

Method ReadAbsolute

Kernel/src/storage/partitiondevice.cpp:20–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18}
19
20int 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
36int PartitionDevice::ReadBlock(uint64_t lba, uint32_t count, void* buffer){
37 if(lba * parentDisk->blocksize + count > (endLBA - startLBA) * parentDisk->blocksize) return 2;

Callers

nothing calls this directly

Calls 1

memcpyFunction · 0.85

Tested by

no test coverage detected