MCPcopy Create free account
hub / github.com/MemNixFS/MemNixFS / scan_swapper

Function scan_swapper

src/os/linux/kernel_resolver.cpp:35–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33}
34
35std::vector<PAddr> scan_swapper(const PhysicalLayer& phys) {
36 std::vector<PAddr> hits;
37 std::vector<u8> buf(kScanChunk + 16);
38 PAddr maxa = phys.max_address();
39 PAddr pa = 0;
40 log::debug("Scanning {:.1f} MB for swapper signature...", maxa / (1024.0 * 1024));
41 while (pa < maxa) {
42 std::size_t want = std::min<u64>(kScanChunk + 16, maxa - pa);
43 std::size_t got = phys.read(pa, buf.data(), want);
44 if (got == 0) { pa += kScanChunk; continue; }
45 std::size_t scan_end = (got >= 16) ? (got - 16) : 0;
46 for (std::size_t i = 0; i < scan_end; ++i) {
47 if (match_swapper(buf.data() + i, got - i)) {
48 hits.push_back(pa + i);
49 }
50 }
51 pa += kScanChunk; // overlap of 16 handled by reading want=CHUNK+16
52 }
53 log::debug("Found {} swapper candidates", hits.size());
54 return hits;
55}
56
57bool read_string(const PhysicalLayer& phys, PAddr pa, std::size_t max, std::string& out) {
58 std::vector<u8> b(max);

Callers 1

resolve_kernelFunction · 0.85

Calls 5

debugFunction · 0.85
match_swapperFunction · 0.85
max_addressMethod · 0.45
readMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected