pagemap: was missing one bit in lkmc_pagemap_get_entry for pfn

Credits to Phidelux:
https://stackoverflow.com/questions/6284810/proc-pid-pagemaps-and-proc-pid-maps-linux/45500208?noredirect=1#comment109030479_45500208
This commit is contained in:
Ciro Santilli 六四事件 法轮功
2020-05-09 01:00:00 +00:00
parent 12ed05f893
commit 6275f70ed8
2 changed files with 8 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
/* https://cirosantilli.com/linux-kernel-module-cheat#pagemap-dump-out */
#define _XOPEN_SOURCE 700
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <stdint.h>
@@ -91,8 +92,10 @@ int main(int argc, char **argv) {
{
LkmcPagemapEntry entry;
for (uintptr_t vaddr = low; vaddr < high; vaddr += sysconf(_SC_PAGE_SIZE)) {
/* TODO always fails for the last page (vsyscall), why? pread returns 0. */
if (!lkmc_pagemap_get_entry(&entry, pagemap_fd, vaddr)) {
if (lkmc_pagemap_get_entry(&entry, pagemap_fd, vaddr)) {
/* TODO always fails for the last page (vsyscall), why? pread returns 0. */
/*assert(0);*/
} else {
printf(
"%jx %jx %u %u %u %u %s\n",
(uintmax_t)vaddr,